Search in sources :

Example 6 with NimbusLookAndFeel

use of javax.swing.plaf.nimbus.NimbusLookAndFeel in project jgnash by ccavanaugh.

the class ThemeManager method setLookAndFeel.

private static void setLookAndFeel(final String lookAndFeel) {
    Preferences pref = Preferences.userNodeForPackage(ThemeManager.class);
    String theme = pref.get(THEME, DEFAULT_THEME);
    try {
        Class<?> lafClass = Class.forName(lookAndFeel);
        Object lafInstance = lafClass.newInstance();
        if (lafInstance instanceof SubstanceSkin) {
            UIManager.put(SubstanceLookAndFeel.SHOW_EXTRA_WIDGETS, Boolean.TRUE);
            if (isSubstanceAnimationsEnabled()) {
                AnimationConfigurationManager.getInstance().setTimelineDuration(animationDuration);
            } else {
                AnimationConfigurationManager.getInstance().setTimelineDuration(0);
            }
            SubstanceLookAndFeel.setSkin(lookAndFeel);
        } else if (lafInstance instanceof NimbusLookAndFeel) {
            UIManager.setLookAndFeel((LookAndFeel) lafInstance);
            NimbusUtils.changeFontSize(getNimbusFontSize());
        } else if (lafInstance instanceof MetalLookAndFeel) {
            UIManager.setLookAndFeel((LookAndFeel) lafInstance);
            setTheme(theme);
        } else if (lafInstance instanceof LookAndFeel) {
            UIManager.setLookAndFeel((LookAndFeel) lafInstance);
        }
    } catch (final ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) {
        Logger.getLogger(ThemeManager.class.getName()).log(Level.WARNING, null, e);
    }
}
Also used : LookAndFeel(javax.swing.LookAndFeel) NimbusLookAndFeel(javax.swing.plaf.nimbus.NimbusLookAndFeel) SubstanceLookAndFeel(org.pushingpixels.substance.api.SubstanceLookAndFeel) MetalLookAndFeel(javax.swing.plaf.metal.MetalLookAndFeel) MetalLookAndFeel(javax.swing.plaf.metal.MetalLookAndFeel) SubstanceSkin(org.pushingpixels.substance.api.SubstanceSkin) UnsupportedLookAndFeelException(javax.swing.UnsupportedLookAndFeelException) NimbusLookAndFeel(javax.swing.plaf.nimbus.NimbusLookAndFeel) Preferences(java.util.prefs.Preferences)

Example 7 with NimbusLookAndFeel

use of javax.swing.plaf.nimbus.NimbusLookAndFeel in project jdk8u_jdk by JetBrains.

the class Bug8154069 method main.

public static void main(String[] args) throws Exception {
    try {
        try {
            UIManager.setLookAndFeel(new NimbusLookAndFeel());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        SwingUtilities.invokeAndWait(() -> {
            frame = new JFrame();
            String[] petStrings = { "Bird", "Cat" };
            JComboBox<String> cb = new JComboBox<>(petStrings);
            // select Cat
            cb.setSelectedIndex(1);
            frame.add(cb);
            frame.pack();
            try {
                cb.setSelectedIndex(-1);
                int i = cb.getSelectedIndex();
                if (i != -1) {
                    throw new RuntimeException("getSelectedIndex is not -1");
                }
                Object o = cb.getSelectedItem();
                if (o != null) {
                    throw new RuntimeException("getSelectedItem is not null");
                }
                AccessibleContext ac = cb.getAccessibleContext();
                AccessibleSelection as = ac.getAccessibleSelection();
                int count = as.getAccessibleSelectionCount();
                if (count != 0) {
                    throw new RuntimeException("getAccessibleSelection count is not 0");
                }
                Accessible a = as.getAccessibleSelection(0);
                if (a != null) {
                    throw new RuntimeException("getAccessibleSelection(0) is not null");
                }
            } catch (Exception e) {
                exception = e;
            }
        });
        if (exception != null) {
            System.out.println("Test failed: " + exception.getMessage());
            throw exception;
        } else {
            System.out.println("Test passed.");
        }
    } finally {
        SwingUtilities.invokeAndWait(() -> {
            frame.dispose();
        });
    }
}
Also used : JComboBox(javax.swing.JComboBox) AccessibleContext(javax.accessibility.AccessibleContext) AccessibleSelection(javax.accessibility.AccessibleSelection) JFrame(javax.swing.JFrame) NimbusLookAndFeel(javax.swing.plaf.nimbus.NimbusLookAndFeel) Accessible(javax.accessibility.Accessible)

Example 8 with NimbusLookAndFeel

use of javax.swing.plaf.nimbus.NimbusLookAndFeel in project jdk8u_jdk by JetBrains.

the class Test6827032 method main.

public static void main(String[] args) throws Exception {
    UIManager.setLookAndFeel(new NimbusLookAndFeel());
    Robot robot = new Robot();
    robot.setAutoDelay(50);
    SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
    SwingUtilities.invokeAndWait(new Runnable() {

        public void run() {
            createAndShowGUI();
        }
    });
    toolkit.realSync();
    SwingUtilities.invokeAndWait(new Runnable() {

        public void run() {
            Component previewPanel = Util.findSubComponent(cc, "javax.swing.colorchooser.DefaultPreviewPanel");
            point = previewPanel.getLocationOnScreen();
        }
    });
    point.translate(5, 5);
    robot.mouseMove(point.x, point.y);
    robot.mousePress(InputEvent.BUTTON1_MASK);
    robot.mouseRelease(InputEvent.BUTTON1_MASK);
}
Also used : SunToolkit(sun.awt.SunToolkit) NimbusLookAndFeel(javax.swing.plaf.nimbus.NimbusLookAndFeel)

Example 9 with NimbusLookAndFeel

use of javax.swing.plaf.nimbus.NimbusLookAndFeel in project jdk8u_jdk by JetBrains.

the class ColorCustomizationTest method main.

public static void main(String[] args) throws Exception {
    nimbus = new NimbusLookAndFeel();
    try {
        UIManager.setLookAndFeel(nimbus);
    } catch (UnsupportedLookAndFeelException e) {
        throw new Error("Unable to set Nimbus LAF");
    }
    SwingUtilities.invokeAndWait(new Runnable() {

        @Override
        public void run() {
            new ColorCustomizationTest().test();
        }
    });
}
Also used : UnsupportedLookAndFeelException(javax.swing.UnsupportedLookAndFeelException) NimbusLookAndFeel(javax.swing.plaf.nimbus.NimbusLookAndFeel)

Aggregations

NimbusLookAndFeel (javax.swing.plaf.nimbus.NimbusLookAndFeel)9 UnsupportedLookAndFeelException (javax.swing.UnsupportedLookAndFeelException)4 Preferences (java.util.prefs.Preferences)2 LookAndFeel (javax.swing.LookAndFeel)2 MetalLookAndFeel (javax.swing.plaf.metal.MetalLookAndFeel)2 SubstanceLookAndFeel (org.pushingpixels.substance.api.SubstanceLookAndFeel)2 Color (java.awt.Color)1 Graphics (java.awt.Graphics)1 Rectangle (java.awt.Rectangle)1 BufferedImage (java.awt.image.BufferedImage)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 HashSet (java.util.HashSet)1 Accessible (javax.accessibility.Accessible)1 AccessibleContext (javax.accessibility.AccessibleContext)1 AccessibleSelection (javax.accessibility.AccessibleSelection)1 DefaultListModel (javax.swing.DefaultListModel)1 JComboBox (javax.swing.JComboBox)1 JFrame (javax.swing.JFrame)1 JList (javax.swing.JList)1 SynthLookAndFeel (javax.swing.plaf.synth.SynthLookAndFeel)1