Example usage for java.awt GraphicsEnvironment getLocalGraphicsEnvironment

List of usage examples for java.awt GraphicsEnvironment getLocalGraphicsEnvironment

Introduction

In this page you can find the example usage for java.awt GraphicsEnvironment getLocalGraphicsEnvironment.

Prototype

public static GraphicsEnvironment getLocalGraphicsEnvironment() 

Source Link

Document

Returns the local GraphicsEnvironment .

Usage

From source file:PureImmediateStereo.java

public void init() {
    setLayout(new BorderLayout());

    // Preferred to use Stereo
    GraphicsConfigTemplate3D gct = new GraphicsConfigTemplate3D();
    gct.setStereo(GraphicsConfigTemplate3D.PREFERRED);

    GraphicsConfiguration config = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice()
            .getBestConfiguration(gct);/*from   w w w.  j  av a  2 s . c  o m*/

    canvas = new Canvas3D(config);
    Map map = canvas.queryProperties();

    stereoSupport = canvas.getStereoAvailable();

    if (stereoSupport) {
        System.out.println(
                "This machine support stereo, you should see a red cone on the left and green cone on the right.");
        // User can overide the above default behavior using
        // java3d property.
        String str = System.getProperty("j3d.sharedstereozbuffer", defaultSharedStereoZbuffer);
        sharedStereoZbuffer = (new Boolean(str)).booleanValue();
    } else {
        System.out.println("Stereo is not support, you should only see the left red cone.");
    }

    if (!canvas.getDoubleBufferAvailable()) {
        System.out.println("Double buffer is not support !");
    }

    // we must stop the Renderer in PureImmediate mode
    canvas.stopRenderer();
    add("Center", canvas);

    // Create the universe and viewing branch
    u = new SimpleUniverse(canvas);

    // This will move the ViewPlatform back a bit so the
    // objects in the scene can be viewed.
    u.getViewingPlatform().setNominalViewingTransform();

    // Start a new thread that will continuously render
    (new Thread(this)).start();
}

From source file:MainClass.java

public void actionPerformed(ActionEvent e) {
    JTextPane editor = (JTextPane) getEditor(e);
    int p0 = editor.getSelectionStart();
    StyledDocument doc = getStyledDocument(editor);
    Element paragraph = doc.getCharacterElement(p0);
    AttributeSet as = paragraph.getAttributes();

    family = StyleConstants.getFontFamily(as);
    fontSize = StyleConstants.getFontSize(as);

    formatText = new JDialog(new JFrame(), "Font and Size", true);
    formatText.getContentPane().setLayout(new BorderLayout());

    JPanel choosers = new JPanel();
    choosers.setLayout(new GridLayout(2, 1));

    JPanel fontFamilyPanel = new JPanel();
    fontFamilyPanel.add(new JLabel("Font"));

    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    String[] fontNames = ge.getAvailableFontFamilyNames();

    fontFamilyChooser = new JComboBox();
    for (int i = 0; i < fontNames.length; i++) {
        fontFamilyChooser.addItem(fontNames[i]);
    }/*w w  w .  j  a v a2  s. c  om*/
    fontFamilyChooser.setSelectedItem(family);
    fontFamilyPanel.add(fontFamilyChooser);
    choosers.add(fontFamilyPanel);

    JPanel fontSizePanel = new JPanel();
    fontSizePanel.add(new JLabel("Size"));
    fontSizeChooser = new JComboBox();
    fontSizeChooser.setEditable(true);
    fontSizeChooser.addItem(new Float(4));
    fontSizeChooser.addItem(new Float(8));
    fontSizeChooser.addItem(new Float(12));
    fontSizeChooser.addItem(new Float(16));
    fontSizeChooser.addItem(new Float(20));
    fontSizeChooser.addItem(new Float(24));
    fontSizeChooser.setSelectedItem(new Float(fontSize));
    fontSizePanel.add(fontSizeChooser);
    choosers.add(fontSizePanel);

    JButton ok = new JButton("OK");
    ok.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            accept = true;
            formatText.dispose();
            family = (String) fontFamilyChooser.getSelectedItem();
            fontSize = Float.parseFloat(fontSizeChooser.getSelectedItem().toString());
        }
    });

    JButton cancel = new JButton("Cancel");
    cancel.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            formatText.dispose();
        }
    });

    JPanel buttons = new JPanel();
    buttons.add(ok);
    buttons.add(cancel);
    formatText.getContentPane().add(choosers, BorderLayout.CENTER);
    formatText.getContentPane().add(buttons, BorderLayout.SOUTH);
    formatText.pack();
    formatText.setVisible(true);

    MutableAttributeSet attr = null;
    if (editor != null && accept) {
        attr = new SimpleAttributeSet();
        StyleConstants.setFontFamily(attr, family);
        StyleConstants.setFontSize(attr, (int) fontSize);
        setCharacterAttributes(editor, attr, false);
    }

}

From source file:org.pmedv.core.gui.ApplicationWindowAdvisorImpl.java

@Override
public void postWindowCreate() {

    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    Rectangle frame = win.getBounds();

    ApplicationWindowConfiguration config = windowConfig.getConfig();

    if (config.getX() > 0 && config.getY() > 0) {
        win.setLocation(config.getX(), config.getY());
    } else {//from   w w w . j  a v a 2 s.c  om
        win.setLocation((screen.width - frame.width) / 2, (screen.height - frame.height) / 2);
        Rectangle bounds = new Rectangle(0, 0, screen.width, screen.height - 35);
        win.setBounds(bounds);
    }
    if (config.getHeight() > 0 && config.getWidth() > 0) {
        if (config.isMaximized())
            win.setExtendedState(win.getExtendedState() | Frame.MAXIMIZED_BOTH);
        else
            win.setSize(config.getWidth(), config.getHeight());
    } else {
        GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
        numberOfDisplays = env.getScreenDevices().length;
        win.setMaximizedBounds(env.getMaximumWindowBounds());
        win.setExtendedState(win.getExtendedState() | Frame.MAXIMIZED_BOTH);
    }
    //      if (!config.isStatusbarVisible())
    //         win.getStatusBar().setVisible(false);

}

From source file:org.tinymediamanager.ui.settings.GeneralSettingsPanel.java

/**
 * Instantiates a new general settings panel.
 *//*from  www .  j a v  a  2 s .  c om*/
public GeneralSettingsPanel() {
    setLayout(new FormLayout(
            new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("left:max(200px;min):grow"),
                    FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("max(200px;default):grow"),
                    FormSpecs.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC,
                    FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.RELATED_GAP_ROWSPEC, }));

    JPanel panelUI = new JPanel();
    panelUI.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.ui"), TitledBorder.LEADING, //$NON-NLS-1$
            TitledBorder.TOP, null, null));
    add(panelUI, "2, 2, 3, 1, fill, fill");
    panelUI.setLayout(new FormLayout(
            new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
                    FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("100dlu"), FormSpecs.RELATED_GAP_COLSPEC,
                    ColumnSpec.decode("default:grow"), FormSpecs.UNRELATED_GAP_COLSPEC,
                    FormSpecs.DEFAULT_COLSPEC, FormSpecs.UNRELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
                    FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC,
                    ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC,
                    FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.RELATED_GAP_ROWSPEC, }));
    LocaleComboBox actualLocale = null;
    // cbLanguage = new JComboBox(Utils.getLanguages().toArray());
    Locale settingsLang = Utils.getLocaleFromLanguage(Globals.settings.getLanguage());
    for (Locale l : Utils.getLanguages()) {
        LocaleComboBox localeComboBox = new LocaleComboBox(l);
        locales.add(localeComboBox);
        if (l.equals(settingsLang)) {
            actualLocale = localeComboBox;
        }
    }

    JLabel lblUiLanguage = new JLabel(BUNDLE.getString("Settings.language"));
    panelUI.add(lblUiLanguage, "2, 2");
    cbLanguage = new JComboBox(locales.toArray());
    panelUI.add(cbLanguage, "4, 2");

    if (actualLocale != null) {
        cbLanguage.setSelectedItem(actualLocale);
    }

    JSeparator separator = new JSeparator();
    separator.setOrientation(SwingConstants.VERTICAL);
    panelUI.add(separator, "8, 2, 1, 7");

    JLabel lblFontFamily = new JLabel(BUNDLE.getString("Settings.fontfamily")); //$NON-NLS-1$
    panelUI.add(lblFontFamily, "10, 2, right, default");
    GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
    cbFontFamily = new JComboBox(env.getAvailableFontFamilyNames());
    cbFontFamily.setSelectedItem(Globals.settings.getFontFamily());
    int index = cbFontFamily.getSelectedIndex();
    if (index < 0) {
        cbFontFamily.setSelectedItem("Dialog");
        index = cbFontFamily.getSelectedIndex();
    }
    if (index < 0) {
        cbFontFamily.setSelectedIndex(0);
    }
    panelUI.add(cbFontFamily, "12, 2, fill, default");

    JLabel lblFontSize = new JLabel(BUNDLE.getString("Settings.fontsize")); //$NON-NLS-1$
    panelUI.add(lblFontSize, "10, 4, right, default");

    cbFontSize = new JComboBox(DEFAULT_FONT_SIZES);
    cbFontSize.setSelectedItem(Globals.settings.getFontSize());
    index = cbFontSize.getSelectedIndex();
    if (index < 0) {
        cbFontSize.setSelectedIndex(0);
    }

    panelUI.add(cbFontSize, "12, 4, fill, default");

    JPanel panel = new JPanel();
    panelUI.add(panel, "2, 6, 5, 1, fill, fill");
    panel.setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC,
            ColumnSpec.decode("100dlu"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), },
            new RowSpec[] { FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC,
                    FormSpecs.DEFAULT_ROWSPEC, }));

    JLabel lblMissingTranslation = new JLabel(BUNDLE.getString("tmm.helptranslate"));
    panel.add(lblMissingTranslation, "1, 1, 5, 1");

    lblLinkTransifex = new LinkLabel("https://www.transifex.com/projects/p/tinymediamanager/");
    panel.add(lblLinkTransifex, "1, 3, 5, 1");
    lblLinkTransifex.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            try {
                TmmUIHelper.browseUrl(lblLinkTransifex.getNormalText());
            } catch (Exception e) {
                LOGGER.error(e.getMessage());
                MessageManager.instance
                        .pushMessage(new Message(MessageLevel.ERROR, lblLinkTransifex.getNormalText(),
                                "message.erroropenurl", new String[] { ":", e.getLocalizedMessage() }));//$NON-NLS-2$
            }
        }
    });

    tpFontHint = new JTextPane();
    tpFontHint.setOpaque(false);
    TmmFontHelper.changeFont(tpFontHint, 0.833);
    tpFontHint.setText(BUNDLE.getString("Settings.fonts.hint")); //$NON-NLS-1$
    panelUI.add(tpFontHint, "10, 6, 5, 1");

    lblLanguageHint = new JLabel("");
    TmmFontHelper.changeFont(lblLanguageHint, Font.BOLD);
    panelUI.add(lblLanguageHint, "2, 8, 5, 1");

    lblFontChangeHint = new JLabel("");
    TmmFontHelper.changeFont(lblFontChangeHint, Font.BOLD);
    panelUI.add(lblFontChangeHint, "10, 8, 5, 1");

    JPanel panelMemory = new JPanel();
    panelMemory.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.memoryborder"), //$NON-NLS-1$
            TitledBorder.LEADING, TitledBorder.TOP, null, null));
    add(panelMemory, "2, 4, fill, fill");
    panelMemory.setLayout(new FormLayout(
            new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC,
                    FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("250px:grow(4)"),
                    FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("max(20dlu;default)"),
                    ColumnSpec.decode("left:default:grow(5)"), },
            new RowSpec[] { FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC,
                    RowSpec.decode("default:grow"), FormFactory.RELATED_GAP_ROWSPEC, }));

    JLabel lblMemoryT = new JLabel(BUNDLE.getString("Settings.memory")); //$NON-NLS-1$
    panelMemory.add(lblMemoryT, "2, 1");

    sliderMemory = new JSlider();
    sliderMemory.setPaintLabels(true);
    sliderMemory.setPaintTicks(true);
    sliderMemory.setSnapToTicks(true);
    sliderMemory.setMajorTickSpacing(512);
    sliderMemory.setMinorTickSpacing(128);
    sliderMemory.setMinimum(256);
    sliderMemory.setMaximum(1536);
    sliderMemory.setValue(512);
    panelMemory.add(sliderMemory, "4, 1, fill, default");

    lblMemory = new JLabel("512"); //$NON-NLS-1$
    panelMemory.add(lblMemory, "6, 1, right, default");

    JLabel lblMb = new JLabel("MB");
    panelMemory.add(lblMb, "7, 1, left, default");

    tpMemoryHint = new JTextPane();
    tpMemoryHint.setOpaque(false);
    tpMemoryHint.setText(BUNDLE.getString("Settings.memory.hint")); //$NON-NLS-1$
    TmmFontHelper.changeFont(tpMemoryHint, 0.833);
    panelMemory.add(tpMemoryHint, "2, 3, 6, 1, fill, fill");

    JPanel panelProxySettings = new JPanel();
    panelProxySettings.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.proxy"), //$NON-NLS-1$
            TitledBorder.LEADING, TitledBorder.TOP, null, null));
    add(panelProxySettings, "4, 4, fill, fill");
    panelProxySettings.setLayout(new FormLayout(
            new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC,
                    FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), },
            new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                    FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                    FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                    FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                    FormFactory.RELATED_GAP_ROWSPEC, }));

    JLabel lblProxyHost = new JLabel(BUNDLE.getString("Settings.proxyhost")); //$NON-NLS-1$
    panelProxySettings.add(lblProxyHost, "2, 2, right, default");

    tfProxyHost = new JTextField();
    lblProxyHost.setLabelFor(tfProxyHost);
    panelProxySettings.add(tfProxyHost, "4, 2, fill, default");
    tfProxyHost.setColumns(10);

    JLabel lblProxyPort = new JLabel(BUNDLE.getString("Settings.proxyport")); //$NON-NLS-1$
    panelProxySettings.add(lblProxyPort, "2, 4, right, default");

    tfProxyPort = new JTextField();
    lblProxyPort.setLabelFor(tfProxyPort);
    panelProxySettings.add(tfProxyPort, "4, 4, fill, default");
    tfProxyPort.setColumns(10);

    JLabel lblProxyUser = new JLabel(BUNDLE.getString("Settings.proxyuser")); //$NON-NLS-1$
    panelProxySettings.add(lblProxyUser, "2, 6, right, default");

    tfProxyUsername = new JTextField();
    lblProxyUser.setLabelFor(tfProxyUsername);
    panelProxySettings.add(tfProxyUsername, "4, 6, fill, default");
    tfProxyUsername.setColumns(10);

    JLabel lblProxyPassword = new JLabel(BUNDLE.getString("Settings.proxypass")); //$NON-NLS-1$
    panelProxySettings.add(lblProxyPassword, "2, 8, right, default");

    tfProxyPassword = new JPasswordField();
    lblProxyPassword.setLabelFor(tfProxyPassword);
    panelProxySettings.add(tfProxyPassword, "4, 8, fill, default");

    JPanel panelMediaPlayer = new JPanel();
    panelMediaPlayer.setBorder(
            new TitledBorder(null, "MediaPlayer", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    add(panelMediaPlayer, "2, 6, fill, fill");
    panelMediaPlayer.setLayout(new FormLayout(
            new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"),
                    FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.RELATED_GAP_ROWSPEC, }));

    tpMediaPlayer = new JTextPane();
    tpMediaPlayer.setOpaque(false);
    TmmFontHelper.changeFont(tpMediaPlayer, 0.833);
    tpMediaPlayer.setText(BUNDLE.getString("Settings.mediaplayer.hint")); //$NON-NLS-1$
    panelMediaPlayer.add(tpMediaPlayer, "2, 2, 3, 1, fill, fill");

    tfMediaPlayer = new JTextField();
    panelMediaPlayer.add(tfMediaPlayer, "2, 4, fill, default");
    tfMediaPlayer.setColumns(10);

    btnSearchMediaPlayer = new JButton(BUNDLE.getString("Button.chooseplayer")); //$NON-NLS-1$
    btnSearchMediaPlayer.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            Path file = TmmUIHelper.selectFile(BUNDLE.getString("Button.chooseplayer")); //$NON-NLS-1$
            if (file != null && Utils.isRegularFile(file) || Platform.isMac()) {
                tfMediaPlayer.setText(file.toAbsolutePath().toString());
            }
        }
    });
    panelMediaPlayer.add(btnSearchMediaPlayer, "4, 4");

    JPanel panelCache = new JPanel();
    panelCache.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.cache"), TitledBorder.LEADING, //$NON-NLS-1$
            TitledBorder.TOP, null, null));
    add(panelCache, "4, 6, fill, fill");
    panelCache.setLayout(new FormLayout(
            new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
                    FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"),
                    FormSpecs.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.RELATED_GAP_ROWSPEC, }));

    chckbxImageCache = new JCheckBox(BUNDLE.getString("Settings.imagecache"));//$NON-NLS-1$
    panelCache.add(chckbxImageCache, "2, 2, 3, 1");

    JLabel lblImageCacheQuality = new JLabel(BUNDLE.getString("Settings.imagecachetype"));//$NON-NLS-1$
    panelCache.add(lblImageCacheQuality, "2, 4, right, default");

    cbImageCacheQuality = new JComboBox(ImageCache.CacheType.values());
    panelCache.add(cbImageCacheQuality, "4, 4, fill, default");

    JPanel panelAnalytics = new JPanel();
    panelAnalytics.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.analytics.border"), //$NON-NLS-1$
            TitledBorder.LEADING, TitledBorder.TOP, null, null));
    add(panelAnalytics, "2, 8, fill, fill");
    panelAnalytics.setLayout(new FormLayout(
            new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"),
                    FormSpecs.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LINE_GAP_ROWSPEC, }));

    chckbxAnalytics = new JCheckBox(BUNDLE.getString("Settings.analytics"));//$NON-NLS-1$
    panelAnalytics.add(chckbxAnalytics, "2, 2");

    JTextPane tpAnalyticsDescription = new JTextPane();
    tpAnalyticsDescription.setText(BUNDLE.getString("Settings.analytics.desc"));//$NON-NLS-1$
    tpAnalyticsDescription.setOpaque(false);
    panelAnalytics.add(tpAnalyticsDescription, "2, 4, fill, fill");

    JPanel panelMisc = new JPanel();
    panelMisc.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.misc"), TitledBorder.LEADING, //$NON-NLS-1$
            TitledBorder.TOP, null, null));
    add(panelMisc, "4, 8, fill, fill");
    panelMisc.setLayout(new FormLayout(
            new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC,
                    FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"),
                    FormFactory.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                    FormFactory.RELATED_GAP_ROWSPEC, }));

    chckbxDeleteTrash = new JCheckBox(BUNDLE.getString("Settings.deletetrash"));
    panelMisc.add(chckbxDeleteTrash, "2, 2, 3, 1");

    initDataBindings();

    initMemorySlider();

    // listen to changes of the combo box
    ItemListener listener = new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            checkChanges();
        }
    };

    cbLanguage.addItemListener(listener);
    cbFontSize.addItemListener(listener);
    cbFontFamily.addItemListener(listener);
}

From source file:org.dishevelled.brainstorm.BrainStorm.java

/**
 * Choose an installed font name from a list of preferred font names.
 *//*from   w  w  w.j  av  a2  s. co  m*/
private String chooseFontName() {
    List<String> preferredNames = Arrays
            .asList(new String[] { "Luxi Sans", "Calibri", "Corbel", "Lucida Sans Unicode", "Lucida Grande" });
    List<String> actualNames = Arrays
            .asList(GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames());
    for (String actual : actualNames) {
        if ((fontName != null) && (fontName.equalsIgnoreCase(actual))) {
            return actual;
        }
    }
    for (String actual : actualNames) {
        for (String preferred : preferredNames) {
            if (preferred.equalsIgnoreCase(actual)) {
                return actual;
            }
        }
    }
    return "Dialog";
}

From source file:Utilities.java

/**
 * Returns the usable area of the screen where applications can place its
 * windows.  The method subtracts from the screen the area of taskbars,
 * system menus and the like./*from  w w  w .ja v  a2s  .c o m*/
 *
 * @param gconf the GraphicsConfiguration of the monitor
 * @return the rectangle of the screen where one can place windows
 *
 * @since 2.5
 */
public static Rectangle getUsableScreenBounds(GraphicsConfiguration gconf) {
    if (gconf == null) {
        gconf = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice()
                .getDefaultConfiguration();
    }

    Rectangle bounds = new Rectangle(gconf.getBounds());

    String str;

    str = System.getProperty("netbeans.screen.insets"); // NOI18N

    if (str != null) {
        StringTokenizer st = new StringTokenizer(str, ", "); // NOI18N

        if (st.countTokens() == 4) {
            try {
                bounds.y = Integer.parseInt(st.nextToken());
                bounds.x = Integer.parseInt(st.nextToken());
                bounds.height -= (bounds.y + Integer.parseInt(st.nextToken()));
                bounds.width -= (bounds.x + Integer.parseInt(st.nextToken()));
            } catch (NumberFormatException ex) {
                Logger.getAnonymousLogger().log(Level.WARNING, null, ex);
            }
        }

        return bounds;
    }

    str = System.getProperty("netbeans.taskbar.height"); // NOI18N

    if (str != null) {
        bounds.height -= Integer.getInteger(str, 0).intValue();

        return bounds;
    }

    try {
        Toolkit toolkit = Toolkit.getDefaultToolkit();
        Insets insets = toolkit.getScreenInsets(gconf);
        bounds.y += insets.top;
        bounds.x += insets.left;
        bounds.height -= (insets.top + insets.bottom);
        bounds.width -= (insets.left + insets.right);
    } catch (Exception ex) {
        Logger.getAnonymousLogger().log(Level.WARNING, null, ex);
    }

    return bounds;
}

From source file:de.ifsr.adam.ImageGenerator.java

/**
 * Main method for generating an Preview out of a report with it results.
 *
 * @param resultReport The report with it results
 * @return returns true if the generation and saving of the image was successful, false
 * otherwise//from   w w  w  . j  a v  a  2  s.co  m
 */
public Scene generatePreview(JSONArray resultReport) {
    log.info("Preview generation has started");
    VBox vbox = generateImageVBox(resultReport);

    ScrollPane scrollPane = new ScrollPane();
    scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.ALWAYS);
    scrollPane.setContent(vbox);

    //Gets the screen resulution for scaling.
    GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
    int width = gd.getDisplayMode().getWidth();
    int height = gd.getDisplayMode().getHeight();

    scrollPane.setVmax(100.0);
    scrollPane.setPrefSize(width * 0.65, height * 0.8); //TODO Can I do this better?

    ((Group) scene.getRoot()).getChildren().add(scrollPane);
    scene.getStylesheets().add(this.stylesheetURI.toString());

    //The Observer for resizing the scrollpane when the window changes.
    scene.widthProperty().addListener(new ChangeListener<Number>() {
        @Override
        public void changed(ObservableValue<? extends Number> observableValue, Number oldSceneWidth,
                Number newSceneWidth) {
            scrollPane.setPrefWidth(newSceneWidth.doubleValue());
        }
    });

    //The Observer for resizing the scrollpane when the window changes.
    scene.heightProperty().addListener(new ChangeListener<Number>() {
        @Override
        public void changed(ObservableValue<? extends Number> observableValue, Number oldSceneHeight,
                Number newSceneHeight) {
            scrollPane.setPrefHeight(newSceneHeight.doubleValue());
        }
    });

    log.info("End of Preview generation");
    return scene;
}

From source file:eulermind.Style.java

public static ArrayList<String> getFontFamilies() {
    ArrayList<String> fontFamilies = new ArrayList<String>();
    for (String family : GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames()) {
        Font font = new Font(family, Font.PLAIN, 1);
        if (font.canDisplay('a')) {
            fontFamilies.add(family);/*from w w  w.ja v  a 2 s.co m*/
        }
    }

    return fontFamilies;
}

From source file:pcgen.gui2.PCGenFrame.java

/**
 * This checks to make sure that the given rectangle will be visible
 * on the current graphics environment/*from   ww  w  .j av  a2 s.  co m*/
 */
private boolean checkBounds(Rectangle rect) {
    if (rect.isEmpty()) {
        return false;
    }
    GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();

    for (GraphicsDevice device : env.getScreenDevices()) {
        Rectangle bounds = device.getDefaultConfiguration().getBounds();
        if (bounds.contains(rect) || bounds.intersects(rect)) {
            return true;
        }
    }
    return false;
}

From source file:com.haulmont.cuba.desktop.gui.components.SwingXTableSettings.java

protected void loadFontPreferences(Element element) {
    // load font preferences
    String fontFamily = element.attributeValue("fontFamily");
    String fontSize = element.attributeValue("fontSize");
    String fontStyle = element.attributeValue("fontStyle");
    String fontUnderline = element.attributeValue("fontUnderline");
    if (!StringUtils.isBlank(fontFamily) && !StringUtils.isBlank(fontSize)
            && !StringUtils.isBlank(fontUnderline) && !StringUtils.isBlank(fontStyle)) {

        try {//from ww w.j  av  a2s  . com
            int size = Integer.parseInt(fontSize);
            int style = Integer.parseInt(fontStyle);

            String[] availableFonts = GraphicsEnvironment.getLocalGraphicsEnvironment()
                    .getAvailableFontFamilyNames();
            int fontIndex = Arrays.asList(availableFonts).indexOf(fontFamily);
            if (fontIndex < 0) {
                log.debug("Unsupported font family, font settings not loaded");
                return;
            }

            Configuration configuration = AppBeans.get(Configuration.NAME);
            DesktopConfig desktopConfig = configuration.getConfig(DesktopConfig.class);
            int sizeIndex = desktopConfig.getAvailableFontSizes().indexOf(size);

            if (sizeIndex < 0) {
                log.debug("Unsupported font size, font settings not loaded");
                return;
            }

            Boolean underline = BooleanUtils.toBooleanObject(fontUnderline);

            @SuppressWarnings("MagicConstant")
            Font font = new Font(fontFamily, style, size);
            if (underline != null && Boolean.TRUE.equals(underline)) {
                Map<TextAttribute, Integer> attributes = new HashMap<>();
                attributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
                font = font.deriveFont(attributes);
            }
            table.setFont(font);
        } catch (NumberFormatException ex) {
            log.debug("Broken font definition in user setting");
        }
    }
}