Search in sources :

Example 1 with NimbusLookAndFeel

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

the class bug8057791 method main.

public static void main(String[] args) {
    try {
        UIManager.setLookAndFeel(new NimbusLookAndFeel());
        SwingUtilities.invokeAndWait(new Runnable() {

            @Override
            public void run() {
                final int listWidth = 50;
                final int listHeight = 50;
                final int selCellIndex = 0;
                JList<String> list = new JList<String>();
                list.setSize(listWidth, listHeight);
                DefaultListModel<String> listModel = new DefaultListModel<String>();
                listModel.add(selCellIndex, "E");
                list.setModel(listModel);
                list.setSelectedIndex(selCellIndex);
                BufferedImage img = new BufferedImage(listWidth, listHeight, BufferedImage.TYPE_INT_ARGB);
                Graphics g = img.getGraphics();
                list.paint(g);
                g.dispose();
                Rectangle cellRect = list.getCellBounds(selCellIndex, selCellIndex);
                HashSet<Color> cellColors = new HashSet<Color>();
                int uniqueColorIndex = 0;
                for (int x = cellRect.x; x < (cellRect.x + cellRect.width); x++) {
                    for (int y = cellRect.y; y < (cellRect.y + cellRect.height); y++) {
                        Color cellColor = new Color(img.getRGB(x, y), true);
                        if (cellColors.add(cellColor)) {
                            System.err.println(String.format("Cell color #%d: %s", uniqueColorIndex++, cellColor));
                        }
                    }
                }
                Color selForegroundColor = list.getSelectionForeground();
                Color selBackgroundColor = list.getSelectionBackground();
                if (!cellColors.contains(new Color(selForegroundColor.getRGB(), true))) {
                    throw new RuntimeException(String.format("Selected cell is drawn without selection foreground color '%s'.", selForegroundColor));
                }
                if (!cellColors.contains(new Color(selBackgroundColor.getRGB(), true))) {
                    throw new RuntimeException(String.format("Selected cell is drawn without selection background color '%s'.", selBackgroundColor));
                }
            }
        });
    } catch (UnsupportedLookAndFeelException | InterruptedException | InvocationTargetException e) {
        throw new RuntimeException(e);
    }
}
Also used : Color(java.awt.Color) Rectangle(java.awt.Rectangle) DefaultListModel(javax.swing.DefaultListModel) BufferedImage(java.awt.image.BufferedImage) InvocationTargetException(java.lang.reflect.InvocationTargetException) Graphics(java.awt.Graphics) UnsupportedLookAndFeelException(javax.swing.UnsupportedLookAndFeelException) NimbusLookAndFeel(javax.swing.plaf.nimbus.NimbusLookAndFeel) JList(javax.swing.JList) HashSet(java.util.HashSet)

Example 2 with NimbusLookAndFeel

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

the class Test6933784 method main.

public static void main(String[] args) throws Exception {
    UIManager.setLookAndFeel(new SynthLookAndFeel());
    checkImages();
    UIManager.setLookAndFeel(new NimbusLookAndFeel());
    checkImages();
}
Also used : SynthLookAndFeel(javax.swing.plaf.synth.SynthLookAndFeel) NimbusLookAndFeel(javax.swing.plaf.nimbus.NimbusLookAndFeel)

Example 3 with NimbusLookAndFeel

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

the class Test6919629 method main.

public static void main(String[] args) throws Exception {
    UIManager.setLookAndFeel(new NimbusLookAndFeel());
    Test6919629 t = new Test6919629();
    t.test();
    System.gc();
    t.check();
}
Also used : NimbusLookAndFeel(javax.swing.plaf.nimbus.NimbusLookAndFeel)

Example 4 with NimbusLookAndFeel

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

the class Test7048204 method main.

public static void main(String[] args) throws Exception {
    UIManager.setLookAndFeel(new NimbusLookAndFeel());
    SwingUtilities.invokeAndWait(new Runnable() {

        public void run() {
            new JLabel();
            UIDefaults uid = UIManager.getDefaults();
            uid.putDefaults(new Object[0]);
            uid.put("what.ever", "else");
        }
    });
}
Also used : NimbusLookAndFeel(javax.swing.plaf.nimbus.NimbusLookAndFeel)

Example 5 with NimbusLookAndFeel

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

the class ThemeManager method getNimbusFontSize.

public static int getNimbusFontSize() {
    Preferences p = Preferences.userNodeForPackage(ThemeManager.class);
    int preferredSize = p.getInt(NIMBUS_FONT_SIZE, 0);
    // and save it
    if (preferredSize == 0) {
        LookAndFeel old = UIManager.getLookAndFeel();
        try {
            UIManager.setLookAndFeel(new NimbusLookAndFeel());
            preferredSize = NimbusUtils.getBaseFontSize();
            p.putInt(NIMBUS_FONT_SIZE, preferredSize);
            UIManager.setLookAndFeel(old);
        } catch (Exception e) {
            Logger.getLogger(ThemeManager.class.getName()).log(Level.SEVERE, e.toString(), e);
        }
    }
    return preferredSize;
}
Also used : NimbusLookAndFeel(javax.swing.plaf.nimbus.NimbusLookAndFeel) Preferences(java.util.prefs.Preferences) LookAndFeel(javax.swing.LookAndFeel) NimbusLookAndFeel(javax.swing.plaf.nimbus.NimbusLookAndFeel) SubstanceLookAndFeel(org.pushingpixels.substance.api.SubstanceLookAndFeel) MetalLookAndFeel(javax.swing.plaf.metal.MetalLookAndFeel) UnsupportedLookAndFeelException(javax.swing.UnsupportedLookAndFeelException)

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