📄 infonodelookandfeel.java
字号:
*/
public InfoNodeLookAndFeelTheme getTheme() {
return theme;
}
public void initialize() {
super.initialize();
if (oldMetalTheme == null) {
// Try to obtain the old Metal theme if possible
try {
oldMetalTheme = (MetalTheme) MetalLookAndFeel.class.getMethod("getCurrentTheme", null).invoke(null, null);
}
catch (NoSuchMethodException e) {
// Ignore
}
catch (IllegalAccessException e) {
// Ignore
}
catch (InvocationTargetException e) {
// Ignore
}
}
setCurrentTheme(defaultTheme);
}
public void uninitialize() {
setCurrentTheme(oldMetalTheme == null ? new DefaultMetalTheme() : oldMetalTheme);
oldMetalTheme = null;
}
public String getName() {
return LOOK_AND_FEEL_INFO.getName();
}
public String getDescription() {
return "A slim look and feel based on Metal.";
}
protected void initClassDefaults(UIDefaults table) {
super.initClassDefaults(table);
try {
{
Class cl = SlimSplitPaneUI.class;
table.put("SplitPaneUI", cl.getName());
table.put(cl.getName(), cl);
}
{
Class cl = SlimInternalFrameUI.class;
table.put("InternalFrameUI", cl.getName());
table.put(cl.getName(), cl);
}
{
Class cl = SlimComboBoxUI.class;
SlimComboBoxUI.NORMAL_BORDER = theme.getListItemBorder();
SlimComboBoxUI.FOCUS_BORDER = theme.getListFocusedItemBorder();
table.put("ComboBoxUI", cl.getName());
table.put(cl.getName(), cl);
}
{
Class cl = SlimMenuItemUI.class;
table.put("MenuItemUI", cl.getName());
table.put(cl.getName(), cl);
}
}
catch (Exception ex) {
throw new RuntimeException(ex);
}
}
private static class MyListCellRenderer extends DefaultListCellRenderer {
private Border normalBorder;
private Border focusBorder;
MyListCellRenderer(Border normalBorder, Border focusBorder) {
this.normalBorder = normalBorder;
this.focusBorder = focusBorder;
}
public Component getListCellRendererComponent(JList list, Object value, int index,
boolean isSelected,
boolean cellHasFocus) {
JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
label.setBorder(cellHasFocus ? focusBorder : normalBorder);
return label;
}
public static class UIResource extends MyListCellRenderer implements javax.swing.plaf.UIResource {
public UIResource(Border normalBorder, Border focusBorder) {
super(normalBorder, focusBorder);
}
}
}
protected void initComponentDefaults(UIDefaults table) {
super.initComponentDefaults(table);
Class iconClass = MetalLookAndFeel.class;
UIResource menuItemBorder = new MetalBorders.MenuItemBorder() {
public Insets getBorderInsets(Component c) {
return new Insets(2, 0, 2, 0);
}
};
Object[] defaults = {
"SplitPane.dividerSize", new Integer(theme.getSplitPaneDividerSize()),
// "SplitPaneDivider.border", new BorderUIResource(splitPaneDividerBorder),
// "SplitPane.border", new BorderUIResource(splitPaneBorder),
// "TabbedPane.contentBorderInsets", tabbedPaneContentInsets,
// "TabbedPane.tabAreaInsets", new InsetsUIResource(0, 0, 0, 0),
// "TabbedPane.selectedTabPadInsets", new InsetsUIResource(0, 0, 0, 0),
// "TabbedPane.tabInsets", new InsetsUIResource(0, 0, 0, 0),
"TabbedPane.background", theme.getControlLightShadowColor(),
//"TabbedPane.darkShadow", new Color(160, 160, 160),
"ComboBox.selectionBackground", theme.getSelectedMenuBackgroundColor(),
"ComboBox.selectionForeground", theme.getSelectedMenuForegroundColor(),
"List.cellRenderer", new UIDefaults.ActiveValue() {
public Object createValue(UIDefaults table) {
return new MyListCellRenderer.UIResource(theme.getListItemBorder(), theme.getListFocusedItemBorder());
}
},
"ToolTip.foreground", theme.getTooltipForegroundColor(),
"ToolTip.background", theme.getTooltipBackgroundColor(),
"Viewport.background", theme.getBackgroundColor(),
"ScrollBar.background", theme.getScrollBarBackgroundColor(),
"ScrollBar.shadow", theme.getScrollBarBackgroundShadowColor(),
"ScrollBar.width", new Integer(theme.getScrollBarWidth()),
// "ScrollBar.border", new BorderUIResource(new LineBorder(Color.GRAY, 1)),
// "ScrollBar.thumb", new RelativeColor(thumbColor, 0.8).getColor(),
// "ScrollBar.thumbShadow", new RelativeColor(thumbColor, 0.7).getColor(),
// "ScrollBar.thumbHighlight", new RelativeColor(thumbColor, 1).getColor(),
/* "ScrollBar.thumb", new ColorUIResource(255, 255, 255),
"ScrollBar.thumbShadow", new ColorUIResource(0, 255, 0),
"ScrollBar.thumbHighlight", new ColorUIResource(255, 255, 255),
*/
"Table.focusCellBackground", new ColorUIResource(ColorUtil.mult(theme.getSelectedMenuBackgroundColor(), 1.40f)),
"Table.focusCellForeground", theme.getSelectedMenuForegroundColor(),
"TableHeader.cellBorder", theme.getTableHeaderCellBorder(),
"InternalFrame.activeTitleBackground", theme.getActiveInternalFrameTitleBackgroundColor(),
"InternalFrame.activeTitleForeground", theme.getActiveInternalFrameTitleForegroundColor(),
"InternalFrame.activeTitleGradient", theme.getActiveInternalFrameTitleGradientColor(), //ColorUtil.mult(theme.getActiveInternalFrameTitleBackgroundColor(), 1.2),
"InternalFrame.inactiveTitleBackground", theme.getInactiveInternalFrameTitleBackgroundColor(),
"InternalFrame.inactiveTitleForeground", theme.getInactiveInternalFrameTitleForegroundColor(),
"InternalFrame.inactiveTitleGradient", theme.getInactiveInternalFrameTitleGradientColor(), //ColorUtil.mult(theme.getInactiveInternalFrameTitleBackgroundColor(), 1.2),
"InternalFrame.icon", theme.getInternalFrameIcon(),
"InternalFrame.iconifyIcon", theme.getInternalFrameIconifyIcon(),
"InternalFrame.minimizeIcon", theme.getInternalFrameMinimizeIcon(),
"InternalFrame.maximizeIcon", theme.getInternalFrameMaximizeIcon(),
"InternalFrame.closeIcon", theme.getInternalFrameCloseIcon(),
"InternalFrame.border", theme.getInternalFrameBorder(),
"InternalFrame.titleFont", theme.getInternalFrameTitleFont(),
"MenuBar.border", theme.getMenuBarBorder(),
"MenuItem.border", menuItemBorder,
"Menu.border", menuItemBorder,
// "CheckBoxMenuItem.border", menuItemBorder,
// "RadioButtonMenuItem.border", menuItemBorder,
"Spinner.border", theme.getTextFieldBorder(),
"Spinner.background", new ColorUIResource(theme.getBackgroundColor()),
"PopupMenu.border", theme.getPopupMenuBorder(),
"TextField.border", theme.getTextFieldBorder(),
"FormattedTextField.border", theme.getTextFieldBorder(),
// "Button.border", new BorderUIResource(buttonBorder),
// "Button.disabledShadow", new ColorUIResource(Color.GREEN), //ColorUtil.blend(textColor, controlColor, 0.5f)),
"Button.textShiftOffset", new Integer(2),
"Button.select", theme.getControlLightShadowColor(),
// "Button.focus", focusColor,
"Button.margin", theme.getButtonMargin(),
"Button.disabledText", theme.getInactiveTextColor(),
//"Button.background", buttonBackground.getColor(),
"ToggleButton.margin", theme.getButtonMargin(),
"ToggleButton.select", theme.getControlLightShadowColor(),
"ToggleButton.textShiftOffset", new Integer(2),
"Tree.openIcon", theme.getTreeOpenIcon(),
"Tree.closedIcon", theme.getTreeClosedIcon(),
"Tree.leafIcon", theme.getTreeLeafIcon(),
"Tree.collapsedIcon", new IconUIResource(
new TreeIcon(TreeIcon.PLUS, 10, 10, true, theme.getTextColor(), theme.getTreeIconBackgroundColor())),
"Tree.expandedIcon", new IconUIResource(
new TreeIcon(TreeIcon.MINUS, 10, 10, true, theme.getTextColor(), theme.getTreeIconBackgroundColor())),
"Tree.leftChildIndent", new Integer(5),
"Tree.rightChildIndent", new Integer(11),
// "Tree.rowHeight", new Integer(12),
"OptionPane.errorIcon", LookAndFeel.makeIcon(iconClass, "icons/Error.gif"),
"OptionPane.informationIcon", LookAndFeel.makeIcon(iconClass, "icons/Inform.gif"),
"OptionPane.warningIcon", LookAndFeel.makeIcon(iconClass, "icons/Warn.gif"),
"OptionPane.questionIcon", LookAndFeel.makeIcon(iconClass, "icons/Question.gif"),
"OptionPane.buttonFont", theme.getOptionPaneButtonFont(),
};
table.putDefaults(defaults);
}
/**
* Installs this look and feel with the {@link UIManager}, if it's not already installed.
*/
public static void install() {
if (!ArrayUtil.contains(UIManager.getInstalledLookAndFeels(), LOOK_AND_FEEL_INFO))
UIManager.installLookAndFeel(LOOK_AND_FEEL_INFO);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -