Search in sources :

Example 36 with LookAndFeelInfo

use of javax.swing.UIManager.LookAndFeelInfo in project com.revolsys.open by revolsys.

the class BaseMain method runDo.

protected void runDo() throws Throwable {
    boolean lookSet = false;
    if (Property.hasValue(this.lookAndFeelName)) {
        final LookAndFeelInfo[] installedLookAndFeels = UIManager.getInstalledLookAndFeels();
        for (final LookAndFeelInfo lookAndFeelInfo : installedLookAndFeels) {
            final String name = lookAndFeelInfo.getName();
            if (this.lookAndFeelName.equals(name)) {
                try {
                    final String className = lookAndFeelInfo.getClassName();
                    UIManager.setLookAndFeel(className);
                    lookSet = true;
                } catch (final Throwable e) {
                }
            }
        }
    }
    if (!lookSet) {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    }
    JFrame.setDefaultLookAndFeelDecorated(true);
    JDialog.setDefaultLookAndFeelDecorated(true);
    ToolTipManager.sharedInstance().setInitialDelay(100);
}
Also used : LookAndFeelInfo(javax.swing.UIManager.LookAndFeelInfo)

Example 37 with LookAndFeelInfo

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

the class LookAndFeelManager method changeTo.

public boolean changeTo(String lookAndFeelName) {
    currentLAF = lookAndFeelName;
    for (LookAndFeelInfo info : available) {
        if (info.getName().equals(lookAndFeelName)) {
            try {
                UIManager.setLookAndFeel(info.getClassName());
                updateUserInterface();
                return true;
            } catch (RuntimeException re) {
                throw re;
            } catch (Throwable t) {
                t.printStackTrace();
                return false;
            }
        }
    }
    return false;
}
Also used : LookAndFeelInfo(javax.swing.UIManager.LookAndFeelInfo)

Example 38 with LookAndFeelInfo

use of javax.swing.UIManager.LookAndFeelInfo in project MtgDesktopCompanion by nicho92.

the class LookAndFeelProvider method getExtraLookAndFeel.

public LookAndFeelInfo[] getExtraLookAndFeel() {
    if (!list.isEmpty())
        return list.toArray(new LookAndFeelInfo[list.size()]);
    Reflections classReflections = new Reflections("org.pushingpixels.substance.api.skin");
    list = new ArrayList<>();
    for (Class<? extends SubstanceLookAndFeel> c : classReflections.getSubTypesOf(SubstanceLookAndFeel.class)) {
        try {
            SubstanceLookAndFeel look = c.getConstructor(null).newInstance();
            list.add(new LookAndFeelInfo(look.getID(), c.getName()));
        } catch (Exception e) {
            logger.error("Loading " + c, e);
        }
    }
    return list.toArray(new LookAndFeelInfo[list.size()]);
}
Also used : SubstanceLookAndFeel(org.pushingpixels.substance.api.SubstanceLookAndFeel) LookAndFeelInfo(javax.swing.UIManager.LookAndFeelInfo) Reflections(org.reflections.Reflections)

Example 39 with LookAndFeelInfo

use of javax.swing.UIManager.LookAndFeelInfo in project Vidyavana by borsosl.

the class Main method setLookAndFeel.

private static void setLookAndFeel() {
    try {
        boolean hasNimbus = false;
        for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
            if ("Nimbus".equals(info.getName())) {
                UIManager.setLookAndFeel(info.getClassName());
                hasNimbus = true;
                break;
            }
        }
        if (!hasNimbus)
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
    }
}
Also used : LookAndFeelInfo(javax.swing.UIManager.LookAndFeelInfo) IOException(java.io.IOException)

Example 40 with LookAndFeelInfo

use of javax.swing.UIManager.LookAndFeelInfo in project netbeans-mmd-plugin by raydac.

the class Main method main.

public static void main(@Nonnull @MustNotContainNull final String... args) {
    // -- Properties for MAC OSX --
    // NOI18N
    System.setProperty("apple.awt.fileDialogForDirectories", "true");
    // NOI18N
    System.setProperty("apple.laf.useScreenMenuBar", "true");
    // NOI18N
    System.setProperty("com.apple.mrj.application.apple.menu.about.name", "SciaReto");
    // ----------------------------
    SystemUtils.setDebugLevelForJavaLogger(Level.WARNING);
    PlatformProvider.getPlatform().init();
    final String selectedLookAndFeel = PreferencesManager.getInstance().getPreferences().get(PROPERTY_LOOKANDFEEL, PlatformProvider.getPlatform().getDefaultLFClassName());
    // NOI18N
    LOGGER.info("java.vendor = " + System.getProperty("java.vendor", "unknown"));
    // NOI18N
    LOGGER.info("java.version = " + System.getProperty("java.version", "unknown"));
    // NOI18N
    LOGGER.info("os.name = " + System.getProperty("os.name", "unknown"));
    // NOI18N
    LOGGER.info("os.arch = " + System.getProperty("os.arch", "unknown"));
    // NOI18N
    LOGGER.info("os.version = " + System.getProperty("os.version", "unknown"));
    final AtomicReference<SplashScreen> splash = new AtomicReference<>();
    final long timeTakenBySplashStart;
    if (args.length == 0) {
        final long splashTimerStart = System.currentTimeMillis();
        try {
            // NOI18N
            final Image splashImage = Assertions.assertNotNull(UiUtils.loadIcon("splash.png"));
            SwingUtilities.invokeAndWait(new Runnable() {

                @Override
                public void run() {
                    try {
                        splash.set(new SplashScreen(splashImage));
                        splash.get().setVisible(true);
                    } catch (Exception ex) {
                        // NOI18N
                        LOGGER.error("Splash can't be shown", ex);
                        if (splash.get() != null) {
                            splash.get().dispose();
                            splash.set(null);
                        }
                    }
                }
            });
        } catch (final Exception ex) {
            // NOI18N
            LOGGER.error("Error during splash processing", ex);
        }
        timeTakenBySplashStart = System.currentTimeMillis() - splashTimerStart;
    } else {
        timeTakenBySplashStart = 0L;
    }
    if ((System.currentTimeMillis() - PreferencesManager.getInstance().getPreferences().getLong(MetricsService.PROPERTY_METRICS_SENDING_LAST_TIME, System.currentTimeMillis() + STATISTICS_DELAY)) >= STATISTICS_DELAY) {
        // NOI18N
        LOGGER.info("Statistics scheduled");
        final Timer timer = new Timer(45000, new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                MetricsService.getInstance().sendStatistics();
            }
        });
        timer.setRepeats(false);
        timer.start();
    }
    Runtime.getRuntime().addShutdownHook(new Thread() {

        @Override
        public void run() {
            try {
                final Preferences prefs = PreferencesManager.getInstance().getPreferences();
                prefs.putLong(PROPERTY_TOTAL_UPSTART, prefs.getLong(PROPERTY_TOTAL_UPSTART, 0L) + (System.currentTimeMillis() - UPSTART));
                PreferencesManager.getInstance().flush();
            } finally {
                PlatformProvider.getPlatform().dispose();
            }
        }
    });
    try {
        for (final LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
            if (selectedLookAndFeel.equals(info.getClassName())) {
                UIManager.setLookAndFeel(info.getClassName());
                break;
            }
        }
    } catch (Exception e) {
        // NOI18N
        LOGGER.error("Can't set L&F", e);
    }
    loadPlugins();
    boolean doShowGUI = true;
    if (args.length > 0) {
        if ("--help".equalsIgnoreCase(args[0]) || "--?".equals(args[0])) {
            // NOI18N
            doShowGUI = false;
            MindMapPluginRegistry.getInstance().registerPlugin(new LocalMMDExporter());
            MindMapPluginRegistry.getInstance().registerPlugin(new LocalMMDImporter());
            printCliHelp(System.out);
            System.exit(0);
        } else if ("--importsettings".equalsIgnoreCase(args[0])) {
            // NOI18N
            doShowGUI = false;
            final File file = args.length > 1 ? new File(args[1]) : null;
            if (file == null) {
                // NOI18N
                LOGGER.error("Settings file not provided");
                System.exit(1);
            }
            if (!importSettings(file)) {
                System.exit(1);
            }
        } else if ("--exportsettings".equalsIgnoreCase(args[0])) {
            // NOI18N
            doShowGUI = false;
            // NOI18N
            final File file = args.length > 1 ? new File(args[1]) : new File("sciaretosettings.properties");
            if (!exportSettings(file)) {
                System.exit(1);
            }
        } else if ("--convert".equalsIgnoreCase(args[0])) {
            // NOI18N
            doShowGUI = false;
            if (!convertData(args)) {
                // NOI18N
                LOGGER.error("Conversion failed for error");
                printConversionHelp(System.out);
                System.exit(1);
            }
        }
    }
    if (doShowGUI) {
        SystemUtils.setDebugLevelForJavaLogger(Level.INFO);
        MindMapPluginRegistry.getInstance().registerPlugin(new PrinterPlugin());
        MindMapPluginRegistry.getInstance().unregisterPluginForClass(AboutPlugin.class);
        MindMapPluginRegistry.getInstance().unregisterPluginForClass(OptionsPlugin.class);
        SwingUtilities.invokeLater(new Runnable() {

            @Override
            public void run() {
                final GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
                final int width = gd.getDisplayMode().getWidth();
                final int height = gd.getDisplayMode().getHeight();
                if (PlatformProvider.isErrorDetected()) {
                    JOptionPane.showMessageDialog(null, "Can't init the Platform dependent layer, the default one will be used instead.\n" + "Check that you have installed Java correctly to avoid the warning", "Warning", JOptionPane.WARNING_MESSAGE);
                }
                MAIN_FRAME = new MainFrame(args);
                MAIN_FRAME.setSize(Math.round(width * 0.75f), Math.round(height * 0.75f));
                if (splash.get() != null) {
                    final long delay = (2000L + timeTakenBySplashStart) - (System.currentTimeMillis() - UPSTART);
                    if (delay > 0L) {
                        final Timer timer = new Timer((int) delay, new ActionListener() {

                            @Override
                            public void actionPerformed(@Nonnull final ActionEvent e) {
                                splash.get().dispose();
                                splash.set(null);
                            }
                        });
                        timer.setRepeats(false);
                        timer.start();
                    } else {
                        splash.get().dispose();
                        splash.set(null);
                    }
                }
                MAIN_FRAME.setVisible(true);
                MAIN_FRAME.setExtendedState(MAIN_FRAME.getExtendedState() | JFrame.MAXIMIZED_BOTH);
                final JHtmlLabel label = new JHtmlLabel("<html>You use the application already for some time. If you like it then you could support its author and <a href=\"http://www.google.com\"><b>make some donation</b></a>.</html>");
                label.addLinkListener(new JHtmlLabel.LinkListener() {

                    @Override
                    public void onLinkActivated(@Nonnull final JHtmlLabel source, @Nonnull final String link) {
                        try {
                            UiUtils.browseURI(new URI(link), false);
                        } catch (URISyntaxException ex) {
                            // NOI18N
                            LOGGER.error("Can't make URI", ex);
                        }
                    }
                });
            }
        });
        new MessagesService().execute();
    }
}
Also used : ActionEvent(java.awt.event.ActionEvent) URISyntaxException(java.net.URISyntaxException) Image(java.awt.Image) BufferedImage(java.awt.image.BufferedImage) URI(java.net.URI) MainFrame(com.igormaznitsa.sciareto.ui.MainFrame) GraphicsDevice(java.awt.GraphicsDevice) SplashScreen(com.igormaznitsa.sciareto.ui.UiUtils.SplashScreen) PropertiesPreferences(com.igormaznitsa.mindmap.swing.panel.utils.PropertiesPreferences) Preferences(java.util.prefs.Preferences) LookAndFeelInfo(javax.swing.UIManager.LookAndFeelInfo) Nonnull(javax.annotation.Nonnull) MessagesService(com.igormaznitsa.sciareto.notifications.MessagesService) AtomicReference(java.util.concurrent.atomic.AtomicReference) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) JHtmlLabel(com.igormaznitsa.sciareto.ui.misc.JHtmlLabel) Timer(javax.swing.Timer) ActionListener(java.awt.event.ActionListener) PrinterPlugin(com.igormaznitsa.sciareto.plugins.services.PrinterPlugin) File(java.io.File)

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