📄 toniclookandfeel.java
字号:
result.put("RootPane.frameBorder", internalFrameBorder2);
result.put("RootPane.plainDialogBorder", plainDialogBorder);
result.put("RootPane.informationDialogBorder", plainDialogBorder);
result.put("RootPane.errorDialogBorder", plainDialogBorder);
result.put("RootPane.colorChooserDialogBorder", plainDialogBorder);
result.put("RootPane.fileChooserDialogBorder", plainDialogBorder);
result.put("RootPane.questionDialogBorder", plainDialogBorder);
result.put("RootPane.warningDialogBorder", plainDialogBorder);
if(isSlim)
result.put("ScrollBar.width", new Integer(14)); // activeShadow); //windowBg);
result.put("ScrollBar.background", activeBg); // activeShadow); //windowBg);
result.put("ScrollBar.thumb", activeHighlight);
result.put("ScrollBar.thumbHighlight", activeHighlight);
result.put("ScrollBar.thumbShadow", activeLightShadow);
result.put("ScrollBar.thumbStripes", activeLightShadow);
result.put("ScrollPane.viewportBorder", null);
result.put("ScrollPane.border", new BorderUIResource.LineBorderUIResource(borderColor));
result.put("Separator.foreground", borderColor);
result.put("Separator.background", windowBg);
result.put("Slider.background", windowBg);
result.put("Slider.foreground", textFg);
result.put("Slider.trackColor", activeBg);
result.put("SplitPane.dividerSize", new Integer(4));
result.put("SplitPane.oneTouchDividerSize", new Integer(8));
result.put("SplitPane.background", windowBg);
result.put("SplitPane.border", new BorderUIResource.MatteBorderUIResource(5, 5, 2, 2, windowBg));
result.put("Spinner.border", null);
result.put("TabbedPane.selectedTabPadInsets", new InsetsUIResource(2, 0, 0, 0));
if(isSlim)
result.put("TabbedPane.tabInsets", new InsetsUIResource(0, 6, 0, 6));
else
result.put("TabbedPane.tabInsets", new InsetsUIResource(3, 6, 2, 6));
result.put("TabbedPane.font", stdFont);
result.put("TabbedPane.thickBorders", new Boolean(false));
result.put("TabbedPane.selectedFont", stdBoldFont);
result.put("TabbedPane.selected", windowBg);
result.put("TabbedPane.background", inactiveBg);
result.put("Table.scrollPaneBorder", new BorderUIResource.LineBorderUIResource(borderColor));
result.put("Table.selectionBackground", selBg);
result.put("Table.selectionForeground", selFg);
result.put("Table.focusCellBackground", selBg);
result.put("Table.focusCellForeground", selFg);
result.put("Table.focusCellHighlightBorder", null);
result.put("TableHeader.cellBorder", new BorderUIResource.MatteBorderUIResource(0, 0, 1, 1, borderColor));
result.put("TextArea.selectionBackground", selBg);
result.put("TextArea.selectionForeground", selFg);
result.put("TextField.selectionBackground", selBg);
result.put("TextField.selectionForeground", selFg);
result.put("TextField.border", simpleBorder);
result.put("ToggleButton.border", null);
result.put("ToggleButton.background", activeBg);
result.put("ToolBar.background", windowBg);
result.put("ToolBar.border", menuBarBorder);
result.put("ToolBar.verticalBorder", toolBarVerticalBorder);
result.put("ToolButton.activeBackground", toolButtonActiveBg);
result.put("ToolButton.activeForeground", selFg);
result.put("ToolButton.activeBorderColor", toolButtonBorder);
result.put("ToolTip.background", toolTipBg);
result.put("ToolTip.border", new BorderUIResource.LineBorderUIResource(borderColor));
result.put("Tree.expandedIcon", LookAndFeel.makeIcon(getClass(),"icons/tree_expanded.gif"));
result.put("Tree.leafIcon", LookAndFeel.makeIcon(getClass(),"icons/tree_leaf.gif"));
result.put("Tree.collapsedIcon", LookAndFeel.makeIcon(getClass(),"icons/tree_collapsed.gif"));
result.put("Tree.closedIcon", LookAndFeel.makeIcon(getClass(),"icons/tree_closed.gif"));
result.put("Tree.openIcon", LookAndFeel.makeIcon(getClass(),"icons/tree_open.gif"));
result.put("Tree.selectionBackground", selBg);
result.put("Tree.selectionBorderColor", selBg);
result.put("Tree.selectionForeground", selFg);
result.put("Tree.textBackground", fieldBg);
result.put("Tree.textForeground", textFg);
result.put("Tree.font", stdFont);
result.put("Tree.foreground", textFg);
result.put("Tree.line", treeLineColor);
result.put("Tree.hash", treeLineColor);
result.put("Tree.rowHeight", new Integer(17));
// Set constants for NetBeans (workaround for buggy NB)
result.put("controlFont", new FontUIResource(new Font("Dialog", Font.PLAIN, 11)));
// Associate the icons with their components
setIcon(result, "Menu.arrowIcon", "icons/arrow.gif");
setIcon(result, "Menu.invArrowIcon", "icons/invarrow.gif");
setIcon(result, "CheckBoxMenuItem.uncheckIcon", "icons/menucheckbox0.gif");
setIcon(result, "CheckBoxMenuItem.checkIcon", "icons/menucheckbox1.gif");
setIcon(result, "RadioButtonMenuItem.uncheckIcon", "icons/menuradiobutton0.gif");
setIcon(result, "RadioButtonMenuItem.checkIcon", "icons/menuradiobutton1.gif");
setIcon(result, "ComboBox.icon", "icons/downarrow.gif");
setIcon(result, "Arrow.down", "icons/downarrow.gif");
setIcon(result, "Arrow.up", "icons/uparrow.gif");
setIcon(result, "Arrow.left", "icons/leftarrow.gif");
setIcon(result, "Arrow.right", "icons/rightarrow.gif");
setIcon(result, "RadioButton.unselectedEnabledIcon", "icons/radiobutton0.gif");
setIcon(result, "RadioButton.selectedEnabledIcon", "icons/radiobutton1.gif");
setIcon(result, "RadioButton.unselectedDisabledIcon", "icons/radiobutton0.gif");
setIcon(result, "RadioButton.selectedDisabledIcon", "icons/radiobutton1.gif");
setIcon(result, "CheckBox.unselectedEnabledIcon", "icons/checkbox0.gif");
setIcon(result, "CheckBox.selectedEnabledIcon", "icons/checkbox1.gif");
setIcon(result, "CheckBox.unselectedDisabledIcon", "icons/checkbox0.gif");
setIcon(result, "CheckBox.selectedDisabledIcon", "icons/checkbox1.gif");
setIcon(result, "Slider.horizontalThumbIcon", "icons/sliderdown.gif");
setIcon(result, "Slider.verticalThumbIcon", "icons/sliderright.gif");
return result;
}
/** Adds to the specified UIDefaults an association of the specified key with
* an icon made from the specified icon file name. The icon is created
* by calling makeIcon().
*
* @param uiDefaults The UI defaults table for which the specified
* icon will be added
* @param key The key under which the icon will be added
* @param iconFileName The file name of the icon to be associated
* with the key
* @see #makeIcon()
*/
private void setIcon(UIDefaults uiDefaults, String key, String iconFileName)
{
Object icon=LookAndFeel.makeIcon(getClass(), iconFileName);
uiDefaults.put(key, icon);
}
/** Returns a predefined icon associated with the specified key. This method
* grants access to Tonic themed icons fitting the visual appearance of the
* whole look and feel.
*
* @param key The key for the icon to be returned
*
* @return The icon associated with the specified key, or
* null, if the key was invalid.
*/
public static ImageIcon getTonicIcon(String key)
{
URL url=TonicLookAndFeel.class.getResource("icons/collection/"+key);
if(url!=null)
return new ImageIcon(url);
else
{
url=TonicLookAndFeel.class.getResource("icons/collection/"+key+".gif");
if(url!=null)
return new ImageIcon(url);
}
return null;
}
/** Returns the color for the focus */
public static ColorUIResource getFocusColor()
{
return focusColor;
}
public static ColorUIResource getPrimaryControlDarkShadow()
{
return selBg;
}
/** Returns a one line description of this look and feel */
public String getDescription()
{
return "Tonic look and feel";
}
/** Returns a String that identifies this look and feel */
public String getID()
{
return "TonicLF";
}
/** Returns the name of this look and feel */
public String getName()
{
return "Tonic Look and Feel";
}
/** Returns true if the LookAndFeel returned RootPaneUI instances support
* providing Window decorations in a JRootPane.
*/
public boolean getSupportsWindowDecorations()
{
return true;
}
/** This is called before the first (and usually only) call to getDefaults.
*
* @see #getDefaults()
*/
public void initialize()
{
super.initialize();
}
/** Returns true if this is the native look and feel of the current
* operating system.
*/
public boolean isNativeLookAndFeel()
{
return false;
}
/** Returns true if the underlying platform supports or allows
* this look and feel
*/
public boolean isSupportedLookAndFeel()
{
return true;
}
/** Invoked when the user attempts an invalid operation, such as pasting
* into an uneditable JTextField that has focus.
*/
public void provideErrorFeedback(Component component)
{
super.provideErrorFeedback(component);
}
/** UIManager.setLookAndFeel calls this method just before we're
* replaced by a new default look and feel.
*/
public void uninitialize()
{
super.uninitialize();
}
public static void setStandardFont(Font font)
{
stdFont=new FontUIResource(font);
}
// /**
// * Utility method that creates a UIDefaults.LazyValue that creates
// * an ImageIcon UIResource for the specified <code>gifFile</code>
// * filename.
// */
// public static Object makeIcon(final Class baseClass, final String gifFile)
// {
// return new UIDefaults.LazyValue()
// {
// public Object createValue(UIDefaults table)
// {
// /* Copy resource into a byte array. This is
// * necessary because several browsers consider
// * Class.getResource a security risk because it
// * can be used to load additional classes.
// * Class.getResourceAsStream just returns raw
// * bytes, which we can convert to an image.
// */
// final byte[][] buffer= new byte[1][];
//
// try
// {
// SwingUtilities.invokeAndWait(new Runnable()
// {
// public void run()
// {
// try
// {
// InputStream resource=
// baseClass.getResourceAsStream(gifFile);
// if (resource == null)
// {
// return;
// }
// BufferedInputStream in= new BufferedInputStream(resource);
// ByteArrayOutputStream out= new ByteArrayOutputStream(1024);
// buffer[0]= new byte[1024];
// int n;
// while ((n= in.read(buffer[0])) > 0)
// {
// out.write(buffer[0], 0, n);
// }
// in.close();
// out.flush();
// buffer[0]= out.toByteArray();
// }
// catch (IOException ioe)
// {
// System.err.println(ioe.toString());
// return;
// }
// }
// });
// }
// catch(InterruptedException e)
// {
// System.err.println("Could not load icon - interrupted: "+e.getMessage());
// }
// catch (InvocationTargetException e)
// {
// e.printStackTrace(System.err);
// }
//
// if (buffer[0] == null)
// {
// System.err.println(
// baseClass.getName() + "/" + gifFile + " not found.");
// return null;
// }
// if (buffer[0].length == 0)
// {
// System.err.println("warning: " + gifFile + " is zero-length");
// return null;
// }
//
// return new ImageIcon(buffer[0]);
// }
// };
// }
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -