/** * Statyczna metoda ustawiająca temat(Ocean) LookAndFeel */ public static void setLookAndFeel() { MetalLookAndFeel.setCurrentTheme(new OceanTheme()); try { UIManager.setLookAndFeel(new MetalLookAndFeel()); } catch(Exception e) { System.err.println(e); } JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); }
@Override protected void addMetalDefaults(LookAndFeelAddons addon, DefaultsList defaults) { super.addMetalDefaults(addon, defaults); if (MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme) { defaults.add(JXTaskPane.uiClassID, "org.jdesktop.swingx.plaf.misc.GlossyTaskPaneUI"); } else { defaults.add(JXTaskPane.uiClassID, "org.jdesktop.swingx.plaf.metal.MetalTaskPaneUI"); } //TODO use safe methods defaults.add("TaskPane.foreground", UIManager.getColor("activeCaptionText")); defaults.add("TaskPane.background", MetalLookAndFeel.getControl()); defaults.add("TaskPane.specialTitleBackground", MetalLookAndFeel.getPrimaryControl()); defaults.add("TaskPane.titleBackgroundGradientStart", MetalLookAndFeel.getPrimaryControl()); defaults.add("TaskPane.titleBackgroundGradientEnd", MetalLookAndFeel.getPrimaryControlHighlight()); defaults.add("TaskPane.titleForeground", MetalLookAndFeel.getControlTextColor()); defaults.add("TaskPane.specialTitleForeground", MetalLookAndFeel.getControlTextColor()); defaults.add("TaskPane.borderColor", MetalLookAndFeel.getPrimaryControl()); defaults.add("TaskPane.titleOver", new ColorUIResource(MetalLookAndFeel.getControl().darker())); defaults.add("TaskPane.specialTitleOver", MetalLookAndFeel.getPrimaryControlHighlight()); }
public void updateLookAndFeel(String canonicalName) { SwingUtilities.invokeLater(() -> { try { if(canonicalName.equalsIgnoreCase(MetalLookAndFeel.class.getCanonicalName())) MetalLookAndFeel.setCurrentTheme(new OceanTheme()); UIManager.setLookAndFeel(canonicalName); SwingUtilities.updateComponentTreeUI(frame); } catch (ClassNotFoundException | InstantiationException | UnsupportedLookAndFeelException | IllegalAccessException e) { e.printStackTrace(); } }); }
/** * {@inheritDoc} */ @Override protected void addMetalDefaults(LookAndFeelAddons addon, DefaultsList defaults) { super.addMetalDefaults(addon, defaults); if (MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme) { defaults.add("UIColorHighlighter.stripingBackground", new ColorUIResource(230, 238, 246)); } else { defaults.add("UIColorHighlighter.stripingBackground", new ColorUIResource(235, 235, 255)); } }
protected void buildMenus() { menuBar = new JMenuBar(); menuBar.setOpaque(true); JMenu file = buildFileMenu(); JMenu edit = buildEditMenu(); JMenu views = buildViewsMenu(); JMenu speed = buildSpeedMenu(); JMenu help = buildHelpMenu(); // load a theme from a text file MetalTheme myTheme = null; try { InputStream istream = getClass().getResourceAsStream( "/resources/MyTheme.theme"); myTheme = new PropertiesMetalTheme(istream); } catch (NullPointerException e) { System.out.println(e); } // build an array of themes MetalTheme[] themes = { new OceanTheme(), new DefaultMetalTheme(), new GreenMetalTheme(), new AquaMetalTheme(), new KhakiMetalTheme(), new DemoMetalTheme(), new ContrastMetalTheme(), new BigContrastMetalTheme(), myTheme }; // put the themes in a menu JMenu themeMenu = new MetalThemeMenu("Theme", themes); menuBar.add(file); menuBar.add(edit); menuBar.add(views); menuBar.add(themeMenu); menuBar.add(speed); menuBar.add(help); setJMenuBar(menuBar); }
/** * Go through all existing LookAndFeelAddons. This leads all registered * {@link org.jdesktop.swingx.plaf.ComponentAddon} to initialize/uninitialize * themselves. */ public static void cycleAddons(JComponent component) throws Exception { LookAndFeelAddons.setAddon(MacOSXLookAndFeelAddons.class.getName()); component.updateUI(); MetalTheme oldTheme = MetalLookAndFeel.getCurrentTheme(); try { MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme()); LookAndFeelAddons.setAddon(MetalLookAndFeelAddons.class.getName()); component.updateUI(); MetalLookAndFeel.setCurrentTheme(new OceanTheme()); LookAndFeelAddons.setAddon(MetalLookAndFeelAddons.class.getName()); component.updateUI(); } finally { MetalLookAndFeel.setCurrentTheme(oldTheme); } LookAndFeelAddons.setAddon(MotifLookAndFeelAddons.class.getName()); component.updateUI(); LookAndFeelAddons.setAddon(WindowsLookAndFeelAddons.class.getName()); component.updateUI(); String property = UIManager.getString("win.xpstyle.name"); try { UIManager.put("win.xpstyle.name", WindowsLookAndFeelAddons.HOMESTEAD_VISUAL_STYLE); LookAndFeelAddons.setAddon(WindowsClassicLookAndFeelAddons.class .getName()); component.updateUI(); UIManager.put("win.xpstyle.name", WindowsLookAndFeelAddons.SILVER_VISUAL_STYLE); LookAndFeelAddons.setAddon(WindowsClassicLookAndFeelAddons.class .getName()); component.updateUI(); UIManager.put("win.xpstyle.name", null); LookAndFeelAddons.setAddon(WindowsClassicLookAndFeelAddons.class .getName()); component.updateUI(); } finally { UIManager.put("win.xpstyle.name", property); } }