Example usage for javax.swing UIManager put

List of usage examples for javax.swing UIManager put

Introduction

In this page you can find the example usage for javax.swing UIManager put.

Prototype

public static Object put(Object key, Object value) 

Source Link

Document

Stores an object in the developer defaults.

Usage

From source file:org.ut.biolab.medsavant.MedSavantClient.java

private static void customizeForMac() {

    try {//from w  w  w .j a  v a2 s. c  om

        UIManager.put("Panel.background", new Color(237, 237, 237)); // the above line makes the bg dark, setting back

        System.setProperty("apple.laf.useScreenMenuBar", "true");
        System.setProperty("com.apple.mrj.application.apple.menu.about.name", "MedSavant");

        batchApplyProperty(new String[] { "Button.font", "ToggleButton.font", "RadioButton.font",
                "CheckBox.font", "ColorChooser.font", "ComboBox.font", "Label.font", "List.font",
                "MenuBar.font", "MenuItem.font", "RadioButtonMenuItem.font", "CheckBoxMenuItem.font",
                "Menu.font", "PopupMenu.font", "OptionPane.font", "Panel.font", "ProgressBar.font",
                "ScrollPane.font", "Viewport.font", "TabbedPane.font", "Table.font", "TableHeader.font",
                "TextField.font", "PasswordField.font", "TextArea.font", "TextPane.font", "EditorPane.font",
                "TitledBorder.font", "ToolBar.font", "ToolTip.font", "Tree.font", "JOptionPane.font",
                "JDialog.font" }, FontFactory.getGeneralFont());

        System.setProperty("awt.useSystemAAFontSettings", "on");
        System.setProperty("swing.aatext", "true");

        UIManager.put("TitledBorder.border", UIManager.getBorder("TitledBorder.aquaVariant"));
        //com.apple.eawt.FullScreenUtilities.setWindowCanFullScreen(this, true);
        Application macOSXApplication = Application.getApplication();
        macOSXApplication.setAboutHandler(new AboutHandler() {
            @Override
            public void handleAbout(AppEvent.AboutEvent evt) {
                JOptionPane.showMessageDialog(MedSavantFrame.getInstance(), "MedSavant "
                        + VersionSettings.getVersionString() + "\nCreated by Biolab at University of Toronto.");
            }
        });
        macOSXApplication.setPreferencesHandler(new PreferencesHandler() {
            @Override
            public void handlePreferences(AppEvent.PreferencesEvent pe) {
                DialogUtils.displayMessage("Preferences available for Administrators only");
            }
        });
        macOSXApplication.setQuitHandler(new QuitHandler() {
            @Override
            public void handleQuitRequestWith(AppEvent.QuitEvent evt, QuitResponse resp) {
                MedSavantFrame.getInstance().requestClose();
                resp.cancelQuit(); // If user accepted close request, System.exit() was called and we never get here.
            }
        });
    } catch (Throwable x) {
        System.err.println(
                "Warning: MedSavant requires Java for Mac OS X 10.6 Update 3 (or later).\nPlease check Software Update for the latest version.");
    }
}

From source file:org.ut.biolab.medsavant.MedSavantClient.java

private static void batchApplyProperty(String[] propn, Object o) {
    for (String s : propn) {
        UIManager.put(s, o);
    }
}

From source file:org.yccheok.jstock.gui.JStock.java

/**
 * @param args the command line arguments
 */// w w w.ja va 2s .  c om
public static void main(String args[]) {
    /***********************************************************************
     * UI Manager initialization via JStockOptions.
     **********************************************************************/
    final JStockOptions jStockOptions = getJStockOptionsViaXML();

    // OSX menu bar at top.
    if (Utils.isMacOSX()) {
        System.setProperty("apple.laf.useScreenMenuBar", "true");
        System.setProperty("apple.awt.brushMetalLook", "true");
    }

    boolean uiManagerLookAndFeelSuccess = false;
    try {
        String lookNFeel = jStockOptions.getLooknFeel();
        if (null != lookNFeel) {
            UIManager.setLookAndFeel(lookNFeel);
            uiManagerLookAndFeelSuccess = true;
        }
    } catch (java.lang.ClassNotFoundException | java.lang.InstantiationException
            | java.lang.IllegalAccessException | javax.swing.UnsupportedLookAndFeelException exp) {
        log.error(null, exp);
    }

    if (!uiManagerLookAndFeelSuccess) {
        String className = Utils.setDefaultLookAndFeel();
        if (null != className) {
            final String lookNFeel = jStockOptions.getLooknFeel();
            // When jStockOptions.getLookNFeel returns null, it means we wish
            // to use system default value. Hence, don't overwrite the null value,
            // so that we can use the same jStockOptions, across different
            // platforms.
            if (lookNFeel != null) {
                jStockOptions.setLooknFeel(className);
            }
        }
    }

    /***********************************************************************
     * Ensure correct localization.
     **********************************************************************/
    // This global effect, should just come before anything else, 
    // after we get an instance of JStockOptions.
    Locale.setDefault(jStockOptions.getLocale());

    /***********************************************************************
     * Single application instance enforcement.
     **********************************************************************/
    if (false == AppLock.lock()) {
        final int choice = JOptionPane.showOptionDialog(null,
                MessagesBundle.getString("warning_message_running_2_jstock"),
                MessagesBundle.getString("warning_title_running_2_jstock"), JOptionPane.YES_NO_OPTION,
                JOptionPane.WARNING_MESSAGE, null,
                new String[] { MessagesBundle.getString("yes_button_running_2_jstock"),
                        MessagesBundle.getString("no_button_running_2_jstock") },
                MessagesBundle.getString("no_button_running_2_jstock"));
        if (choice != JOptionPane.YES_OPTION) {
            System.exit(0);
            return;
        }
    }

    // Avoid "JavaFX IllegalStateException when disposing JFXPanel in Swing"
    // http://stackoverflow.com/questions/16867120/javafx-illegalstateexception-when-disposing-jfxpanel-in-swing
    Platform.setImplicitExit(false);

    // As ProxyDetector is affected by system properties
    // http.proxyHost, we are forced to initialized ProxyDetector right here,
    // before we manually change the system properties according to
    // JStockOptions.
    ProxyDetector.getInstance();

    /***********************************************************************
     * Apply large font if possible.
     **********************************************************************/
    if (jStockOptions.useLargeFont()) {
        java.util.Enumeration keys = UIManager.getDefaults().keys();
        while (keys.hasMoreElements()) {
            Object key = keys.nextElement();
            Object value = UIManager.get(key);
            if (value != null && value instanceof javax.swing.plaf.FontUIResource) {
                javax.swing.plaf.FontUIResource fr = (javax.swing.plaf.FontUIResource) value;
                UIManager.put(key, new javax.swing.plaf.FontUIResource(
                        fr.deriveFont((float) fr.getSize2D() * (float) Constants.FONT_ENLARGE_FACTOR)));
            }
        }
    }

    /***********************************************************************
     * GA tracking.
     **********************************************************************/
    GA.trackAsynchronously("main");

    java.awt.EventQueue.invokeLater(new Runnable() {
        @Override
        public void run() {
            final JStock mainFrame = JStock.instance();

            // We need to first assign jStockOptions to mainFrame, as during
            // Utils.migrateXMLToCSVPortfolios, we will be accessing mainFrame's
            // jStockOptions.
            mainFrame.initJStockOptions(jStockOptions);

            mainFrame.init();
            mainFrame.setVisible(true);
            mainFrame.updateDividerLocation();
            mainFrame.requestFocusOnJComboBox();
        }
    });
}

From source file:processing.app.Base.java

private void installKeyboardInputMap() {
    UIManager.put("RSyntaxTextAreaUI.inputMap", new SketchTextAreaDefaultInputMap());
}

From source file:Proiect.uploadFTP.java

public void actionFTP() {
    adressf.addCaretListener(new CaretListener() {
        public void caretUpdate(CaretEvent e) {
            InetAddress thisIp;/*from  w w  w . ja v  a2s.  c om*/
            try {
                thisIp = InetAddress.getLocalHost();
                titleFTP.setText("Connection: " + thisIp.getHostAddress() + " -> " + adressf.getText());
            } catch (UnknownHostException e1) {
                e1.printStackTrace();
            }
        }
    });

    exit.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            saveState();
            uploadFTP.dispose();
            tree.dispose();
        }
    });

    connect.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            FTPClient client = new FTPClient();
            FileInputStream fis = null;
            String pass = String.valueOf(passf.getPassword());
            try {
                if (filename == null) {
                    status.setText("File does not exist!");
                } else {
                    // Server address
                    client.connect(adressf.getText());
                    // Login credentials
                    client.login(userf.getText(), pass);
                    if (client.isConnected()) {
                        status.setText("Succesfull transfer!");
                        // File type
                        client.setFileType(FTP.BINARY_FILE_TYPE);
                        // File location
                        File file = new File(filepath);
                        fis = new FileInputStream(file);
                        // Change the folder on the server
                        client.changeWorkingDirectory(folderf.getText());
                        // Save the file on the server
                        client.storeFile(filename, fis);
                    } else {
                        status.setText("Transfer failed!");
                    }
                }
                client.logout();
            } catch (IOException e1) {
                Encrypter.printException(e1);
            } finally {
                try {
                    if (fis != null) {
                        fis.close();
                    }
                    client.disconnect();
                } catch (IOException e1) {
                    Encrypter.printException(e1);
                }
            }
        }
    });

    browsef.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            int retval = chooserf.showOpenDialog(chooserf);
            if (retval == JFileChooser.APPROVE_OPTION) {
                status.setText("");
                filename = chooserf.getSelectedFile().getName().toString();
                filepath = chooserf.getSelectedFile().getPath();
                filenf.setText(chooserf.getSelectedFile().getName().toString());
            }
        }
    });

    adv.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

            tree.setSize(220, uploadFTP.getHeight());
            tree.setLocation(uploadFTP.getX() + 405, uploadFTP.getY());
            tree.setResizable(false);
            tree.setIconImage(Toolkit.getDefaultToolkit()
                    .getImage(getClass().getClassLoader().getResource("assets/ico.png")));
            tree.setUndecorated(true);
            tree.getRootPane().setBorder(BorderFactory.createLineBorder(Encrypter.color_black, 2));
            tree.setVisible(true);
            tree.setLayout(new BorderLayout());

            JLabel labeltree = new JLabel("Server documents");
            labeltree.setOpaque(true);
            labeltree.setBackground(Encrypter.color_light);
            labeltree.setBorder(BorderFactory.createMatteBorder(8, 10, 10, 0, Encrypter.color_light));
            labeltree.setForeground(Encrypter.color_blue);
            labeltree.setFont(Encrypter.font16);

            JButton refresh = new JButton("");
            ImageIcon refresh_icon = getImageIcon("assets/icons/refresh.png");
            refresh.setIcon(refresh_icon);
            refresh.setBackground(Encrypter.color_light);
            refresh.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0));
            refresh.setForeground(Encrypter.color_black);
            refresh.setFont(Encrypter.font16);
            refresh.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

            final FTPClient client = new FTPClient();
            DefaultMutableTreeNode top = new DefaultMutableTreeNode(adressf.getText());
            DefaultMutableTreeNode files = null;
            DefaultMutableTreeNode leaf = null;

            final JTree tree_view = new JTree(top);
            tree_view.setForeground(Encrypter.color_black);
            tree_view.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0));
            tree_view.putClientProperty("JTree.lineStyle", "None");
            tree_view.setBackground(Encrypter.color_light);
            JScrollPane scrolltree = new JScrollPane(tree_view);
            scrolltree.setBackground(Encrypter.color_light);
            scrolltree.getVerticalScrollBar().setPreferredSize(new Dimension(0, 0));

            UIManager.put("Tree.textBackground", Encrypter.color_light);
            UIManager.put("Tree.selectionBackground", Encrypter.color_blue);
            UIManager.put("Tree.selectionBorderColor", Encrypter.color_blue);

            tree_view.updateUI();

            final String pass = String.valueOf(passf.getPassword());
            try {
                client.connect(adressf.getText());
                client.login(userf.getText(), pass);
                client.enterLocalPassiveMode();
                if (client.isConnected()) {
                    try {
                        FTPFile[] ftpFiles = client.listFiles();
                        for (FTPFile ftpFile : ftpFiles) {
                            files = new DefaultMutableTreeNode(ftpFile.getName());
                            top.add(files);
                            if (ftpFile.getType() == FTPFile.DIRECTORY_TYPE) {
                                FTPFile[] ftpFiles1 = client.listFiles(ftpFile.getName());
                                for (FTPFile ftpFile1 : ftpFiles1) {
                                    leaf = new DefaultMutableTreeNode(ftpFile1.getName());
                                    files.add(leaf);
                                }
                            }
                        }
                    } catch (IOException e1) {
                        Encrypter.printException(e1);
                    }
                    client.disconnect();
                } else {
                    status.setText("Failed connection!");
                }
            } catch (IOException e1) {
                Encrypter.printException(e1);
            } finally {
                try {
                    client.disconnect();
                } catch (IOException e1) {
                    Encrypter.printException(e1);
                }
            }

            tree.add(labeltree, BorderLayout.NORTH);
            tree.add(scrolltree, BorderLayout.CENTER);
            tree.add(refresh, BorderLayout.SOUTH);

            uploadFTP.addComponentListener(new ComponentListener() {

                public void componentMoved(ComponentEvent e) {
                    tree.setLocation(uploadFTP.getX() + 405, uploadFTP.getY());
                }

                public void componentShown(ComponentEvent e) {
                }

                public void componentResized(ComponentEvent e) {
                }

                public void componentHidden(ComponentEvent e) {
                }
            });

            uploadFTP.addWindowListener(new WindowListener() {
                public void windowActivated(WindowEvent e) {
                    tree.toFront();
                }

                public void windowOpened(WindowEvent e) {
                }

                public void windowIconified(WindowEvent e) {
                }

                public void windowDeiconified(WindowEvent e) {
                }

                public void windowDeactivated(WindowEvent e) {
                }

                public void windowClosing(WindowEvent e) {
                }

                public void windowClosed(WindowEvent e) {
                }
            });

            refresh.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent e) {
                    tree.dispose();
                    tree.setVisible(true);
                }
            });
        }
    });

}

From source file:quake3mapfixer.Pk3Fixer.java

private void fileChooserActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fileChooserActionPerformed
    Boolean old = UIManager.getBoolean("FileChooser.readOnly");
    UIManager.put("FileChooser.readOnly", Boolean.TRUE);
    JFileChooser chooser = new JFileChooser();
    UIManager.put("FileChooser.readOnly", old);
    FileNameExtensionFilter pk3filter = new FileNameExtensionFilter("pk3 files (*.pk3)", "pk3");
    chooser.setFileFilter(pk3filter);//from   w  ww.java2 s .c o  m
    chooser.setAcceptAllFileFilterUsed(false);
    chooser.setDialogTitle("Open pk3 file");
    if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
        currentDirectory = chooser.getCurrentDirectory().toString();
        selectedFile = chooser.getSelectedFile().toString();
        absolutePath = chooser.getSelectedFile().getName();
        areaFileName.setText(selectedFile);
        fileFixer.setEnabled(true);
    }

}

From source file:savant.view.swing.Savant.java

/**
 * Starts an instance of the Savant Browser
 *
 * @param args the command line arguments
 *//*from  www . ja  v  a 2  s.c  o  m*/
public static void main(String args[]) {

    AnalyticsAgent.onStartSession("Savant", BrowserSettings.VERSION);

    try {
        boolean loadProject = false;
        boolean loadPlugin = false;
        String loadProjectUrl = null;
        List<String> loadPluginUrls = new ArrayList<String>();
        for (int i = 0; i < args.length; i++) {
            String s = args[i];
            if (s.startsWith("--")) { //build
                loadProject = false;
                loadPlugin = false;
                BrowserSettings.BUILD = s.replaceAll("-", "");
                if (s.equals("--debug")) {
                    turnExperimentalFeaturesOff = false;
                }
            } else if (s.startsWith("-")) {
                if (s.equals("-project")) {
                    loadProject = true;
                    loadPlugin = false;
                } else if (s.equals("-plugins")) {
                    loadPlugin = true;
                    loadProject = false;
                }
            } else if (loadProject) {
                loadProjectUrl = s;
                loadProject = false;
            } else if (loadPlugin) {
                loadPluginUrls.add(s);
            } else {
                //bad argument, skip
            }
        }

        System.setProperty("java.net.useSystemProxies", "true");
        installMissingPlugins(loadPluginUrls);

        //java.awt.EventQueue.invokeLater(new Runnable() {

        //@Override
        //public void run() {

        System.setProperty("apple.laf.useScreenMenuBar", "true");
        com.jidesoft.utils.Lm.verifyLicense("Marc Fiume", "Savant Genome Browser",
                "1BimsQGmP.vjmoMbfkPdyh0gs3bl3932");
        UIManager.put("JideSplitPaneDivider.border", 5);
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

        SAMFileReader.setDefaultValidationStringency(SAMFileReader.ValidationStringency.SILENT);

        if (MiscUtils.WINDOWS) {
            LookAndFeelFactory.installJideExtension(LookAndFeelFactory.XERTO_STYLE_WITHOUT_MENU);
        }

        // Load project immediately if argument exists.
        if (Savant.getInstance().isWebStart() && loadProjectUrl != null) {
            ProjectController.getInstance().loadProjectFromURL(loadProjectUrl);
        }
    } catch (Exception x) {
        LOG.error("Error in main()", x);
    }
}

From source file:storybook.toolkit.swing.SwingUtil.java

public static void setUIFont(javax.swing.plaf.FontUIResource f) {
    Enumeration<Object> keys = UIManager.getDefaults().keys();
    while (keys.hasMoreElements()) {
        Object key = keys.nextElement();
        Object value = UIManager.get(key);
        if (value instanceof javax.swing.plaf.FontUIResource)
            UIManager.put(key, f);
    }/*w  w w  .  j a v  a 2 s .co m*/
}

From source file:studio.core.EntryPoint.java

public static void main(final String[] args) {
    TimeZone.setDefault(TimeZone.getTimeZone("GMT"));

    if (System.getProperty("mrj.version") != null) {
        System.setProperty("apple.laf.useScreenMenuBar", "true");
        //     System.setProperty("apple.awt.brushMetalLook", "true");
        System.setProperty("apple.awt.showGrowBox", "true");
        System.setProperty("com.apple.mrj.application.apple.menu.about.name", "Studio for kdb+");
        System.setProperty("com.apple.mrj.application.live-resize", "true");
        System.setProperty("com.apple.macos.smallTabs", "true");
        System.setProperty("com.apple.mrj.application.growbox.intrudes", "false");
    }/*  w  w w.j ava 2s  .co m*/

    if (Config.getInstance().getLookAndFeel() != null) {
        try {
            UIManager.setLookAndFeel(Config.getInstance().getLookAndFeel());
        } catch (Exception ex) {
            // go on with default one
            ex.printStackTrace();
        }
    }
    final CommandLineParser cmdLineGnuParser = new GnuParser();
    try {
        CommandLine commandLine = cmdLineGnuParser.parse(constructGnuOptions(), args);
        if (commandLine.hasOption("servers")) {
            String fileName = commandLine.getOptionValue("servers");
            Config.getInstance().loadFromFile(fileName);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    studio.ui.I18n.setLocale(Locale.getDefault());

    //   studio.ui.I18n.setLocale(new Locale("zh", "cn"));

    if (!Config.getInstance().getAcceptedLicense()) {
        LicensePanel panel = new LicensePanel();
        Object[] options = new String[] { "Accept", "Do Not Accept" };
        int answer = JOptionPane.showOptionDialog(null, panel, "Studio for kdb+", JOptionPane.YES_NO_OPTION,
                JOptionPane.QUESTION_MESSAGE, Studio.getImage(Config.imageBase + "32x32/question.png"), //do not use a custom Icon
                options, //the titles of buttons
                options[1]); //default button title

        if (answer == JOptionPane.NO_OPTION)
            System.exit(0);

        Config.getInstance().setAcceptedLicense(Lm.buildDate);
    }

    UIManager.put("Table.font", new javax.swing.plaf.FontUIResource("Monospaced", Font.PLAIN,
            UIManager.getFont("Table.font").getSize()));
    System.setProperty("awt.useSystemAAFontSettings", "on");
    System.setProperty("swing.aatext", "true");

    ThreadGroup exceptionThreadGroup = new ExceptionGroup();

    new Thread(exceptionThreadGroup, "Init thread") {
        public void run() {
            Studio.init(args);
        }
    }.start();

}

From source file:test.uk.co.modularaudio.util.swing.lwtc.TestShowLWTCSliderComparison.java

public static void main(final String[] args) throws Exception {
    if (LWTCCtrlTestingConstants.USE_LAF) {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        UIManager.put("Slider.paintValue", Boolean.FALSE);
    }//from   ww w  . ja  v  a  2  s  .  c o m
    final TestShowLWTCSliderComparison vt = new TestShowLWTCSliderComparison();
    vt.go(SwingConstants.VERTICAL);

    final TestShowLWTCSliderComparison ht = new TestShowLWTCSliderComparison();
    ht.go(SwingConstants.HORIZONTAL);
}