public void testSinglePlatformInstall () throws IOException, UnsupportedLookAndFeelException { UIManager.setLookAndFeel(new MetalLookAndFeel()); InstallerRegistry regs = InstallerRegistryAccessor.prepareForUnitTest(new GeneralPlatformInstall[] { new FileBasedPlatformInstall ("FileBased1", Collections.<WizardDescriptor.Panel<WizardDescriptor>>singletonList( new Panel ("FileBased1_panel1") )) }); PlatformInstallIterator iterator = PlatformInstallIterator.create(); WizardDescriptor wd = new WizardDescriptor (iterator); iterator.initialize(wd); assertEquals("Invalid state", 1, iterator.getPanelIndex()); WizardDescriptor.Panel panel = iterator.current(); assertTrue ("Invalid panel",panel instanceof LocationChooser.Panel); ((JFileChooser)panel.getComponent()).setSelectedFile(this.getWorkDir()); //Select some folder assertTrue ("LocationChooser is not valid after folder was selected",panel.isValid()); assertTrue ("Should have next panel",iterator.hasNext()); assertFalse ("Should not have previous panel", iterator.hasPrevious()); iterator.nextPanel(); assertEquals("Invalid state", 2, iterator.getPanelIndex()); panel = iterator.current(); assertEquals("Invalid panel","FileBased1_panel1",panel.getComponent().getName()); assertFalse ("Should not have next panel",iterator.hasNext()); assertTrue ("Should have previous panel", iterator.hasPrevious()); }
/** Overridden to use CleanComboUI on Metal L&F to avoid extra borders */ @Override public void updateUI() { LookAndFeel lf = UIManager.getLookAndFeel(); String id = lf.getID(); boolean useClean = tableUI && (lf instanceof MetalLookAndFeel || "GTK".equals(id) //NOI18N || "Nimbus".equals(id) //NOI18N || ("Aqua".equals(id) && checkMacSystemVersion()) // NOI18N || PropUtils.isWindowsVistaLaF() //#217957 || "Kunststoff".equals(id)); //NOI18N if (useClean) { super.setUI(PropUtils.createComboUI(this, tableUI)); } else { super.updateUI(); } if (tableUI & getEditor().getEditorComponent() instanceof JComponent) { ((JComponent) getEditor().getEditorComponent()).setBorder(null); } }
private void installPerLFDefaults() { boolean isLFChange = curCustoms != null; curCustoms = findCustoms(); if (curCustoms != null) { Integer in = (Integer) UIManager.get(LFCustoms.CUSTOM_FONT_SIZE); //NOI18N if (in == null && UIManager.getLookAndFeel().getClass() == MetalLookAndFeel.class) { in = new Integer (11); } //#161761: Do not want to use font size param for GTK L&F because it causes mixed font size if ((in != null) && !UIUtils.isGtkLF()) { AllLFCustoms.initCustomFontSize (in.intValue()); } installLFCustoms (curCustoms); if (isLFChange) { //make sure UIBootstrapValue.Lazy instances really get a chance //to replace their values loadAllLazyValues (curCustoms); } curCustoms.disposeValues(); } }
private static boolean isOceanTheme() { if (!inSandbox) { try { java.lang.reflect.Field field = MetalLookAndFeel.class.getDeclaredField("currentTheme"); field.setAccessible(true); Object theme = field.get(null); return "javax.swing.plaf.metal.OceanTheme".equals(theme.getClass().getName()); } catch (Exception ex) { // We're in a sandbox and can't access the field inSandbox = true; } } if (!checkedForOcean) { checkedForOcean = true; checkForOcean(); } return usingOcean; }
public static void main(String[] args) { UIManager.put("swing.boldMetal", Boolean.FALSE); JDialog.setDefaultLookAndFeelDecorated(true); JFrame.setDefaultLookAndFeelDecorated(true); Toolkit.getDefaultToolkit().setDynamicLayout(true); System.setProperty("sun.awt.noerasebackground", "true"); try { UIManager.setLookAndFeel(new MetalLookAndFeel()); } catch (UnsupportedLookAndFeelException e) { System.out.println( "Metal Look & Feel not supported on this platform. \n" + "Program Terminated"); System.exit(0); } JFrame frame = new MetalworksFrame(); frame.setVisible(true); }
public static void main(String[] args) throws Exception { tempDir = System.getProperty("java.io.tmpdir"); if (tempDir.length() == 0) { //'java.io.tmpdir' isn't guaranteed to be defined tempDir = System.getProperty("user.home"); } System.out.println("Temp directory: " + tempDir); UIManager.setLookAndFeel(new MetalLookAndFeel()); SwingUtilities.invokeAndWait(new Runnable() { public void run() { HackedFileChooser openChooser = new HackedFileChooser(); openChooser.setUI(new MetalFileChooserUI(openChooser)); openChooser.setCurrentDirectory(new File(tempDir)); } }); }
void test() { try { UIManager.setLookAndFeel(new MetalLookAndFeel()); } catch (UnsupportedLookAndFeelException e) { throw new Error("Cannot set Metal LAF"); } // Render text using background color UIManager.put("textInactiveText", TEST_COLOR); test(new JLabel(html)); test(new JButton(html)); JEditorPane pane = new JEditorPane("text/html", html); pane.setDisabledTextColor(TEST_COLOR); test(pane); }
public static void main(String[] args) throws Exception { try { UIManager.setLookAndFeel(new MetalLookAndFeel()); SwingUtilities.invokeAndWait(bug7170310::createAndShowUI); SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); toolkit.realSync(); for (int i = 0; i < TABS_NUMBER; i++) { SwingUtilities.invokeAndWait(bug7170310::addTab); toolkit.realSync(); } SwingUtilities.invokeAndWait(bug7170310::check); if (exception != null) { System.out.println("Test failed: " + exception.getMessage()); throw exception; } else { System.out.printf("Test passed"); } } finally { frame.dispose(); } }
public static void main(String[] args) { UIDefaults table= new MetalLookAndFeel().getDefaults(); test(table.get("ToolBar.rolloverBorder"), "javax.swing.plaf.metal.MetalBorders$ButtonBorder", "javax.swing.plaf.metal.MetalBorders$RolloverMarginBorder"); test(table.get("ToolBar.nonrolloverBorder"), "javax.swing.plaf.metal.MetalBorders$ButtonBorder", "javax.swing.plaf.metal.MetalBorders$RolloverMarginBorder"); test(table.get("RootPane.frameBorder"), "javax.swing.plaf.metal.MetalBorders$FrameBorder"); test(table.get("RootPane.plainDialogBorder"), "javax.swing.plaf.metal.MetalBorders$DialogBorder"); test(table.get("RootPane.informationDialogBorder"), "javax.swing.plaf.metal.MetalBorders$DialogBorder"); test(table.get("RootPane.errorDialogBorder"), "javax.swing.plaf.metal.MetalBorders$ErrorDialogBorder"); test(table.get("RootPane.colorChooserDialogBorder"), "javax.swing.plaf.metal.MetalBorders$QuestionDialogBorder"); test(table.get("RootPane.fileChooserDialogBorder"), "javax.swing.plaf.metal.MetalBorders$QuestionDialogBorder"); test(table.get("RootPane.questionDialogBorder"), "javax.swing.plaf.metal.MetalBorders$QuestionDialogBorder"); test(table.get("RootPane.warningDialogBorder"), "javax.swing.plaf.metal.MetalBorders$WarningDialogBorder"); }
public static void main(String[] args) throws Exception { try { UIManager.setLookAndFeel(new MetalLookAndFeel()); SwingUtilities.invokeAndWait(bug7170310::createAndShowUI); sync(); for (int i = 0; i < TABS_NUMBER; i++) { SwingUtilities.invokeAndWait(bug7170310::addTab); sync(); } SwingUtilities.invokeAndWait(bug7170310::check); if (exception != null) { System.out.println("Test failed: " + exception.getMessage()); throw exception; } else { System.out.printf("Test passed"); } } finally { if (frame != null) { frame.dispose(); } } }
public static void main(String[] args) throws Exception { SwingUtilities.invokeAndWait(() -> { try { UIManager.setLookAndFeel(new MetalLookAndFeel()); } catch (Exception e) { throw new RuntimeException(e); } if (!testSliderThumb(true)) { throw new RuntimeException("Horizontal Slider Thumb is not scaled!"); } if (!testSliderThumb(false)) { throw new RuntimeException("Vertical Slider Thumb is not scaled!"); } }); }
private static void createAndShowGUI() { try { UIManager.setLookAndFeel(new MetalLookAndFeel()); } catch (Exception e) { throw new RuntimeException(e); } frame = new JFrame(); frame.setSize(300, 300); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel panel = new JPanel(new BorderLayout()); button = new JButton(""); panel.add(button); frame.getContentPane().add(panel); frame.setVisible(true); }
public static void main(String[] args) throws Exception { try { UIManager.setLookAndFeel(new MetalLookAndFeel()); SwingUtilities.invokeAndWait(bug7170310::createAndShowUI); sync(); for (int i = 0; i < TABS_NUMBER; i++) { SwingUtilities.invokeAndWait(bug7170310::addTab); sync(); } SwingUtilities.invokeAndWait(bug7170310::check); if (exception != null) { System.out.println("Test failed: " + exception.getMessage()); throw exception; } else { System.out.printf("Test passed"); } } finally { frame.dispose(); } }
/** * Based on the current look and feel (as returned by * <code>UIManager.getLookAndFeel()</code>), this method returns * the name of the closest <code>LookAndFeelAddons</code> to use. * * @return the addon matching the currently installed look and feel */ public static String getBestMatchAddonClassName() { String lnf = UIManager.getLookAndFeel().getClass().getName(); String addon; if (UIManager.getCrossPlatformLookAndFeelClassName().equals(lnf)) { addon = MetalLookAndFeelAddons.class.getName(); } else if (UIManager.getSystemLookAndFeelClassName().equals(lnf)) { addon = getSystemAddonClassName(); } else if ("com.sun.java.swing.plaf.windows.WindowsLookAndFeel".equals(lnf) || "com.jgoodies.looks.windows.WindowsLookAndFeel".equals(lnf)) { if (OS.isUsingWindowsVisualStyles()) { addon = WindowsLookAndFeelAddons.class.getName(); } else { addon = WindowsClassicLookAndFeelAddons.class.getName(); } } else if ("com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel" .equals(lnf)) { addon = WindowsClassicLookAndFeelAddons.class.getName(); } else if (UIManager.getLookAndFeel() instanceof MetalLookAndFeel) { // for JGoodies and other sub-l&fs of Metal addon = MetalLookAndFeelAddons.class.getName(); } else { addon = getSystemAddonClassName(); } return addon; }
/** * 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); }
/** * Changes the theme to the one specified in the constructor. * * @param event the action event that triggered this action */ public void actionPerformed(ActionEvent event) { MetalLookAndFeel.setCurrentTheme(theme); try { // Only switch theme if we have a metal L&F. It is still necessary // to install a new MetalLookAndFeel instance. if (UIManager.getLookAndFeel() instanceof MetalLookAndFeel) UIManager.setLookAndFeel(new MetalLookAndFeel()); } catch (UnsupportedLookAndFeelException ex) { ex.printStackTrace(); } SwingUtilities.updateComponentTreeUI(frame); }
/** Look up the named theme, and apply it to the frame */ public void setTheme(String themeName) { // Look up the theme in the resource bundle Theme theme = new Theme(resources, themeName); // Make it the current theme MetalLookAndFeel.setCurrentTheme(theme); // Re-apply the Metal look-and-feel to install new theme try { UIManager.setLookAndFeel(new MetalLookAndFeel()); } catch(UnsupportedLookAndFeelException e) {} // Propagate the new l&f across the entire component tree of the frame SwingUtilities.updateComponentTreeUI(frame); //ZEPH ADD-ON: //Change also the font of the viewed page: if (frame instanceof WebBrowser){ WebBrowser wbf = (WebBrowser)frame; wbf.textPane.setFont(theme.systemFont); wbf.textPane.updateUI(); } }
protected void createButtons() { super.createButtons(); Boolean paintActive = frame.isSelected() ? Boolean.TRUE : Boolean.FALSE; iconButton.putClientProperty("paintActive", paintActive); iconButton.setBorder(handyEmptyBorder); maxButton.putClientProperty("paintActive", paintActive); maxButton.setBorder(handyEmptyBorder); closeButton.putClientProperty("paintActive", paintActive); closeButton.setBorder(handyEmptyBorder); // The palette close icon isn't opaque while the regular close icon is. // This makes sure palette close buttons have the right background. closeButton.setBackground(MetalLookAndFeel.getPrimaryControlShadow()); if (true) { iconButton.setContentAreaFilled(false); maxButton.setContentAreaFilled(false); closeButton.setContentAreaFilled(false); } }
private void paintNorthBorder(Graphics g, boolean isEnabled, int w, int h, boolean paintBottom) /* 89: */ { /* 90:128 */ if (isEnabled) /* 91: */ { /* 92:129 */ boolean isPressed = (this.model.isPressed()) && (this.model.isArmed()); /* 93:130 */ if (isPressed) { /* 94:131 */ PlasticXPUtils.drawPressedButtonBorder(g, 0, 1, w - 2, h); /* 95: */ } else { /* 96:133 */ PlasticXPUtils.drawPlainButtonBorder(g, 0, 1, w - 2, h); /* 97: */ } /* 98: */ } /* 99: */ else /* 100: */ { /* 101:136 */ PlasticXPUtils.drawDisabledButtonBorder(g, 0, 1, w - 2, h + 1); /* 102: */ } /* 103:139 */ g.setColor(isEnabled ? PlasticLookAndFeel.getControlDarkShadow() : MetalLookAndFeel.getControlShadow()); /* 104: */ /* 105: */ /* 106:142 */ g.fillRect(0, 1, 1, 1); /* 107:144 */ if (paintBottom) { /* 108:145 */ g.fillRect(0, h - 1, w - 1, 1); /* 109: */ } /* 110: */ }
private void paintSouthBorder(Graphics g, boolean isEnabled, int w, int h) /* 151: */ { /* 152:191 */ if (isEnabled) /* 153: */ { /* 154:192 */ boolean isPressed = (this.model.isPressed()) && (this.model.isArmed()); /* 155:193 */ if (isPressed) { /* 156:194 */ PlasticXPUtils.drawPressedButtonBorder(g, 0, -2, w - 2, h + 1); /* 157: */ } else { /* 158:196 */ PlasticXPUtils.drawPlainButtonBorder(g, 0, -2, w - 2, h + 1); /* 159: */ } /* 160: */ } /* 161: */ else /* 162: */ { /* 163:199 */ PlasticXPUtils.drawDisabledButtonBorder(g, 0, -2, w - 2, h + 1); /* 164: */ } /* 165:202 */ g.setColor(isEnabled ? PlasticLookAndFeel.getControlDarkShadow() : MetalLookAndFeel.getControlShadow()); /* 166: */ /* 167: */ /* 168:205 */ g.fillRect(0, h - 2, 1, 1); /* 169: */ }