Example usage for javax.swing JDialog setDefaultLookAndFeelDecorated

List of usage examples for javax.swing JDialog setDefaultLookAndFeelDecorated

Introduction

In this page you can find the example usage for javax.swing JDialog setDefaultLookAndFeelDecorated.

Prototype

public static void setDefaultLookAndFeelDecorated(boolean defaultLookAndFeelDecorated) 

Source Link

Document

Provides a hint as to whether or not newly created JDialog s should have their Window decorations (such as borders, widgets to close the window, title...) provided by the current look and feel.

Usage

From source file:pl.edu.icm.visnow.system.main.VisNow.java

public static void main(final String[] args) {
    /*/*from  w w w . j a v  a  2 s.  c o  m*/
     * try { for (javax.swing.UIManager.LookAndFeelInfo info :
     * javax.swing.UIManager.getInstalledLookAndFeels()) { if
     * ("Nimbus".equals(info.getName())) {
     * javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } }
     * } catch (ClassNotFoundException ex) {
     * java.util.logging.LOGGER.getLogger(VisNow.class.getName()).log(java.util.logging.Level.SEVERE,
     * null, ex); } catch (InstantiationException ex) {
     * java.util.logging.LOGGER.getLogger(VisNow.class.getName()).log(java.util.logging.Level.SEVERE,
     * null, ex); } catch (IllegalAccessException ex) {
     * java.util.logging.LOGGER.getLogger(VisNow.class.getName()).log(java.util.logging.Level.SEVERE,
     * null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) {
     * java.util.logging.LOGGER.getLogger(VisNow.class.getName()).log(java.util.logging.Level.SEVERE,
     * null, ex); }
     */
    EventQueue.invokeLater(new Runnable() {
        @Override
        public void run() {

            for (int i = 0; i < args.length; i++) {
                if (args[i].equals("-debug")) {
                    debug = true;
                }

                if (args[i].equals("-substancedebug")) {
                    substancedebug = true;
                }

                if (args[i].equals("-easy")) {
                    libraryLevel = SIMPLE_LIBRARY;
                    VERSION = VERSION_BASE + "-Simple";
                    allowGUISwitch = false;
                }

                if (args[i].equals("-full")) {
                    guiLevel = EXPERT_GUI;
                    libraryLevel = FULL_LIBRARY;
                    VERSION = VERSION_BASE + "-Pro";
                }
            }
            Locale.setDefault(Locale.US);

            renderSplashFrame(0.1f, "Initializing logging...");
            //TODO: test it see #initConfigDir
            //                initConfigDir();
            initLogging();
            startupInfo();
            renderSplashFrame(0.2f, "Initializing Java3D...");
            initJava3D();

            if (substancedebug) {
                try {

                    Class substance = Class.forName("org.jvnet.substance.SubstanceLookAndFeel");
                    Class selectedSkinClass;
                    if (guiLevel == SIMPLE_GUI) {
                        selectedSkinClass = Class.forName("org.jvnet.substance.skin.BusinessBlackSteelSkin");
                    } else {
                        @SuppressWarnings("unchecked")
                        Map<String, Object> skinInfoMap = (Map<String, Object>) substance
                                .getMethod("getAllSkins").invoke(null);
                        List<String> skinClassNameArray = new ArrayList<String>();
                        for (Object object : skinInfoMap.values()) {
                            String cn = (String) object.getClass().getMethod("getClassName").invoke(object);
                            LOGGER.info("Adding substance skin class: " + cn);
                            skinClassNameArray.add(cn);
                        }
                        int skinClassIdx = 0;
                        if (guiLevel == SIMPLE_GUI) {
                            skinClassIdx = 2;
                        } else {
                            skinClassIdx = new Random().nextInt(skinClassNameArray.size());
                        }
                        LOGGER.info("Selected skin: " + skinClassNameArray.get(skinClassIdx));
                        selectedSkinClass = Class.forName(skinClassNameArray.get(skinClassIdx));
                    }

                    //                        selectedSkinClass =Class.forName("org.jvnet.substance.skin.BusinessBlackSteelSkin");
                    javax.swing.UIManager
                            .setLookAndFeel("org.jvnet.substance.skin.SubstanceBusinessLookAndFeel");
                    Class skinClass = Class.forName("org.jvnet.substance.api.SubstanceSkin");
                    @SuppressWarnings("unchecked")
                    Method m = substance.getMethod("setSkin", skinClass);
                    m.invoke(null, selectedSkinClass.newInstance());
                    JFrame.setDefaultLookAndFeelDecorated(true);
                    JDialog.setDefaultLookAndFeelDecorated(true);
                } catch (Exception ex) {
                    LOGGER.error("Failed to set lf: " + ex.getMessage());
                }
            }

            //resize borders from tabbedPane
            //TODO: needs refactoring - initPresentation, initL&F or sth like that
            try {
                UIManager.getDefaults().put("TabbedPane.contentBorderInsets", new Insets(4, 0, 0, 0));
            } catch (Exception ex) {
                //this causes exception on MacOS X
            }

            try {
                visnow = new VisNow();

                int argsCount = 0;
                for (int i = 0; i < args.length; i++) {
                    if (!args[i].startsWith("-")) {
                        argsCount++;
                    }
                }
                String[] args2 = new String[argsCount];
                int c = 0;
                for (int i = 0; i < args.length; i++) {
                    if (!args[i].startsWith("-")) {
                        args2[c++] = args[i];
                    }
                }
                visnow.init(args2);
            } catch (VNSystemException ex) {
                Displayer.display(1010101010, ex, null, "Initialization failed.");
                return;
            }

            visnow.initUserMessages();
        }
    });

}

From source file:qic.Main.java

public static void reloadLookAndFeel() {
    if (Config.getBooleanProperty(Config.LOOK_AND_FEEL_DECORATED, false)) {
        JFrame.setDefaultLookAndFeelDecorated(true);
        JDialog.setDefaultLookAndFeelDecorated(true);
        System.setProperty("sun.awt.noerasebackground", "true");
    }/*from   w w  w .  j  ava 2  s  .c  o  m*/
    try {
        String lookAndFeel = Config.getPropety(Config.LOOK_AND_FEEL,
                "com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
        if (lookAndFeel.startsWith("Substance")) {
            lookAndFeel = "org.pushingpixels.substance.api.skin." + lookAndFeel;
        }
        UIManager.setLookAndFeel(lookAndFeel);
    } catch (Exception e) {
        try {
            UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
    }

    for (Window window : Window.getWindows()) {
        SwingUtilities.updateComponentTreeUI(window);
    }
}

From source file:se.nawroth.asciidoc.browser.AsciidocBrowserApplication.java

public static void main(final String[] args) {
    EventQueue.invokeLater(new Runnable() {
        @Override//from   w w  w  .j av a2  s .c o m
        public void run() {
            try {
                JFrame.setDefaultLookAndFeelDecorated(true);
                JDialog.setDefaultLookAndFeelDecorated(true);
                System.setProperty("sun.awt.noerasebackground", "true");
                UIManager.setLookAndFeel(new AsciidocBrowserSubstanceSkin());
                AsciidocBrowserApplication browser = new AsciidocBrowserApplication(args);
                browser.setVisible(true);
                settingsDialog = new SettingsDialog();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
}

From source file:xtrememp.XtremeMP.java

public void init(String[] args) {
    // Process arguments
    Option urlOption = OptionBuilder.withArgName("URL").hasArg().withDescription("Open from URL").create("url");
    Options options = new Options();
    options.addOption("help", false, "print help information");
    options.addOption("version", false, "print the version information");
    options.addOption(urlOption);//from  ww  w  . j  av a 2  s  .c  om
    CommandLineParser parser = new PosixParser();
    try {
        final CommandLine line = parser.parse(options, args);
        if (line.hasOption("h") || line.hasOption("help")) {
            HelpFormatter formatter = new HelpFormatter();
            formatter.printHelp("xtrememp", options);
            System.exit(0);
        }
        if (line.hasOption("version")) {
            StringBuilder appVersion = new StringBuilder(tr("Application.title"));
            appVersion.append(" ").append(currentVersion);
            appVersion.append(" [").append(tr("Dialog.About.Codename"));
            appVersion.append(" ").append(tr("Application.version.codename"));
            appVersion.append("]");
            System.out.println(appVersion.toString());
            System.exit(0);
        }

        // Initialize JIntellitype
        if (OSUtils.IS_OS_WINDOWS) {
            String libraryLocation = (OSUtils.IS_ARCH_X64) ? "\\native\\JIntellitype64.dll"
                    : "\\native\\JIntellitype.dll";
            JIntellitype.setLibraryLocation(OSUtils.USER_DIR + libraryLocation);
            if (JIntellitype.isJIntellitypeSupported()) {
                JIntellitype.getInstance().addIntellitypeListener(this);
            }
        }

        // Initialize audio engine
        audioPlayer = new AudioPlayer();
        audioPlayer.addPlaybackListener(this);
        String mixerName = Settings.getMixerName();
        if (!Utilities.isNullOrEmpty(mixerName)) {
            audioPlayer.setMixerName(mixerName);
        }

        // Launch gui
        EventQueue.invokeLater(() -> {
            if (!OSUtils.IS_OS_WINDOWS_7 && !OSUtils.IS_OS_WINDOWS_VISTA) {
                JFrame.setDefaultLookAndFeelDecorated(true);
                JDialog.setDefaultLookAndFeelDecorated(true);
            }
            UIManager.put(SubstanceLookAndFeel.FOCUS_KIND, SubstanceConstants.FocusKind.NONE);
            SubstanceLookAndFeel.setSkin(Settings.getSkin());

            //Turn on Substance animations if required
            guiEffectsStateChanged(Settings.isUIEffectsEnabled());

            StringBuilder appTitle = new StringBuilder(tr("Application.title"));
            appTitle.append(" ").append(currentVersion);
            mainFrame = new JFrame(appTitle.toString());
            mainFrame.setIconImages(Utilities.getIconImages());

            Rectangle boundsRect = Settings.getMainFrameBounds();
            if (boundsRect.x <= 0 || boundsRect.y <= 0) {
                mainFrame.setSize(boundsRect.width, boundsRect.height);
                // Center the frame.
                mainFrame.setLocationRelativeTo(null);
            } else {
                mainFrame.setBounds(boundsRect);
            }
            mainFrame.addWindowListener(new WindowAdapter() {

                @Override
                public void windowClosing(WindowEvent ev) {
                    exit();
                }
                //                    @Override
                //                    public void windowIconified(WindowEvent e) {
                //                        if (Toolkit.getDefaultToolkit().isFrameStateSupported(JFrame.ICONIFIED)) {
                //                            getMainFrame().setExtendedState(JFrame.ICONIFIED);
                //                        }
                //                        getMainFrame().setVisible(false);
                //                    }
                //
                //                    @Override
                //                    public void windowDeiconified(WindowEvent e) {
                //                        if (Toolkit.getDefaultToolkit().isFrameStateSupported(JFrame.NORMAL)) {
                //                            getMainFrame().setExtendedState(JFrame.NORMAL);
                //                        }
                //                        getMainFrame().setVisible(true);
                //                    }
            });
            createMenuBar();
            createPanels();

            // Set a minimum size for this frame.
            mainFrame.setMinimumSize(new Dimension(532, 244));

            playlist = playlistManager.getPlaylist();
            playlist.addPlaylistListener(XtremeMP.this);

            // Restore playlist settings : play mode
            playlist.setPlayMode(Settings.getPlayMode());

            List<String> argList = Arrays.asList(line.getArgs());
            List<File> fileList = new ArrayList<>();
            if (argList.isEmpty()) {
                File playlistFile = new File(Settings.getCacheDir(), Utilities.DEFAULT_PLAYLIST);
                if (playlistFile.exists()) {
                    playlistManager.loadPlaylist(playlistFile.getAbsolutePath());
                }
            } else {
                playlistManager.setFirstLoad(true);
                if (argList.size() == 1) {
                    File file = new File(argList.get(0));
                    if (audioFileFilter.accept(file)) {
                        fileList.add(file);
                        playlistManager.addFiles(fileList, true);
                    } else if (playlistFileFilter.accept(file)) {
                        playlistManager.loadPlaylist(file.getAbsolutePath());
                    }
                } else {
                    for (String arg : argList) {
                        File file = new File(arg);
                        if (audioFileFilter.accept(file)) {
                            fileList.add(file);
                        }
                    }
                    playlistManager.addFiles(fileList, true);
                }
            }

            mainFrame.setVisible(true);
        });
    } catch (ParseException exp) {
        logger.error("Parsing failed.", exp.getMessage());
    }
}