Search in sources :

Example 31 with LookAndFeelInfo

use of javax.swing.UIManager.LookAndFeelInfo in project jdk8u_jdk by JetBrains.

the class bug8002077 method main.

public static void main(String[] args) throws Exception {
    for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
        if ("Nimbus".equals(info.getName())) {
            UIManager.setLookAndFeel(info.getClassName());
            UIManager.put("FileChooser.openButtonMnemonic", KeyEvent.VK_O);
            UIManager.put("FileChooser.saveButtonMnemonic", KeyEvent.VK_S);
            runTest();
            break;
        }
    }
}
Also used : LookAndFeelInfo(javax.swing.UIManager.LookAndFeelInfo)

Example 32 with LookAndFeelInfo

use of javax.swing.UIManager.LookAndFeelInfo in project jdk8u_jdk by JetBrains.

the class Test7163696 method test.

private void test() throws Exception {
    Robot robot = new Robot();
    SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
    for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
        UIManager.setLookAndFeel(info.getClassName());
        SwingUtilities.invokeAndWait(this);
        // after creation
        toolkit.realSync();
        Thread.sleep(1000);
        Point point = this.bar.getLocation();
        SwingUtilities.convertPointToScreen(point, this.bar);
        point.x += this.bar.getWidth() >> 2;
        point.y += this.bar.getHeight() >> 1;
        robot.mouseMove(point.x, point.y);
        robot.mousePress(InputEvent.BUTTON1_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_MASK);
        // before validation
        toolkit.realSync();
        Thread.sleep(1000);
        SwingUtilities.invokeAndWait(this);
        if (this.bar != null) {
            // allows to reuse the instance
            this.bar = null;
            if (AUTO) {
                // error reporting only for automatic testing
                throw new Error("TEST FAILED");
            }
        }
    }
}
Also used : LookAndFeelInfo(javax.swing.UIManager.LookAndFeelInfo) SunToolkit(sun.awt.SunToolkit) Point(java.awt.Point) Robot(java.awt.Robot)

Example 33 with LookAndFeelInfo

use of javax.swing.UIManager.LookAndFeelInfo in project freeplane by freeplane.

the class FrameController method setLookAndFeel.

public static void setLookAndFeel(final String lookAndFeel, boolean supportHidpi) {
    try {
        if (lookAndFeel.equals("default")) {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } else {
            LookAndFeelInfo[] lafInfos = UIManager.getInstalledLookAndFeels();
            boolean setLnF = false;
            for (LookAndFeelInfo lafInfo : lafInfos) {
                if (lafInfo.getName().equalsIgnoreCase(lookAndFeel)) {
                    UIManager.setLookAndFeel(lafInfo.getClassName());
                    setLnF = true;
                    break;
                }
            }
            if (!setLnF) {
                final URLClassLoader userLibClassLoader = ClassLoaderFactory.getClassLoaderForUserLib();
                try {
                    final Class<?> lookAndFeelClass = userLibClassLoader.loadClass(lookAndFeel);
                    UIManager.setLookAndFeel((LookAndFeel) lookAndFeelClass.newInstance());
                    final ClassLoader uiClassLoader = lookAndFeelClass.getClassLoader();
                    if (userLibClassLoader != uiClassLoader)
                        userLibClassLoader.close();
                    UIManager.getDefaults().put("ClassLoader", uiClassLoader);
                } catch (ClassNotFoundException | ClassCastException | InstantiationException e) {
                    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                    Controller.getCurrentController().getResourceController().setProperty("lookandfeel", "default");
                }
            }
        }
    } catch (final Exception ex) {
        LogUtils.warn("Error while setting Look&Feel" + lookAndFeel);
    }
    UIManager.put("Button.defaultButtonFollowsFocus", Boolean.TRUE);
    final ResourceController resourceController = ResourceController.getResourceController();
    if (!resourceController.getBooleanProperty("hugeFontsFixed", false)) {
        if ("100".equals(resourceController.getProperties().get(UITools.MENU_ITEM_FONT_SIZE_PROPERTY))) {
            resourceController.getProperties().remove(UITools.MENU_ITEM_FONT_SIZE_PROPERTY);
        }
        resourceController.setProperty("hugeFontsFixed", true);
    }
    int lookAndFeelDefaultMenuItemFontSize = getLookAndFeelDefaultMenuItemFontSize();
    final long defaultMenuItemSize = Math.round(lookAndFeelDefaultMenuItemFontSize * DEFAULT_SCALING_FACTOR);
    resourceController.setDefaultProperty(UITools.MENU_ITEM_FONT_SIZE_PROPERTY, Long.toString(defaultMenuItemSize));
    if (supportHidpi) {
        double scalingFactor = calculateFontSizeScalingFactor(lookAndFeelDefaultMenuItemFontSize);
        scaleDefaultUIFonts(scalingFactor);
    }
    // Workaround for https://bugs.openjdk.java.net/browse/JDK-8134828
    // Scrollbar thumb disappears with Nimbus L&F
    // http://stackoverflow.com/questions/32857372/jscrollbar-dont-show-thumb-in-nimbus-lf
    final Dimension minimumThumbSize = new Dimension(30, 30);
    UIManager.getLookAndFeelDefaults().put("ScrollBar.minimumThumbSize", minimumThumbSize);
    UIManager.put("ScrollBar.minimumThumbSize", minimumThumbSize);
    // set FileChooserUI to MetalFileChooserUI if no JFileChooser can be created
    try {
        new JFileChooser();
    } catch (Throwable t) {
        try {
            UIManager.getLookAndFeelDefaults().put("FileChooserUI", MetalFileChooserUI.class.getName());
        } catch (Throwable t1) {
        }
    }
    // Workaround for https://bugs.openjdk.java.net/browse/JDK-8179014
    UIManager.put("FileChooser.useSystemExtensionHiding", false);
    final Color color = UIManager.getColor("control");
    if (color != null && color.getAlpha() < 255)
        UIManager.getDefaults().put("control", Color.LIGHT_GRAY);
}
Also used : LookAndFeelInfo(javax.swing.UIManager.LookAndFeelInfo) Color(java.awt.Color) Dimension(java.awt.Dimension) InvocationTargetException(java.lang.reflect.InvocationTargetException) IOException(java.io.IOException) JFileChooser(javax.swing.JFileChooser) ResourceController(org.freeplane.core.resources.ResourceController) URLClassLoader(java.net.URLClassLoader) URLClassLoader(java.net.URLClassLoader)

Example 34 with LookAndFeelInfo

use of javax.swing.UIManager.LookAndFeelInfo in project sirix by sirixdb.

the class GUI method createAndShowGUI.

/**
 * Create the GUI and show it. For thread safety, this method should be
 * invoked from the event dispatch thread.
 */
private static void createAndShowGUI() {
    ExceptionReporting.registerExceptionReporter();
    // Added to handle possible JDK 1.6 bug (thanks to Makoto Yui and the BaseX
    // guys).
    UIManager.getInstalledLookAndFeels();
    // Refresh views when windows are resized (thanks to the BaseX guys).
    Toolkit.getDefaultToolkit().setDynamicLayout(true);
    if (mUseSystemLookAndFeel) {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (final ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) {
            LOGWRAPPER.error(e.getMessage(), e);
        }
    } else {
        try {
            for (final LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (final Exception e) {
            // feel.
            try {
                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException exc) {
                LOGWRAPPER.error(exc.getMessage(), exc);
            }
        }
    }
    // Create GUI.
    new GUI(new GUIProp());
}
Also used : UnsupportedLookAndFeelException(javax.swing.UnsupportedLookAndFeelException) LookAndFeelInfo(javax.swing.UIManager.LookAndFeelInfo) UnsupportedLookAndFeelException(javax.swing.UnsupportedLookAndFeelException) SirixException(org.sirix.exception.SirixException)

Example 35 with LookAndFeelInfo

use of javax.swing.UIManager.LookAndFeelInfo in project CCDD by nasa.

the class CcddMain method setLookAndFeel.

/**
 ********************************************************************************************
 * Set the application's look & feel
 *
 * @param laf
 *            name of the selected look & feel; null to use the look & feel stored in the
 *            program preferences
 *
 * @return true if an error occurred loading the look & feel
 ********************************************************************************************
 */
protected boolean setLookAndFeel(String laf) {
    boolean isLaFError = false;
    // Set the default to the cross-platform look & feel
    selectedLaF = "Metal";
    String lafClass = UIManager.getCrossPlatformLookAndFeelClassName();
    // Check if the look & feel was not provided
    if (laf == null) {
        // Get the look & feel from the program preferences backing store
        laf = progPrefs.get(LOOK_AND_FEEL, selectedLaF);
    }
    // Step through the look & feels available
    for (LookAndFeelInfo lafInfo : UIManager.getInstalledLookAndFeels()) {
        // Check if the desired look & feel matches one of the available ones
        if (laf.equals(lafInfo.getName())) {
            // Store the selected look & feel
            selectedLaF = laf;
            lafClass = lafInfo.getClassName();
            break;
        }
    }
    try {
        // Set the selected look & feel of the GUI
        UIManager.setLookAndFeel(lafClass);
        // Save the selected L&F in the program preferences backing store
        progPrefs.put(LOOK_AND_FEEL, selectedLaF);
        // Set the adjustments to the selected look & feel
        setLaFAdjustments(selectedLaF);
    }// Look & feel failed to load
     catch (Exception e) {
        isLaFError = true;
    }
    return isLaFError;
}
Also used : LookAndFeelInfo(javax.swing.UIManager.LookAndFeelInfo) BackingStoreException(java.util.prefs.BackingStoreException) SQLException(java.sql.SQLException)

Aggregations

LookAndFeelInfo (javax.swing.UIManager.LookAndFeelInfo)41 IOException (java.io.IOException)7 JPanel (javax.swing.JPanel)6 UnsupportedLookAndFeelException (javax.swing.UnsupportedLookAndFeelException)6 Dimension (java.awt.Dimension)5 JFrame (javax.swing.JFrame)5 JLabel (javax.swing.JLabel)4 BorderLayout (java.awt.BorderLayout)3 File (java.io.File)3 JFileChooser (javax.swing.JFileChooser)3 Color (java.awt.Color)2 FlowLayout (java.awt.FlowLayout)2 GridLayout (java.awt.GridLayout)2 JButton (javax.swing.JButton)2 JTextField (javax.swing.JTextField)2 PropertiesPreferences (com.igormaznitsa.mindmap.swing.panel.utils.PropertiesPreferences)1 MessagesService (com.igormaznitsa.sciareto.notifications.MessagesService)1 PrinterPlugin (com.igormaznitsa.sciareto.plugins.services.PrinterPlugin)1 MainFrame (com.igormaznitsa.sciareto.ui.MainFrame)1 SplashScreen (com.igormaznitsa.sciareto.ui.UiUtils.SplashScreen)1