List of usage examples for javax.swing UIDefaults put
public Object put(Object key, Object value)
key
to value
for all locales. From source file:MainClass.java
public static void main(String args[]) throws Exception { JFrame frame = new JFrame("Icon Slider"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Icon icon = new ImageIcon("logo.gif"); UIDefaults defaults = UIManager.getDefaults(); defaults.put("Slider.horizontalThumbIcon", icon); JSlider aJSlider = new JSlider(); aJSlider.setPaintTicks(true);//from ww w . j a va 2 s .c o m frame.add(aJSlider, BorderLayout.NORTH); frame.setSize(300, 200); frame.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame("Tick Slider"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // No Ticks/* ww w . j ava 2s.c om*/ JSlider jSliderOne = new JSlider(); Icon icon = new ImageIcon("yourFile.gif"); UIDefaults defaults = UIManager.getDefaults(); defaults.put("Slider.horizontalThumbIcon", icon); frame.add(jSliderOne, BorderLayout.NORTH); frame.setSize(300, 200); frame.setVisible(true); }
From source file:net.rptools.maptool.client.MapTool.java
public static void main(String[] args) { if (MAC_OS_X) { // On OSX the menu bar at the top of the screen can be enabled at any time, but the // title (ie. name of the application) has to be set before the GUI is initialized (by // creating a frame, loading a splash screen, etc). So we do it here. System.setProperty("apple.laf.useScreenMenuBar", "true"); System.setProperty("com.apple.mrj.application.apple.menu.about.name", "About MapTool..."); System.setProperty("apple.awt.brushMetalLook", "true"); }//w w w. j av a 2s . co m // Before anything else, create a place to store all the data try { AppUtil.getAppHome(); } catch (Throwable t) { t.printStackTrace(); // Create an empty frame so there's something to click on if the dialog goes in the background JFrame frame = new JFrame(); SwingUtil.centerOnScreen(frame); frame.setVisible(true); String errorCreatingDir = "Error creating data directory"; log.error(errorCreatingDir, t); JOptionPane.showMessageDialog(frame, t.getMessage(), errorCreatingDir, JOptionPane.ERROR_MESSAGE); System.exit(1); } verifyJavaVersion(); configureLogging(); // System properties System.setProperty("swing.aatext", "true"); // System.setProperty("sun.java2d.opengl", "true"); final SplashScreen splash = new SplashScreen(SPLASH_IMAGE, getVersion()); splash.showSplashScreen(); // Protocol handlers // cp:// is registered by the RPTURLStreamHandlerFactory constructor (why?) RPTURLStreamHandlerFactory factory = new RPTURLStreamHandlerFactory(); factory.registerProtocol("asset", new AssetURLStreamHandler()); URL.setURLStreamHandlerFactory(factory); final Toolkit tk = Toolkit.getDefaultToolkit(); tk.getSystemEventQueue().push(new MapToolEventQueue()); // LAF try { // If we are running under Mac OS X then save native menu bar look & feel components // Note the order of creation for the AppMenuBar, this specific chronology // allows the system to set up system defaults before we go and modify things. // That is, please don't move these lines around unless you test the result on windows and mac String lafname; if (MAC_OS_X) { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); menuBar = new AppMenuBar(); lafname = "net.rptools.maptool.client.TinyLookAndFeelMac"; UIManager.setLookAndFeel(lafname); macOSXicon(); } // If running on Windows based OS, CJK font is broken when using TinyLAF. // else if (WINDOWS) { // UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); // menuBar = new AppMenuBar(); // } else { lafname = "de.muntjak.tinylookandfeel.TinyLookAndFeel"; UIManager.setLookAndFeel(lafname); menuBar = new AppMenuBar(); } // After the TinyLAF library is initialized, look to see if there is a Default.theme // in our AppHome directory and load it if there is. Unfortunately, changing the // search path for the default theme requires subclassing TinyLAF and because // we have both the original and a Mac version that gets cumbersome. (Really // the Mac version should use the default and then install the keystroke differences // but what we have works and I'm loathe to go playing with it at 1.3b87 -- yes, 87!) File f = AppUtil.getAppHome("config"); if (f.exists()) { File f2 = new File(f, "Default.theme"); if (f2.exists()) { if (Theme.loadTheme(f2)) { // re-install the Tiny Look and Feel UIManager.setLookAndFeel(lafname); // Update the ComponentUIs for all Components. This // needs to be invoked for all windows. //SwingUtilities.updateComponentTreeUI(rootComponent); } } } com.jidesoft.utils.Lm.verifyLicense("Trevor Croft", "rptools", "5MfIVe:WXJBDrToeLWPhMv3kI2s3VFo"); LookAndFeelFactory.addUIDefaultsCustomizer(new LookAndFeelFactory.UIDefaultsCustomizer() { public void customize(UIDefaults defaults) { // Remove red border around menus defaults.put("PopupMenu.foreground", Color.lightGray); } }); LookAndFeelFactory.installJideExtension(LookAndFeelFactory.XERTO_STYLE); /**************************************************************************** * For TinyLAF 1.3.04 this is how the color was changed for a * button. */ // Theme.buttonPressedColor[Theme.style] = new ColorReference(Color.gray); /**************************************************************************** * And this is how it's done in TinyLAF 1.4.0 (no idea about the * intervening versions). */ Theme.buttonPressedColor = new SBReference(Color.GRAY, 0, -6, SBReference.SUB3_COLOR); configureJide(); } catch (Exception e) { MapTool.showError("msg.error.lafSetup", e); System.exit(1); } /** * This is a tweak that makes the Chinese version work better. * <p> * Consider reviewing <a * href="http://en.wikipedia.org/wiki/CJK_characters" * >http://en.wikipedia.org/wiki/CJK_characters</a> before making * changes. And http://www.scarfboy.com/coding/unicode-tool is also a * really cool site. */ if (Locale.CHINA.equals(Locale.getDefault())) { // The following font name appears to be "Sim Sun". It can be downloaded // from here: http://fr.cooltext.com/Fonts-Unicode-Chinese Font f = new Font("\u65B0\u5B8B\u4F53", Font.PLAIN, 12); FontUIResource fontRes = new FontUIResource(f); for (Enumeration<Object> keys = UIManager.getDefaults().keys(); keys.hasMoreElements();) { Object key = keys.nextElement(); Object value = UIManager.get(key); if (value instanceof FontUIResource) UIManager.put(key, fontRes); } } // Draw frame contents on resize tk.setDynamicLayout(true); EventQueue.invokeLater(new Runnable() { public void run() { initialize(); EventQueue.invokeLater(new Runnable() { public void run() { clientFrame.setVisible(true); splash.hideSplashScreen(); EventQueue.invokeLater(new Runnable() { public void run() { postInitialize(); } }); } }); } }); // new Thread(new HeapSpy()).start(); }
From source file:com.itemanalysis.jmetrik.gui.Jmetrik.java
public static void main(String args[]) { SwingUtilities.invokeLater(new Runnable() { public void run() { try { Color SELECTED_COLOR = new Color(184, 204, 217); Color BASE_COLOR = new Color(220, 231, 243, 50); Color ALT_COLOR = new Color(220, 231, 243, 115); // Insets MENU_INSETS = new Insets(1,12,2,5);//default values // Font MENU_FONT = new Font("SansSerif ", Font.PLAIN, 12);//default values // UIManager.put("nimbusBase", BASE_COLOR); UIManager.put("nimbusSelection", SELECTED_COLOR); UIManager.put("nimbusSelectionBackground", SELECTED_COLOR); UIManager.put("Menu[Enabled+Selected].backgroundPainter", SELECTED_COLOR); //override defaults for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if (info.getName().equals("Nimbus")) { UIManager.setLookAndFeel(info.getClassName()); UIDefaults defaults = UIManager.getLookAndFeelDefaults(); defaults.put("Table.gridColor", Color.lightGray); defaults.put("Table.disabled", false); defaults.put("Table.showGrid", true); defaults.put("Table.intercellSpacing", new Dimension(1, 1)); break; }//from w w w . j a v a2s. c o m } // UIManager.put("TitledBorder.position", TitledBorder.TOP); // UIManager.put("Table.showGrid", true); // UIManager.put("Table.gridColor", Color.RED); // UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel"); } catch (UnsupportedLookAndFeelException ulafe) { // logger.fatal("Substance failed to set", ulafe); } catch (Exception ex) { // logger.fatal(ex.getMessage(), ex); } JFrame frame = new Jmetrik(); // set window to maximum size but account for taskbar GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); Rectangle rect = env.getMaximumWindowBounds(); int width = Double.valueOf(rect.getWidth() - 1.0).intValue(); int height = Double.valueOf(rect.getHeight() - 1.0).intValue(); frame.setMaximizedBounds(new Rectangle(0, 0, width, height)); frame.setDefaultCloseOperation(DISPOSE_ON_CLOSE); frame.pack(); // frame.setExtendedState(JFrame.MAXIMIZED_BOTH); frame.setVisible(true); //check for updates to jmetrik ((Jmetrik) frame).checkForUpdates(); } }); }
From source file:UIUtilities.java
/** * Set up the user interface./* www .ja v a 2 s . com*/ */ public static void setupUI() { try { final String classname = UIManager.getSystemLookAndFeelClassName(); UIManager.setLookAndFeel(classname); } catch (Exception e) { e.printStackTrace(); } final UIDefaults defaults = UIManager.getDefaults(); defaults.put("PopupMenu.border", new BorderUIResource.EtchedBorderUIResource(EtchedBorder.RAISED, defaults.getColor("controlShadow"), defaults.getColor("controlLtHighlight"))); final MatteBorder matteborder = new MatteBorder(1, 1, 1, 1, Color.black); final EmptyBorder emptyborder = new MatteBorder(2, 2, 2, 2, defaults.getColor("control")); final BorderUIResource.CompoundBorderUIResource compBorder = new BorderUIResource.CompoundBorderUIResource( emptyborder, matteborder); final BorderUIResource.EmptyBorderUIResource emptyBorderUI = new BorderUIResource.EmptyBorderUIResource(0, 0, 0, 0); defaults.put("SplitPane.border", emptyBorderUI); defaults.put("Table.scrollPaneBorder", emptyBorderUI); defaults.put("ComboBox.border", compBorder); defaults.put("TextField.border", compBorder); defaults.put("TextArea.border", compBorder); defaults.put("CheckBox.border", compBorder); defaults.put("ScrollPane.border", emptyBorderUI); }
From source file:Main.java
public static void setLookAndFeel(int fontSize) throws Exception { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); UIDefaults defaults = UIManager.getDefaults(); Enumeration<Object> keys = defaults.keys(); while (keys.hasMoreElements()) { Object key = keys.nextElement(); if ((key instanceof String) && (((String) key).endsWith(".font"))) { FontUIResource font = (FontUIResource) UIManager.get(key); defaults.put(key, new FontUIResource(font.getFontName(), font.getStyle(), fontSize)); }// w w w. j a v a 2 s .c om } }
From source file:Main.java
/** * Code from http://stackoverflow.com/questions/1236231/managing-swing-ui-default-font-sizes-without-quaqua * @param fontSize//w ww .j a v a2 s . c o m */ public static void changeDefaultFontSize(int fontSize) { UIDefaults defaults = UIManager.getDefaults(); // UIDefaults defaults = UIManager.getLookAndFeelDefaults(); Enumeration<Object> keys = defaults.keys(); while (keys.hasMoreElements()) { Object key = keys.nextElement(); if ((key instanceof String) && (((String) key).endsWith(".font"))) { FontUIResource font = (FontUIResource) UIManager.get(key); defaults.put(key, new FontUIResource(font.getFontName(), font.getStyle(), fontSize)); } } }
From source file:Main.java
/** * magnify the all fonts in swing.// w w w .j av a2 s . c om * * @param mag * magnify parameter <br/> mag > 1. : large <br/> mag < 1. : * small */ public static void magnifyAllFont(float mag) { List history = new LinkedList(); UIDefaults defaults = UIManager.getDefaults(); Enumeration it = defaults.keys(); while (it.hasMoreElements()) { Object key = it.nextElement(); Object a = defaults.get(key); if (a instanceof Font) { if (history.contains(a)) continue; Font font = (Font) a; font = font.deriveFont(font.getSize2D() * mag); defaults.put(key, font); history.add(font); } } }
From source file:com.diversityarrays.kdxplore.KDXplore.java
private static void applyUIdefaultPreferences(KdxplorePreferences prefs) { UIDefaults uiDefaults = UIManager.getDefaults(); for (KdxPreference<?> pref : KdxPreference.getUiDefaultPreferences()) { Object value = prefs.getPreferenceValue(pref); if (value != null) { uiDefaults.put(pref.uiDefaultName, value); }//from w w w. j a v a2s .c om } }
From source file:Main.java
/** * Convenience method for retrieving a subset of the UIDefaults pertaining * to a particular class./*w w w. ja va2s .c o m*/ * * @param className fully qualified name of the class of interest * @return the UIDefaults of the class named */ public static UIDefaults getUIDefaultsOfClass(String className) { UIDefaults retVal = new UIDefaults(); UIDefaults defaults = UIManager.getLookAndFeelDefaults(); List<?> listKeys = Collections.list(defaults.keys()); for (Object key : listKeys) { if (key instanceof String && ((String) key).startsWith(className)) { String stringKey = (String) key; String property = stringKey; if (stringKey.contains(".")) { property = stringKey.substring(stringKey.indexOf(".") + 1); } retVal.put(property, defaults.get(key)); } } return retVal; }