Example usage for javax.swing Box createGlue

List of usage examples for javax.swing Box createGlue

Introduction

In this page you can find the example usage for javax.swing Box createGlue.

Prototype

public static Component createGlue() 

Source Link

Document

Creates an invisible "glue" component that can be useful in a Box whose visible components have a maximum width (for a horizontal box) or height (for a vertical box).

Usage

From source file:net.sf.jabref.gui.JabRefFrame.java

private void initLayout() {
    tabbedPane.putClientProperty(Options.NO_CONTENT_BORDER_KEY, Boolean.TRUE);

    setProgressBarVisible(false);/*from  w ww .  j  a  v  a2s  . c o  m*/

    pushExternalButton = new PushToApplicationButton(this, PushToApplications.getApplications());
    fillMenu();
    createToolBar();
    getContentPane().setLayout(gbl);
    splitPane.setDividerSize(2);
    splitPane.setBorder(null);
    //getContentPane().setBackground(GUIGlobals.lightGray);
    con.fill = GridBagConstraints.HORIZONTAL;
    con.anchor = GridBagConstraints.WEST;
    con.weightx = 1;
    con.weighty = 0;
    con.gridwidth = GridBagConstraints.REMAINDER;

    //gbl.setConstraints(mb, con);
    //getContentPane().add(mb);
    setJMenuBar(mb);
    con.anchor = GridBagConstraints.NORTH;
    //con.gridwidth = 1;//GridBagConstraints.REMAINDER;;
    gbl.setConstraints(tlb, con);
    getContentPane().add(tlb);

    Component lim = Box.createGlue();
    gbl.setConstraints(lim, con);
    //getContentPane().add(lim);
    /*
      JPanel empt = new JPanel();
      empt.setBackground(GUIGlobals.lightGray);
      gbl.setConstraints(empt, con);
       getContentPane().add(empt);
            
      con.insets = new Insets(1,0,1,1);
      con.anchor = GridBagConstraints.EAST;
      con.weightx = 0;
      gbl.setConstraints(searchManager, con);
      getContentPane().add(searchManager);*/
    con.gridwidth = GridBagConstraints.REMAINDER;
    con.weightx = 1;
    con.weighty = 0;
    con.fill = GridBagConstraints.BOTH;
    con.anchor = GridBagConstraints.WEST;
    con.insets = new Insets(0, 0, 0, 0);
    lim = Box.createGlue();
    gbl.setConstraints(lim, con);
    getContentPane().add(lim);
    //tabbedPane.setVisible(false);
    //tabbedPane.setForeground(GUIGlobals.lightGray);
    con.weighty = 1;
    gbl.setConstraints(splitPane, con);
    getContentPane().add(splitPane);

    UIManager.put("TabbedPane.contentBorderInsets", new Insets(0, 0, 0, 0));

    splitPane.setRightComponent(tabbedPane);
    splitPane.setLeftComponent(sidePaneManager.getPanel());
    sidePaneManager.updateView();

    JPanel status = new JPanel();
    status.setLayout(gbl);
    con.weighty = 0;
    con.weightx = 0;
    con.gridwidth = 1;
    con.insets = new Insets(0, 2, 0, 0);
    gbl.setConstraints(statusLabel, con);
    status.add(statusLabel);
    con.weightx = 1;
    con.insets = new Insets(0, 4, 0, 0);
    con.gridwidth = 1;
    gbl.setConstraints(statusLine, con);
    status.add(statusLine);
    con.weightx = 0;
    con.gridwidth = GridBagConstraints.REMAINDER;
    con.insets = new Insets(2, 4, 2, 2);
    gbl.setConstraints(progressBar, con);
    status.add(progressBar);
    con.weightx = 1;
    con.gridwidth = GridBagConstraints.REMAINDER;
    statusLabel.setForeground(GUIGlobals.ENTRY_EDITOR_LABEL_COLOR.darker());
    con.insets = new Insets(0, 0, 0, 0);
    gbl.setConstraints(status, con);
    getContentPane().add(status);

    // Drag and drop for tabbedPane:
    TransferHandler xfer = new EntryTableTransferHandler(null, this, null);
    tabbedPane.setTransferHandler(xfer);
    tlb.setTransferHandler(xfer);
    mb.setTransferHandler(xfer);
    sidePaneManager.getPanel().setTransferHandler(xfer);
}

From source file:de.bwravencl.controllerbuddy.gui.Main.java

void updateModesPanel() {
    if (modesListPanel == null)
        return;/*from   w  w  w.  j  a v a 2  s .co  m*/

    modesListPanel.removeAll();

    final var modes = input.getProfile().getModes();
    for (var i = 0; i < modes.size(); i++) {
        final var mode = modes.get(i);

        final var modePanel = new JPanel(new GridBagLayout());
        modesListPanel.add(modePanel,
                new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0,
                        GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,
                        new Insets(0, 0, 0, 0), 0, 5));

        final var modeNoLabel = new JLabel(rb.getString("MODE_NO_LABEL_PREFIX") + (i + 1));
        modeNoLabel.setPreferredSize(new Dimension(100, 15));
        modePanel.add(modeNoLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.BASELINE,
                GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));

        modePanel.add(Box.createGlue(), new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 1.0, 1.0,
                GridBagConstraints.BASELINE, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));

        final var descriptionTextField = new JTextField(mode.getDescription(), 20);
        modePanel.add(descriptionTextField, new GridBagConstraints(2, 0, 1, 1, 1.0, 1.0,
                GridBagConstraints.BASELINE, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));

        final var setModeDescriptionAction = new SetModeDescriptionAction(mode, descriptionTextField);
        descriptionTextField.addActionListener(setModeDescriptionAction);
        descriptionTextField.getDocument().addDocumentListener(setModeDescriptionAction);

        modePanel.add(Box.createGlue(), new GridBagConstraints(3, GridBagConstraints.RELATIVE, 1, 1, 1.0, 1.0,
                GridBagConstraints.BASELINE, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));

        if (Profile.defaultMode.equals(mode) || OnScreenKeyboard.onScreenKeyboardMode.equals(mode)) {
            descriptionTextField.setEditable(false);
            modePanel.add(Box.createHorizontalStrut(BUTTON_DIMENSION.width));
        } else {
            final var deleteButton = new JButton(new RemoveModeAction(mode));
            deleteButton.setPreferredSize(BUTTON_DIMENSION);
            modePanel.add(deleteButton, new GridBagConstraints(4, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0,
                    GridBagConstraints.BASELINE, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
        }
    }

    modesListPanel.add(Box.createGlue(), new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 1.0,
            GridBagConstraints.FIRST_LINE_START, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));

    modesScrollPane.setViewportView(modesListPanel);
}

From source file:de.bwravencl.controllerbuddy.gui.Main.java

private void updateOverlayPanel() {
    if (indicatorsListPanel == null)
        return;//from  w  w  w .  j  av  a 2 s.com

    indicatorsListPanel.removeAll();

    for (final var virtualAxis : Input.VirtualAxis.values()) {
        final var indicatorPanel = new JPanel(new GridBagLayout());
        indicatorsListPanel.add(indicatorPanel,
                new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0,
                        GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,
                        new Insets(0, 0, 0, 0), 0, 5));

        final var virtualAxisLabel = new JLabel(virtualAxis.toString() + rb.getString("AXIS_LABEL_SUFFIX"));
        virtualAxisLabel.setPreferredSize(new Dimension(100, 15));
        indicatorPanel.add(virtualAxisLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
                GridBagConstraints.BASELINE, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));

        final var virtualAxisToOverlayAxisMap = input.getProfile().getVirtualAxisToOverlayAxisMap();
        final var overlayAxis = virtualAxisToOverlayAxisMap.get(virtualAxis);
        final var enabled = overlayAxis != null;

        final var colorLabel = new JLabel();
        if (enabled) {
            colorLabel.setOpaque(true);
            colorLabel.setBackground(overlayAxis.color);
        } else
            colorLabel.setText(rb.getString("INDICATOR_DISABLED_LABEL"));
        colorLabel.setHorizontalAlignment(SwingConstants.CENTER);

        colorLabel.setPreferredSize(new Dimension(100, 15));
        colorLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
        indicatorPanel.add(colorLabel, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.BASELINE,
                GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));

        final var colorButton = new JButton(new SelectIndicatorColorAction(virtualAxis));
        colorButton.setPreferredSize(BUTTON_DIMENSION);
        colorButton.setEnabled(enabled);
        indicatorPanel.add(colorButton, new GridBagConstraints(2, 0, 1, 1, 1.0, 0.0,
                GridBagConstraints.BASELINE, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));

        final var invertedCheckBox = new JCheckBox(new InvertIndicatorAction(virtualAxis));
        invertedCheckBox.setSelected(enabled && overlayAxis.inverted);
        invertedCheckBox.setEnabled(enabled);
        indicatorPanel.add(invertedCheckBox, new GridBagConstraints(3, 0, 1, 1, 1.0, 0.0,
                GridBagConstraints.BASELINE, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));

        final var displayCheckBox = new JCheckBox(new DisplayIndicatorAction(virtualAxis));
        displayCheckBox.setSelected(enabled);
        indicatorPanel.add(displayCheckBox, new GridBagConstraints(4, GridBagConstraints.RELATIVE, 1, 1, 0.0,
                0.0, GridBagConstraints.BASELINE, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    }

    indicatorsListPanel.add(Box.createGlue(), new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0,
            1.0, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));

    indicatorsScrollPane.setViewportView(indicatorsListPanel);
}

From source file:com.diversityarrays.kdxplore.curate.TrialDataEditor.java

@Override
public JToolBar getJToolBar() {

    if (toolBar == null) {

        JToolBar tbar = new JToolBar("Curation Toolbar");
        tbar.add(makeToolbarButton(saveChangesAction));
        tbar.add(makeToolbarButton(exportCuratedData));

        tbar.addSeparator();//from w  ww  . j  av a  2  s . c  o m

        tbar.add(makeToolbarButton(undoAction));
        tbar.add(makeToolbarButton(redoAction));

        tbar.addSeparator();

        for (JButton button : createVisualisationButtons()) {
            button.setText(null);
            tbar.add(button);
        }

        tbar.addSeparator();

        tbar.add(showFieldViewButton);

        tbar.add(Box.createGlue());
        toolBar = tbar;
    }

    return toolBar;
}

From source file:net.technicpack.launcher.ui.InstallerFrame.java

private void setupStandardInstall(JPanel panel) {
    panel.setLayout(new GridBagLayout());

    JLabel standardSpiel = new JLabel("<html><body align=\"left\" style='margin-right:10px;'>"
            + resources.getString("launcher.installer.standardspiel") + "</body></html>");
    standardSpiel.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 16));
    standardSpiel.setForeground(LauncherFrame.COLOR_WHITE_TEXT);
    standardSpiel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    panel.add(standardSpiel, new GridBagConstraints(0, 0, 3, 1, 1.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(9, 0, 0, 3), 0, 0));

    panel.add(Box.createGlue(), new GridBagConstraints(0, 1, 3, 1, 1.0, 0.7, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));

    standardDefaultDirectory = new JCheckBox(resources.getString("launcher.installer.default"));
    standardDefaultDirectory.setOpaque(false);
    standardDefaultDirectory.setHorizontalAlignment(SwingConstants.RIGHT);
    standardDefaultDirectory.setBorder(BorderFactory.createEmptyBorder());
    standardDefaultDirectory.setIconTextGap(0);
    standardDefaultDirectory.setSelectedIcon(resources.getIcon("checkbox_closed.png"));
    standardDefaultDirectory.setIcon(resources.getIcon("checkbox_open.png"));
    standardDefaultDirectory.setFocusPainted(false);
    standardDefaultDirectory.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 16));
    standardDefaultDirectory.setForeground(LauncherFrame.COLOR_WHITE_TEXT);
    standardDefaultDirectory.setIconTextGap(6);
    standardDefaultDirectory.setSelected(settings.isPortable() || settings.getTechnicRoot().getAbsolutePath()
            .equals(SettingsFactory.getTechnicHomeDir().getAbsolutePath()));
    standardDefaultDirectory.addActionListener(new ActionListener() {
        @Override//from  ww w.  j a  v a 2 s.c o  m
        public void actionPerformed(ActionEvent e) {
            useDefaultDirectoryChanged();
        }
    });
    panel.add(standardDefaultDirectory, new GridBagConstraints(0, 2, 3, 1, 0, 0, GridBagConstraints.WEST,
            GridBagConstraints.NONE, new Insets(0, 24, 12, 0), 0, 0));

    JLabel installFolderLabel = new JLabel(resources.getString("launcher.installer.folder"));
    installFolderLabel.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 18));
    installFolderLabel.setForeground(LauncherFrame.COLOR_WHITE_TEXT);
    panel.add(installFolderLabel, new GridBagConstraints(0, 3, 1, 1, 0, 0, GridBagConstraints.WEST,
            GridBagConstraints.NONE, new Insets(0, 24, 0, 8), 0, 0));

    String installDir = SettingsFactory.getTechnicHomeDir().getAbsolutePath();

    if (!settings.isPortable())
        installDir = settings.getTechnicRoot().getAbsolutePath();

    standardInstallDir = new JTextField(installDir);
    standardInstallDir.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 18));
    standardInstallDir.setBackground(LauncherFrame.COLOR_FORMELEMENT_INTERNAL);
    standardInstallDir.setHighlighter(null);
    standardInstallDir.setEditable(false);
    standardInstallDir.setCursor(null);
    panel.add(standardInstallDir, new GridBagConstraints(1, 3, 1, 1, 1, 0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 5, 0, 5), 0, 0));

    standardSelectButton = new RoundedButton(resources.getString("launcher.installer.select"));
    standardSelectButton.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 18));
    standardSelectButton.setContentAreaFilled(false);
    standardSelectButton.setHoverForeground(LauncherFrame.COLOR_BLUE);
    standardSelectButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            selectStandard();
        }
    });
    panel.add(standardSelectButton, new GridBagConstraints(2, 3, 1, 1, 0, 0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 5, 0, 16), 0, 0));

    useDefaultDirectoryChanged();

    panel.add(Box.createGlue(), new GridBagConstraints(0, 4, 3, 1, 1.0, 1.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));

    String defaultLocaleText = resources.getString("launcheroptions.language.default");
    if (!resources.isDefaultLocaleSupported()) {
        defaultLocaleText = defaultLocaleText
                .concat(" (" + resources.getString("launcheroptions.language.unavailable") + ")");
    }

    standardLanguages = new JComboBox();
    standardLanguages.addItem(new LanguageItem(ResourceLoader.DEFAULT_LOCALE, defaultLocaleText, resources));
    for (int i = 0; i < ResourceLoader.SUPPORTED_LOCALES.length; i++) {
        standardLanguages
                .addItem(new LanguageItem(resources.getCodeFromLocale(ResourceLoader.SUPPORTED_LOCALES[i]),
                        ResourceLoader.SUPPORTED_LOCALES[i].getDisplayName(ResourceLoader.SUPPORTED_LOCALES[i]),
                        resources.getVariant(ResourceLoader.SUPPORTED_LOCALES[i])));
    }
    if (!settings.getLanguageCode().equalsIgnoreCase(ResourceLoader.DEFAULT_LOCALE)) {
        Locale loc = resources.getLocaleFromCode(settings.getLanguageCode());

        for (int i = 0; i < ResourceLoader.SUPPORTED_LOCALES.length; i++) {
            if (loc.equals(ResourceLoader.SUPPORTED_LOCALES[i])) {
                standardLanguages.setSelectedIndex(i + 1);
                break;
            }
        }
    }
    standardLanguages.setBorder(new RoundBorder(LauncherFrame.COLOR_SCROLL_THUMB, 1, 10));
    standardLanguages.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 14));
    standardLanguages.setUI(new LanguageCellUI(resources));
    standardLanguages.setForeground(LauncherFrame.COLOR_WHITE_TEXT);
    standardLanguages.setBackground(LauncherFrame.COLOR_SELECTOR_BACK);
    standardLanguages.setRenderer(new LanguageCellRenderer(resources, "globe.png",
            LauncherFrame.COLOR_SELECTOR_BACK, LauncherFrame.COLOR_WHITE_TEXT));
    standardLanguages.setEditable(false);
    standardLanguages.setFocusable(false);
    standardLanguages.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            standardLanguageChanged();
        }
    });
    panel.add(standardLanguages, new GridBagConstraints(0, 5, 1, 0, 0, 0, GridBagConstraints.SOUTHWEST,
            GridBagConstraints.NONE, new Insets(0, 8, 8, 0), 0, 0));

    RoundedButton install = new RoundedButton(resources.getString("launcher.installer.install"));
    install.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 18));
    install.setContentAreaFilled(false);
    install.setForeground(LauncherFrame.COLOR_BUTTON_BLUE);
    install.setHoverForeground(LauncherFrame.COLOR_BLUE);
    install.setBorder(BorderFactory.createEmptyBorder(8, 56, 8, 56));
    install.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            standardInstall();
        }
    });
    panel.add(install, new GridBagConstraints(1, 5, 2, 1, 0, 0, GridBagConstraints.EAST,
            GridBagConstraints.VERTICAL, new Insets(0, 0, 8, 8), 0, 0));

}

From source file:net.technicpack.launcher.ui.InstallerFrame.java

private void setupPortableMode(JPanel panel) {
    panel.setLayout(new GridBagLayout());

    JLabel portableSpiel = new JLabel("<html><body align=\"left\" style='margin-right:10px;'>"
            + resources.getString("launcher.installer.portablespiel") + "</body></html>");
    portableSpiel.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 16));
    portableSpiel.setForeground(LauncherFrame.COLOR_WHITE_TEXT);
    portableSpiel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    panel.add(portableSpiel, new GridBagConstraints(0, 0, 3, 1, 1.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(9, 8, 9, 3), 0, 0));

    panel.add(Box.createGlue(), new GridBagConstraints(0, 1, 3, 1, 1.0, 0.7, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));

    JLabel installFolderLabel = new JLabel(resources.getString("launcher.installer.folder"));
    installFolderLabel.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 18));
    installFolderLabel.setForeground(LauncherFrame.COLOR_WHITE_TEXT);
    panel.add(installFolderLabel, new GridBagConstraints(0, 2, 1, 1, 0, 0, GridBagConstraints.WEST,
            GridBagConstraints.NONE, new Insets(0, 24, 0, 8), 0, 0));

    String installDir = "";
    if (settings.isPortable())
        installDir = settings.getTechnicRoot().getAbsolutePath();

    portableInstallDir = new JTextField(installDir);
    portableInstallDir.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 18));
    portableInstallDir.setForeground(LauncherFrame.COLOR_BLUE);
    portableInstallDir.setBackground(LauncherFrame.COLOR_FORMELEMENT_INTERNAL);
    portableInstallDir.setHighlighter(null);
    portableInstallDir.setEditable(false);
    portableInstallDir.setCursor(null);//from www.j av  a2 s .com
    portableInstallDir.setBorder(new RoundBorder(LauncherFrame.COLOR_BUTTON_BLUE, 1, 8));
    panel.add(portableInstallDir, new GridBagConstraints(1, 2, 1, 1, 1, 0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 5, 0, 5), 0, 0));

    RoundedButton selectInstall = new RoundedButton(resources.getString("launcher.installer.select"));
    selectInstall.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 18));
    selectInstall.setContentAreaFilled(false);
    selectInstall.setForeground(LauncherFrame.COLOR_BUTTON_BLUE);
    selectInstall.setHoverForeground(LauncherFrame.COLOR_BLUE);
    selectInstall.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            selectPortable();
        }
    });
    panel.add(selectInstall, new GridBagConstraints(2, 2, 1, 1, 0, 0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 5, 0, 16), 0, 0));

    panel.add(Box.createGlue(), new GridBagConstraints(0, 3, 3, 1, 1.0, 1.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));

    String defaultLocaleText = resources.getString("launcheroptions.language.default");
    if (!resources.isDefaultLocaleSupported()) {
        defaultLocaleText = defaultLocaleText
                .concat(" (" + resources.getString("launcheroptions.language.unavailable") + ")");
    }

    portableLanguages = new JComboBox();
    portableLanguages.addItem(new LanguageItem(ResourceLoader.DEFAULT_LOCALE, defaultLocaleText, resources));
    for (int i = 0; i < ResourceLoader.SUPPORTED_LOCALES.length; i++) {
        portableLanguages
                .addItem(new LanguageItem(resources.getCodeFromLocale(ResourceLoader.SUPPORTED_LOCALES[i]),
                        ResourceLoader.SUPPORTED_LOCALES[i].getDisplayName(ResourceLoader.SUPPORTED_LOCALES[i]),
                        resources.getVariant(ResourceLoader.SUPPORTED_LOCALES[i])));
    }
    if (!settings.getLanguageCode().equalsIgnoreCase(ResourceLoader.DEFAULT_LOCALE)) {
        Locale loc = resources.getLocaleFromCode(settings.getLanguageCode());

        for (int i = 0; i < ResourceLoader.SUPPORTED_LOCALES.length; i++) {
            if (loc.equals(ResourceLoader.SUPPORTED_LOCALES[i])) {
                portableLanguages.setSelectedIndex(i + 1);
                break;
            }
        }
    }
    portableLanguages.setBorder(new RoundBorder(LauncherFrame.COLOR_SCROLL_THUMB, 1, 10));
    portableLanguages.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 14));
    portableLanguages.setUI(new LanguageCellUI(resources));
    portableLanguages.setForeground(LauncherFrame.COLOR_WHITE_TEXT);
    portableLanguages.setBackground(LauncherFrame.COLOR_SELECTOR_BACK);
    portableLanguages.setRenderer(new LanguageCellRenderer(resources, "globe.png",
            LauncherFrame.COLOR_SELECTOR_BACK, LauncherFrame.COLOR_WHITE_TEXT));
    portableLanguages.setEditable(false);
    portableLanguages.setFocusable(false);
    portableLanguages.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            portableLanguageChanged();
        }
    });
    panel.add(portableLanguages, new GridBagConstraints(0, 4, 1, 0, 0, 0, GridBagConstraints.SOUTHWEST,
            GridBagConstraints.NONE, new Insets(0, 8, 8, 0), 0, 0));

    portableInstallButton = new RoundedButton(resources.getString("launcher.installer.install"));
    portableInstallButton.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 18));
    portableInstallButton.setContentAreaFilled(false);
    portableInstallButton.setForeground(LauncherFrame.COLOR_GREY_TEXT);
    portableInstallButton.setHoverForeground(LauncherFrame.COLOR_BLUE);
    portableInstallButton.setBorder(BorderFactory.createEmptyBorder(8, 56, 8, 56));
    portableInstallButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            portableInstall();
        }
    });
    portableInstallButton.setEnabled(false);

    if (!installDir.equals("")) {
        portableInstallButton.setForeground(LauncherFrame.COLOR_BUTTON_BLUE);
        portableInstallButton.setEnabled(true);
    }

    panel.add(portableInstallButton, new GridBagConstraints(1, 4, 2, 1, 0, 0, GridBagConstraints.EAST,
            GridBagConstraints.VERTICAL, new Insets(0, 0, 8, 8), 0, 0));
}

From source file:org.apache.jmeter.gui.MainFrame.java

/**
 * Create the JMeter tool bar pane containing the running indicator.
 *
 * @return a panel containing the running indicator
 *///from  w ww .j av  a  2 s. com
private Component createToolBar() {
    Box toolPanel = new Box(BoxLayout.X_AXIS);
    // add the toolbar
    this.toolbar = JMeterToolBar.createToolbar(true);
    GuiPackage guiInstance = GuiPackage.getInstance();
    guiInstance.setMainToolbar(toolbar);
    toolPanel.add(toolbar);

    toolPanel.add(Box.createRigidArea(new Dimension(10, 15)));
    toolPanel.add(Box.createGlue());

    toolPanel.add(testTimeDuration);
    toolPanel.add(Box.createRigidArea(new Dimension(20, 15)));

    toolPanel.add(errorsOrFatalsLabel);
    toolPanel.add(warnIndicator);
    toolPanel.add(Box.createRigidArea(new Dimension(20, 15)));

    toolPanel.add(activeThreads);
    toolPanel.add(new JLabel(" / "));
    toolPanel.add(totalThreads);
    toolPanel.add(Box.createRigidArea(new Dimension(10, 15)));
    toolPanel.add(runningIndicator);
    return toolPanel;
}

From source file:org.colombbus.tangara.update.SoftwareUpdateDialog.java

private void addButtonPane() {
    Box box = Box.createHorizontalBox();
    box.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
    box.add(Box.createGlue());
    String closeLabel = bundle.getString("SoftwareUpdateDialog.close"); //$NON-NLS-1$
    closeButton = new JButton(closeLabel);
    closeButton.addActionListener(this);
    box.add(closeButton);// w w  w. ja v  a 2 s  . c om
    add(box, BorderLayout.SOUTH);
}

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

/**
 * Initialize components.//from  w  w w  .j av  a  2  s  .c om
 */
private void initComponents() {
    Font font = new Font(chooseFontName(), Font.PLAIN, fontSize);
    hiddenCursor = createHiddenCursor();
    textArea = new JTextArea() {
        /** {@inheritDoc} */
        protected void paintComponent(final Graphics graphics) {
            Graphics2D g2 = (Graphics2D) graphics;
            g2.setRenderingHint(KEY_FRACTIONALMETRICS, VALUE_FRACTIONALMETRICS_ON);
            g2.setRenderingHint(KEY_TEXT_ANTIALIASING, VALUE_TEXT_ANTIALIAS_LCD_HRGB);
            super.paintComponent(g2);
        }
    };
    textArea.setFont(font);
    textArea.setOpaque(true);
    textArea.setCursor(hiddenCursor);
    textArea.setBackground(backgroundColor);
    textArea.setForeground(textColor);
    textArea.setRows(rows);
    textArea.setLineWrap(true);
    textArea.setWrapStyleWord(true);

    // clear all input mappings
    InputMap inputMap = textArea.getInputMap();
    while (inputMap != null) {
        inputMap.clear();
        inputMap = inputMap.getParent();
    }
    // re-add select default input mappings
    textArea.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "insert-break");
    textArea.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0), "insert-tab");
    textArea.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0), "delete-previous");
    int keyMask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
    textArea.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, keyMask), "delete-previous-word");

    // add new input mappings
    textArea.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_EQUALS, keyMask), "increase-font-size");
    textArea.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, keyMask), "decrease-font-size");
    textArea.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_S, keyMask), "save");
    textArea.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "quit");
    textArea.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_Q, keyMask), "quit");

    Action increaseFontSizeAction = new IncreaseFontSizeAction();
    Action decreaseFontSizeAction = new DecreaseFontSizeAction();
    Action saveAction = new SaveAction();
    Action quitAction = new QuitAction();

    textArea.getActionMap().put("increase-font-size", increaseFontSizeAction);
    textArea.getActionMap().put("decrease-font-size", decreaseFontSizeAction);
    textArea.getActionMap().put("save", saveAction);
    textArea.getActionMap().put("quit", quitAction);

    placeholder = Box.createGlue();
}

From source file:org.isatools.isacreator.filechooser.FileChooserUI.java

/**
 * Create the Navigation Tree panel//  ww w.  j  av a 2 s .  c o  m
 *
 * @return @see JPanel containing the navigation tree to browse a file system.
 */
private JPanel createNavTree() {
    JPanel treeContainer = new JPanel(new BorderLayout());
    treeContainer.setBackground(UIHelper.BG_COLOR);
    treeContainer
            .setBorder(new TitledBorder(UIHelper.GREEN_ROUNDED_BORDER, "", TitledBorder.DEFAULT_JUSTIFICATION,
                    TitledBorder.DEFAULT_POSITION, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR));

    JPanel navigationControls = new JPanel();
    navigationControls.setLayout(new BoxLayout(navigationControls, BoxLayout.LINE_AXIS));
    navigationControls.setOpaque(false);

    final JLabel navToParentDir = new JLabel(upIcon);
    navToParentDir.setOpaque(false);
    navToParentDir.addMouseListener(new CommonMouseAdapter() {

        public void mousePressed(MouseEvent event) {
            super.mousePressed(event);
            navToParentDir.setIcon(upIcon);
            try {
                updateTree(fileBrowser.getParentDirectory());
            } catch (IOException e) {
                errorAction("problem occurred!");
            }
        }

        public void mouseEntered(MouseEvent event) {
            super.mouseEntered(event);
            navToParentDir.setIcon(upIconOver);
        }

        public void mouseExited(MouseEvent event) {
            super.mouseExited(event);
            navToParentDir.setIcon(upIcon);
        }
    });

    navigationControls.add(navToParentDir);
    navigationControls.add(Box.createHorizontalStrut(5));

    final JLabel navToHomeDir = new JLabel(homeIcon);
    navToHomeDir.setOpaque(false);
    navToHomeDir.addMouseListener(new CommonMouseAdapter() {

        public void mousePressed(MouseEvent event) {
            super.mousePressed(event);
            navToHomeDir.setIcon(homeIcon);
            try {
                updateTree(fileBrowser.getHomeDirectory());

            } catch (IOException e) {
                if (e instanceof ConnectionException) {
                    status.setText("<html>status: not connected!</html>");
                }
                FileBrowserTreeNode defaultFTPNode = new FileBrowserTreeNode("problem occurred!", false,
                        FileBrowserTreeNode.DIRECTORY);
                updateTree(defaultFTPNode);
            }
        }

        public void mouseEntered(MouseEvent event) {
            super.mouseEntered(event);
            navToHomeDir.setIcon(homeIconOver);
        }

        public void mouseExited(MouseEvent event) {
            super.mouseExited(event);
            navToHomeDir.setIcon(homeIcon);
        }
    });

    navigationControls.add(navToHomeDir);
    navigationControls.add(Box.createGlue());

    treeContainer.add(navigationControls, BorderLayout.NORTH);

    try {
        treeModel = new DefaultTreeModel(fileBrowser.getHomeDirectory());
        directoryTree = new JTree(treeModel);
        directoryTree.setFont(UIHelper.VER_11_PLAIN);
        directoryTree.setCellRenderer(new FileSystemTreeCellRenderer());
    } catch (IOException e) {
        FileBrowserTreeNode defaultFTPNode = new FileBrowserTreeNode("problem occurred!", false,
                FileBrowserTreeNode.DIRECTORY);
        updateTree(defaultFTPNode);
    }

    directoryTree.addMouseListener(new CommonMouseAdapter() {

        public void mousePressed(MouseEvent event) {
            super.mousePressed(event);
            int selRow = directoryTree.getRowForLocation(event.getX(), event.getY());

            TreePath selPath = directoryTree.getPathForLocation(event.getX(), event.getY());

            if (selRow != -1) {
                final FileBrowserTreeNode node = (FileBrowserTreeNode) selPath.getLastPathComponent();

                if (SwingUtilities.isLeftMouseButton(event)) {

                    if (event.getClickCount() == 2) {
                        if ((node.getType() == FileBrowserTreeNode.DIRECTORY) && (node.getLevel() != 0)) {

                            String newPath;
                            if (fileBrowser instanceof LocalBrowser) {
                                newPath = ((File) fileBrowser.getDirFiles().get(node.toString())).getPath();
                            } else {
                                newPath = node.toString();
                            }
                            updateTree(fileBrowser.changeDirectory(newPath));
                        }

                        // else, if a leaf node, then add file to to list
                        if (node.isLeaf() && (node.getType() != FileBrowserTreeNode.DIRECTORY)) {
                            String extension = node.toString().substring(node.toString().lastIndexOf(".") + 1)
                                    .trim().toUpperCase();

                            FileChooserFile toAdd = null;

                            for (Object o : fileBrowser.getFileMap().get(extension)) {
                                String fileName;
                                String filePath;
                                if (fileBrowser instanceof LocalBrowser) {
                                    File file = (File) o;
                                    fileName = file.getName();
                                    filePath = file.getPath();

                                    if (fileName.equals(node.toString())) {
                                        toAdd = new CustomFile(filePath);
                                        break;
                                    }
                                } else {
                                    FTPFile ftpFile = (FTPFile) o;
                                    fileName = ftpFile.getName();
                                    filePath = fileBrowser.getAbsoluteWorkingDirectory() + File.separator
                                            + ftpFile.getName();

                                    if (fileName.equals(node.toString())) {
                                        toAdd = new CustomFTPFile(ftpFile, filePath);
                                        break;
                                    }
                                }

                            }

                            if (toAdd != null && !checkIfInList(toAdd)) {
                                selectedFiles.addFileItem(toAdd);
                            }
                        }
                    }
                } else {
                    if ((node.getType() == FileBrowserTreeNode.DIRECTORY) && (node.getLevel() != 0)) {

                        // show popup to add the directory to the selected files
                        JPopupMenu popup = new JPopupMenu();

                        JMenuItem addDirectory = new JMenuItem("add directory");
                        addDirectory.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent ae) {

                                Object fileToAdd = fileBrowser.getDirFiles().get(node.toString());
                                FileChooserFile toAdd;

                                if (fileToAdd instanceof File) {
                                    toAdd = new CustomFile(((File) fileToAdd).getPath());
                                } else {
                                    FTPFile ftpFile = (FTPFile) fileToAdd;
                                    String filePath = fileBrowser.getAbsoluteWorkingDirectory() + File.separator
                                            + ftpFile.getName();

                                    toAdd = new CustomFTPFile(ftpFile, filePath);
                                }

                                if (!checkIfInList(toAdd)) {
                                    selectedFiles.addDirectoryItem(toAdd);
                                }
                            }
                        });

                        popup.add(addDirectory);
                        popup.show(directoryTree, event.getX(), event.getY());
                    }
                }
            }
        }

    });

    BasicTreeUI ui = new BasicTreeUI() {
        public Icon getCollapsedIcon() {
            return null;
        }

        public Icon getExpandedIcon() {
            return null;
        }
    };

    directoryTree.setUI(ui);
    directoryTree.setFont(UIHelper.VER_12_PLAIN);

    JScrollPane treeScroll = new JScrollPane(directoryTree, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    treeScroll.setPreferredSize(new Dimension(300, 200));
    treeScroll.setBorder(new EmptyBorder(0, 0, 0, 0));
    treeContainer.add(treeScroll, BorderLayout.CENTER);

    IAppWidgetFactory.makeIAppScrollPane(treeScroll);

    return treeContainer;
}