⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xplookandfeel.java

📁 Swing Windows XP 外观和感觉 BeanSoft 修改版, 2003年 原始的作者: XP 外观和感觉 by Stefan Krause - http://www.stefan
💻 JAVA
📖 第 1 页 / 共 2 页
字号:

  /**
   * Sets the current color theme.
   * Warning: The them must be an instance of XPDefaultTheme!
   *
   * @param theme The theme to install.
   */
  public static void setCurrentTheme(MetalTheme theme)
  {
    MetalLookAndFeel.setCurrentTheme(theme);
    themeHasBeenSet = true;
  }

  /**
   * Initializes the system colors.
   *
   * @param table The ui defaults table.
   */
  protected void initSystemColorDefaults(UIDefaults table)
  {
    super.initSystemColorDefaults(table);
    table.put("textHighlight", getTextHighlightColor());
  }

  /**
   * Initializes the default values for many ui widgets and puts them in the
   * given ui defaults table.
   * Here is the place where borders can be changed.
   *
   * @param table The ui defaults table.
   */
  protected void initComponentDefaults(UIDefaults table)
  {
    /* As you can see this is still work in progress... */
    // Let Metal Look and Feel do the basic and complete initializations:
    super.initComponentDefaults(table);

    // Replace the Metal borders:
    Border border;
  	border= new EmptyBorder(0,0,0,0); //4, 16, 4, 16);
//    border=new EmptyBorder(4, 16, 4, 16);
  	table.put("Button.margin", new InsetsUIResource(4, 16, 4, 16)); //MetouiaBorderUtilities.getButtonBorder());
    table.put("Button.border", new BasicBorders.MarginBorder()); //MetouiaBorderUtilities.getButtonBorder());    
  	table.put("ToggleButton.margin", new InsetsUIResource(4, 16, 4, 16)); //, MetouiaBorderUtilities.getButtonBorder());
    table.put("ToggleButton.border", new BasicBorders.MarginBorder()); //new BasicBorders.MarginBorder()); //, MetouiaBorderUtilities.getButtonBorder());
    table.put("TextField.border", new XPTextFieldBorder()); //MetouiaBorderUtilities.getTextFieldBorder());
    table.put("Spinner.border", new XPTextFieldBorder(new Insets(2,2,2,2))); //MetouiaBorderUtilities.getTextFieldBorder());
  	border=new EmptyBorder(2, 2, 2, 2);
    table.put("ToolBar.border", border); //border); //MetouiaBorderUtilities.getButtonBorder()); //new MetouiaToolBarBorder());
//    table.put("MenuBar.border", new EmptyBorder(20,2,2,2));
    table.put("InternalFrame.border", border); //new XPInternalFrameBorder() );
    table.put("InternalFrame.paletteBorder", border); //new XPInternalFrameBorder()); //new XPInternalFrameBorder()); //XPInternalFrameBorder());
    table.put("InternalFrame.optionDialogBorder", border); //new XPInternalFrameBorder()); //new XPInternalFrameBorder()); //XPInternalFrameBorder());
//    table.put("InternalFrame.paletteBorder", new MetouiaPaletteBorder());
//    table.put("InternalFrame.optionDialogBorder", new MetouiaOptionDialogBorder());
    border = new EmptyBorder(2,4,2,4); 
    table.put("Menu.border", border);
    table.put("MenuItem.border", border);
    table.put("CheckBoxMenuItem.border", border);
    table.put("RadioButtonMenuItem.border", border);
    border = new XPPopupMenuBorder();
    table.put("PopupMenu.border", border);
//    table.put("TableHeader.cellBorder", new MetouiaTableHeaderBorder()); 
  	
  	table.put("ScrollPane.border", new LineBorder(new Color(127,157,185),1)); //new MetouiaScrollPaneBorder());

    // Tweak some subtle values:
    table.put("SplitPane.dividerSize", new Integer(6));
    table.put("InternalFrame.paletteTitleHeight", new Integer(10));
    table.put("InternalFrame.frameTitleHeight", new Integer(21));
    table.put("InternalFrame.normalTitleFont",new Font("Trebuchet MS",Font.BOLD,13));
    
	// TabbedPane
//FontUIResource
//TabbedPane.font
//ColorUIResource:
//TabbedPane.shadow
// TabbedPane.darkShadow
	//TabbedPane.focus
//	table.put("TabbedPane.background", Color.red);
//	table.put("TabbedPane.foreground", Color.green);
//	table.put("TabbedPane.highlight", Color.blue);
//	table.put("TabbedPane.shadow", Color.pink);
//	table.put("TabbedPane.darkShadow", Color.cyan);
//	table.put("TabbedPane.lightHighlight", Color.yellow);
//	table.put("TabbedPane.textIconGap",new Integer(20));
//	table.put("TabbedPane.tabInsets",new Insets(40,0,0,0));
//	table.put("TabbedPane.selectedTabPadInsets",new Insets(2, 1, 1, 2)); 	// OK
	table.put("TabbedPane.selectedTabPadInsets",new Insets(2, 2, 2, 3)); 	// OK
//	table.put("TabbedPane.tabAreaInsets",new Insets(4, 2, 0, 6)); // OK
	table.put("TabbedPane.tabAreaInsets",new Insets(4, 2, 0, 0)); // OK
//	table.put("TabbedPane.tabInsets",new Insets(20,20,20,20)); // OK
//	table.put("TabbedPane.contentBorderInsets",new Insets(20,20,20,20)); // OK
	
	table.put("TabbedPane.contentBorderInsets",new Insets(1,1,3,3)); // OK 
//	table.put("TabbedPane.contentBorderInsets",new Insets(1,1,3,3)); // OK 
//	table.put("TabbedPane.tabRunOverlay",new Integer(20));


//    "TabbedPane.contentBorderInsets", tabbedPaneContentBorderInsets,
//    table.put("Button.select", xpTheme.getPressedBackground());
//    table.put("RadioButton.select", xpTheme.getPressedBackground());
//    table.put("ToggleButton.select", xpTheme.getPressedBackground());
    table.put("Checkbox.select", xpTheme.getPressedBackground());
    table.put("TabbedPane.unselected", xpTheme.getPressedBackground());
    table.put("PopupMenu.background", new Color(0,255,0));//xpTheme.getMenuBackground());
    table.put("PopupMenu.foreground", new Color(255,0,0)); 
    
    table.put("TextField.selectionForeground", Color.white);
    table.put("TextField.selectionBackground", new Color(49,106,197));
    
    table.put("TextField.background", Color.white);
    table.put("TextField.disabledBackground", new Color(236,233,216));


    table.put("ComboBox.foreground", Color.black); 
    table.put("ComboBox.background", Color.white); 
    table.put("ComboBox.selectionForeground", Color.white); 
    table.put("ComboBox.selectionBackground", new Color(49,106,197)); 
    table.put("ComboBox.focusBackground", new Color(49,106,197)); 
    

    // Change some icons:
//    table.put("InternalFrame.icon", loadIcon("default.res", this));
//    table.put("InternalFrame.paletteCloseIcon", loadIcon("pclose.res", this));
//    table.put("InternalFrame.closeIcon", loadIcon("close.res", this));
//    table.put("InternalFrame.maximizeIcon", loadIcon("maximize.res", this));
//    table.put("InternalFrame.iconifyIcon", loadIcon("minimize.res", this));
//    table.put("InternalFrame.minimizeIcon", loadIcon("restore.res", this));
    table.put("InternalFrame.frameTitleHeight",new Integer(25));
  	table.put("InternalFrame.paletteTitleHeight",new Integer(16));
  	
    table.put("InternalFrame.icon",loadIcon("XPInternalFrameIcon.res",this));
    
    table.put("ToolTip.background",new Color(255,255,225));
    table.put("ToolTip.foreground",new Color(0,0,0));
    table.put("ToolTip.font",xpTheme.getControlTextFont());
    table.put("ToolTip.border",new CompoundBorder(new LineBorder(Color.black,1), new EmptyBorder(2,2,2,2)));
    
    table.put("Tree.selectionForeground",Color.white );
    table.put("Tree.selectionBackground",new Color(49,106,197) );
    table.put("Tree.expandedIcon",loadIcon("XPTreeMinus.res",this) );
    table.put("Tree.collapsedIcon",loadIcon("XPTreePlus.res",this) );
    table.put("Tree.openIcon",loadIcon("XPTreeFolderOpened.res",this) );
    table.put("Tree.closedIcon",loadIcon("XPTreeFolderClosed.res",this) );
    table.put("Tree.leafIcon",loadIcon("XPTreeLeaf.res",this) );

  	table.put("List.selectionForeground",Color.white );
  	table.put("List.selectionBackground",new Color(49,106,197) );

    
    table.put("FileView.directoryIcon",loadIcon("XPTreeFolderClosed.res",this) );
    table.put("FileView.computerIcon",loadIcon("XPComputerIcon.res",this) );
    table.put("FileView.fileIcon",loadIcon("XPDocument.res",this) );
    table.put("FileView.floppyDriveIcon",loadIcon("XPFloppy.res",this) );
    table.put("FileView.hardDriveIcon",loadIcon("XPHarddisk.res",this) );
    
    table.put("FileChooser.detailsViewIcon",loadIcon("XPFileDetails.res",this) );
    table.put("FileChooser.homeFolderIcon",loadIcon("XPDesktopIcon.res",this) );
    table.put("FileChooser.listViewIcon",loadIcon("XPFileList.res",this) );
    table.put("FileChooser.newFolderIcon",loadIcon("XPNewFolder.res",this) );
    table.put("FileChooser.upFolderIcon",loadIcon("XPParentDirectory.res",this) );
    table.put("FileChooser.upFolderIcon",loadIcon("XPParentDirectory.res",this) );
           
           
	table.put("OptionPane.errorIcon", loadIcon("XPError.res",this) );
	table.put("OptionPane.informationIcon", loadIcon("XPInformation.res",this) );
	table.put("OptionPane.warningIcon", loadIcon("XPWarning.res",this) );
	table.put("OptionPane.questionIcon", loadIcon("XPQuestion.res",this) );           
//    Tree.leafIcon
    
//    table.put("RadioButton.icon", new UIDefaults.ProxyLazyValue("com.stefankrause.xplookandfeel.MetouiaIconFactory","getRadioButtonIcon"));

//	"ScrollBar.darkShadow",.getSecondary1()
  }

  /**
   * Loads an image icon.
   *
   * @param file The image file name.
   * @param invoker The refence of the invoking class, whose classloader will be
   *                used for loading the image.
   */
  public static ImageIcon loadIcon(final String file, final Object invoker)
  {
  	// When we return an IconUIResource the disabled icon of a file choose won't be painted greyed out,
  	// thus we simply stay with an icon
  	return loadIconImmediately(file,invoker); //LookAndFeel.makeIcon(XPLookAndFeel.class,"icons/"+file);
  }

  /**
   * Loads an image icon immediately.
   *
   * @param file The image file name.
   * @param invoker The refence of the invoking class, whose classloader will be
   *                used for loading the image.
   */
  public static ImageIcon loadIconImmediately(String file, Object invoker)
  {
    try
    {
       Image img=SkinImageCache.getInstance().getImage(file);
       ImageIcon icon = new ImageIcon(img);
      /*Toolkit.getDefaultToolkit().createImage(
        readStream(invoker.getClass().getResourceAsStream(file))));*/
       if (icon.getIconWidth()<=0) {
          	System.out.println("******************** File "+file+" not found. Exiting");
          	System.exit(1);
      }
      return icon;
    }
    catch (Exception exception)
    {
      exception.printStackTrace();
      System.out.println("Error getting resource " + file);
      return null;
    }
  }
  
  public static Color getLightControl() {
  	return xpTheme.getControlHighlight();	
  }
  
  /**
   * used for SliderUI Ticks
   */
  public static Color getDarkControl() {
  	return xpTheme.getDarkControl();
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -