Search in sources :

Example 1 with UnsupportedLookAndFeelException

use of javax.swing.UnsupportedLookAndFeelException in project jdk8u_jdk by JetBrains.

the class bug8033069NoScrollBar method iterateLookAndFeels.

protected static void iterateLookAndFeels(final bug8033069NoScrollBar test) throws Exception {
    LookAndFeelInfo[] lafInfo = UIManager.getInstalledLookAndFeels();
    for (LookAndFeelInfo info : lafInfo) {
        try {
            UIManager.setLookAndFeel(info.getClassName());
            System.out.println("Look and Feel: " + info.getClassName());
            test.runTest();
        } catch (UnsupportedLookAndFeelException e) {
            System.out.println("Skipping unsupported LaF: " + info);
        }
    }
}
Also used : LookAndFeelInfo(javax.swing.UIManager.LookAndFeelInfo) UnsupportedLookAndFeelException(javax.swing.UnsupportedLookAndFeelException)

Example 2 with UnsupportedLookAndFeelException

use of javax.swing.UnsupportedLookAndFeelException 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 3 with UnsupportedLookAndFeelException

use of javax.swing.UnsupportedLookAndFeelException in project jdk8u_jdk by JetBrains.

the class Metalworks method main.

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);
}
Also used : UnsupportedLookAndFeelException(javax.swing.UnsupportedLookAndFeelException) JFrame(javax.swing.JFrame) MetalLookAndFeel(javax.swing.plaf.metal.MetalLookAndFeel)

Example 4 with UnsupportedLookAndFeelException

use of javax.swing.UnsupportedLookAndFeelException in project JMRI by JMRI.

the class GuiLafPreferencesManager method applyLookAndFeel.

/**
     * Apply the existing look and feel.
     */
public void applyLookAndFeel() {
    String lafClassName = null;
    for (LookAndFeelInfo LAF : UIManager.getInstalledLookAndFeels()) {
        if (LAF.getName().equals(this.lookAndFeel)) {
            lafClassName = LAF.getClassName();
        }
    }
    log.debug("Look and feel selection \"{}\" ({})", this.lookAndFeel, lafClassName);
    if (lafClassName != null) {
        if (!lafClassName.equals(UIManager.getLookAndFeel().getClass().getName())) {
            log.debug("Apply look and feel \"{}\" ({})", this.lookAndFeel, lafClassName);
            try {
                UIManager.setLookAndFeel(lafClassName);
            } catch (ClassNotFoundException ex) {
                log.error("Could not find look and feel \"{}\".", this.lookAndFeel);
            } catch (IllegalAccessException | InstantiationException ex) {
                log.error("Could not load look and feel \"{}\".", this.lookAndFeel);
            } catch (UnsupportedLookAndFeelException ex) {
                log.error("Look and feel \"{}\" is not supported on this platform.", this.lookAndFeel);
            }
        } else {
            log.debug("Not updating look and feel {} matching existing look and feel" + lafClassName);
        }
    }
}
Also used : LookAndFeelInfo(javax.swing.UIManager.LookAndFeelInfo) UnsupportedLookAndFeelException(javax.swing.UnsupportedLookAndFeelException)

Example 5 with UnsupportedLookAndFeelException

use of javax.swing.UnsupportedLookAndFeelException in project jdk8u_jdk by JetBrains.

the class MenuItemIconTest method main.

public static void main(String[] args) throws Exception {
    robot = new Robot();
    String name = UIManager.getSystemLookAndFeelClassName();
    try {
        UIManager.setLookAndFeel(name);
    } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) {
        throw new RuntimeException("Test Failed");
    }
    createUI();
    robot.waitForIdle();
    executeTest();
    if (!"".equals(errorMessage)) {
        throw new RuntimeException(errorMessage);
    }
}
Also used : UnsupportedLookAndFeelException(javax.swing.UnsupportedLookAndFeelException) Robot(java.awt.Robot)

Aggregations

UnsupportedLookAndFeelException (javax.swing.UnsupportedLookAndFeelException)33 LookAndFeel (javax.swing.LookAndFeel)8 File (java.io.File)7 LookAndFeelInfo (javax.swing.UIManager.LookAndFeelInfo)6 Component (java.awt.Component)5 JFileChooser (javax.swing.JFileChooser)5 JFrame (javax.swing.JFrame)5 JDialog (javax.swing.JDialog)4 JPanel (javax.swing.JPanel)4 FileNameExtensionFilter (javax.swing.filechooser.FileNameExtensionFilter)4 JLabel (javax.swing.JLabel)3 BorderLayout (java.awt.BorderLayout)2 Color (java.awt.Color)2 Dimension (java.awt.Dimension)2 FlowLayout (java.awt.FlowLayout)2 Font (java.awt.Font)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 Preferences (java.util.prefs.Preferences)2