Example usage for java.awt Insets Insets

List of usage examples for java.awt Insets Insets

Introduction

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

Prototype

public Insets(int top, int left, int bottom, int right) 

Source Link

Document

Creates and initializes a new Insets object with the specified top, left, bottom, and right insets.

Usage

From source file:com.frostwire.gui.bittorrent.PartialFilesDialog.java

private void setupTitle() {
    GridBagConstraints c;//from   w ww .ja  va2  s. co m

    String title = _torrent.getUTF8Name();
    if (title == null) {
        if (_torrent.getName() != null) {
            title = StringUtils.getUTF8String(_torrent.getName());
        } else {
            title = _name.replace("_", " ").replace(".torrent", "").replace(""", "\"");
        }
    }
    labelTitle = new JLabel(title);
    labelTitle.setFont(new Font("Dialog", Font.BOLD, 18));
    labelTitle.setHorizontalAlignment(SwingConstants.LEFT);
    c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 2;
    c.gridheight = 1;
    c.anchor = GridBagConstraints.WEST;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1.0;
    c.insets = new Insets(5, 5, 5, 5);
    panel.add(labelTitle, c);
}

From source file:com.microsoft.alm.plugin.idea.common.ui.checkout.CheckoutForm.java

/**
 * Method generated by IntelliJ IDEA GUI Designer
 * >>> IMPORTANT!! <<<
 * DO NOT edit this method OR call it in your code!
 *
 * @noinspection ALL//from  www .  java  2 s .c o m
 */
private void $$$setupUI$$$() {
    createUIComponents();
    contentPanel = new JPanel();
    contentPanel.setLayout(new GridLayoutManager(10, 3, new Insets(0, 0, 0, 0), -1, -1));
    contentPanel.setName("");
    final JLabel label1 = new JLabel();
    this.$$$loadLabelText$$$(label1, ResourceBundle.getBundle("com/microsoft/alm/plugin/idea/ui/tfplugin")
            .getString("VsoCheckoutForm.SelectRepository"));
    contentPanel.add(label1,
            new GridConstraints(1, 0, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE,
                    GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0,
                    false));
    repositoryFilter = new JTextField();
    repositoryFilter.setName("");
    contentPanel.add(repositoryFilter,
            new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL,
                    GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null,
                    new Dimension(150, -1), null, 0, false));
    final JLabel label2 = new JLabel();
    this.$$$loadLabelText$$$(label2, ResourceBundle.getBundle("com/microsoft/alm/plugin/idea/ui/tfplugin")
            .getString("VsoCheckoutForm.ParentDirectory"));
    contentPanel.add(label2,
            new GridConstraints(5, 0, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE,
                    GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0,
                    false));
    final JLabel label3 = new JLabel();
    this.$$$loadLabelText$$$(label3, ResourceBundle.getBundle("com/microsoft/alm/plugin/idea/ui/tfplugin")
            .getString("VsoCheckoutForm.DirectoryName"));
    contentPanel.add(label3,
            new GridConstraints(7, 0, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE,
                    GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0,
                    false));
    directoryName = new JTextField();
    directoryName.setName("");
    contentPanel.add(directoryName,
            new GridConstraints(8, 0, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL,
                    GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null,
                    new Dimension(150, -1), null, 0, false));
    contentPanel.add(userAccountPanel,
            new GridConstraints(0, 0, 1, 3, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null,
                    null, 0, false));
    repositoryTableScrollPane = new JScrollPane();
    contentPanel.add(repositoryTableScrollPane,
            new GridConstraints(3, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null,
                    null, 0, false));
    repositoryTable = new JTable();
    repositoryTable.setFillsViewportHeight(true);
    repositoryTable.setName("");
    repositoryTable.setShowHorizontalLines(false);
    repositoryTable.setShowVerticalLines(false);
    repositoryTableScrollPane.setViewportView(repositoryTable);
    parentDirectory = new TextFieldWithBrowseButton();
    contentPanel.add(parentDirectory,
            new GridConstraints(6, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null,
                    null, 0, false));
    refreshButton = new JButton();
    refreshButton.setIcon(new ImageIcon(getClass().getResource("/actions/refresh.png")));
    refreshButton.setText("");
    refreshButton.setToolTipText(ResourceBundle.getBundle("com/microsoft/alm/plugin/idea/ui/tfplugin")
            .getString("CheckoutDialog.RefreshButton.ToolTip"));
    contentPanel.add(refreshButton,
            new GridConstraints(2, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    busySpinner = new BusySpinnerPanel();
    contentPanel.add(busySpinner,
            new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null,
                    null, 0, false));
    helpPanel = new HelpPanel();
    helpPanel.setHelpText(ResourceBundle.getBundle("com/microsoft/alm/plugin/idea/ui/tfplugin")
            .getString("VsoLookupHelp.helpText"));
    helpPanel.setPopupText(ResourceBundle.getBundle("com/microsoft/alm/plugin/idea/ui/tfplugin")
            .getString("VsoLookupHelp.Instructions"));
    contentPanel.add(helpPanel,
            new GridConstraints(4, 0, 1, 3, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null,
                    null, 0, false));
    advancedCheckBox = new JCheckBox();
    advancedCheckBox.setText("example text");
    contentPanel.add(advancedCheckBox,
            new GridConstraints(9, 0, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
}

From source file:org.apache.taverna.activities.rest.ui.config.RESTActivityConfigurationPanel.java

private JPanel createGeneralTab() {
    JPanel jpGeneral = new JPanel(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    // All components to be anchored WEST
    c.anchor = GridBagConstraints.WEST;

    c.gridx = 0;//from  ww w.  j  a v a2s  .  c  om
    c.gridy = 0;
    c.gridwidth = 1;
    c.insets = new Insets(7, 7, 3, 3);
    c.weightx = 0.0;
    c.fill = GridBagConstraints.NONE;
    JLabel labelMethod = new JLabel("HTTP Method:", infoIcon, JLabel.LEFT);
    labelMethod.setToolTipText(
            "<html>HTTP method determines how a request to the remote server will be made.<br><br>"
                    + "Supported HTTP methods are normally used for different purposes:<br>"
                    + "<b>GET</b> - to fetch data;<br>" + "<b>POST</b> - to create new resources;<br>"
                    + "<b>PUT</b> - to update existing resources;<br>"
                    + "<b>DELETE</b> - to remove existing resources.<br><br>"
                    + "Documentation of the server that is about to be used may suggest the<br>"
                    + "HTTP method that should be used.</html>");
    jpGeneral.add(labelMethod, c);

    // the HTTP method combo-box will always contain the same values - it is
    // the selected
    // method which is important; therefore, can prepopulate as the set of
    // values is known
    c.gridx++;
    c.insets = new Insets(7, 3, 3, 7);
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1.0;
    cbHTTPMethod = new JComboBox<>(HTTP_METHOD.values());
    cbHTTPMethod.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            boolean contentTypeSelEnabled = RESTActivity
                    .hasMessageBodyInputPort((HTTP_METHOD) cbHTTPMethod.getSelectedItem());

            jlContentTypeExplanation.setVisible(contentTypeSelEnabled);
            jlContentType.setVisible(contentTypeSelEnabled);
            cbContentType.setVisible(contentTypeSelEnabled);
            jlSendDataAs.setVisible(contentTypeSelEnabled);
            cbSendDataAs.setVisible(contentTypeSelEnabled);

            jlContentTypeExplanationPlaceholder.setVisible(!contentTypeSelEnabled);
            jlContentTypeLabelPlaceholder.setVisible(!contentTypeSelEnabled);
            jlContentTypeFieldPlaceholder.setVisible(!contentTypeSelEnabled);
            jlSendDataAsLabelPlaceholder.setVisible(!contentTypeSelEnabled);
            jlSendDataAsFieldPlaceholder.setVisible(!contentTypeSelEnabled);
        }
    });
    jpGeneral.add(cbHTTPMethod, c);

    c.gridx = 0;
    c.gridy++;
    c.insets = new Insets(3, 7, 3, 3);
    c.fill = GridBagConstraints.NONE;
    c.weightx = 0.0;
    JLabel labelString = new JLabel("URL Template:", infoIcon, JLabel.LEFT);
    labelString.setToolTipText("<html>URL template enables to define a URL with <b>configurable<br>"
            + "parameters</b> that will be used to access a remote server.<br><br>"
            + "The template may contain zero or more <b>parameters</b> - each<br>"
            + "enclosed within curly braces <b>\"{\"</b> and <b>\"}\"</b>.<br>"
            + "Taverna will automatically create an individual input port for<br>"
            + "this activity for each parameter.<br><br>"
            + "Values extracted from these input ports during the workflow<br>"
            + "execution these will be used to replace the parameters to<br>" + "produce complete URLs.<br><br>"
            + "For example, if the URL template is configured as<br>"
            + "\"<i>http://www.myexperiment.org/user.xml?id={userID}</i>\", a<br>"
            + "single input port with the name \"<i>userID</i>\" will be created.</html>");
    labelString.setLabelFor(tfURLSignature);
    jpGeneral.add(labelString, c);

    c.gridx++;
    c.insets = new Insets(3, 3, 3, 7);
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1.0;
    tfURLSignature = new JTextField(40);
    tfURLSignature.addFocusListener(new FocusListener() {
        public void focusGained(FocusEvent e) {
            tfURLSignature.selectAll();
        }

        public void focusLost(FocusEvent e) { /* do nothing */
        }
    });
    jpGeneral.add(tfURLSignature, c);

    c.gridx = 0;
    c.gridwidth = 2;
    c.gridy++;
    c.weightx = 0.0;
    c.fill = GridBagConstraints.NONE;
    c.insets = new Insets(18, 7, 3, 7);
    JLabel jlAcceptsExplanation = new JLabel(
            "Preferred MIME type for data to be fetched from the remote server --");
    jpGeneral.add(jlAcceptsExplanation, c);
    c.gridwidth = 1;

    c.gridx = 0;
    c.gridy++;
    c.insets = new Insets(3, 7, 3, 3);
    c.weightx = 0.0;
    c.fill = GridBagConstraints.NONE;
    JLabel jlAccepts = new JLabel("'Accept' header:", infoIcon, JLabel.LEFT);
    jlAccepts.setToolTipText(
            "<html>Select a MIME type from the drop-down menu or type your own.<br>Select blank if you do not want this header to be set.</br>");
    jlAccepts.setLabelFor(cbAccepts);
    jpGeneral.add(jlAccepts, c);

    c.gridx++;
    c.insets = new Insets(3, 3, 3, 7);
    c.weightx = 1.0;
    c.fill = GridBagConstraints.HORIZONTAL;
    cbAccepts = new JComboBox<>(getMediaTypes());
    cbAccepts.setEditable(true);
    cbAccepts.getEditor().getEditorComponent().addFocusListener(new FocusListener() {
        public void focusGained(FocusEvent e) {
            cbAccepts.getEditor().selectAll();
        }

        public void focusLost(FocusEvent e) { /* do nothing */
        }
    });
    jpGeneral.add(cbAccepts, c);

    c.gridx = 0;
    c.gridwidth = 2;
    c.gridy++;
    c.insets = new Insets(18, 7, 3, 7);
    c.weightx = 0.0;
    c.fill = GridBagConstraints.NONE;
    jlContentTypeExplanation = new JLabel("MIME type of data that will be sent to the remote server --");
    jpGeneral.add(jlContentTypeExplanation, c);
    c.gridwidth = 1;

    c.gridx = 0;
    c.gridy++;
    c.insets = new Insets(3, 7, 3, 3);
    c.weightx = 0.0;
    c.fill = GridBagConstraints.NONE;
    jlContentType = new JLabel("'Content-Type' header:", infoIcon, JLabel.LEFT);
    jlContentType.setToolTipText(
            "<html>Select a MIME type from the drop-down menu or type your own.<br>Select blank if you do not want this header to be set.</html>");
    jlContentType.setLabelFor(cbContentType);
    jpGeneral.add(jlContentType, c);

    c.gridx++;
    c.insets = new Insets(3, 3, 3, 7);
    c.weightx = 1.0;
    c.fill = GridBagConstraints.HORIZONTAL;
    cbContentType = new JComboBox<>(getMediaTypes());
    cbContentType.setEditable(true);
    cbContentType.getEditor().getEditorComponent().addFocusListener(new FocusListener() {
        public void focusGained(FocusEvent e) {
            cbContentType.getEditor().selectAll();
        }

        public void focusLost(FocusEvent e) { /* do nothing */
        }
    });
    cbContentType.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            // change selection in the "Send data as" combo-box, based on
            // the selection of Content-Type
            String selectedContentType = (String) cbContentType.getSelectedItem();
            if (selectedContentType.startsWith("text")) {
                cbSendDataAs.setSelectedItem(DATA_FORMAT.String);
            } else {
                cbSendDataAs.setSelectedItem(DATA_FORMAT.Binary);
            }
        }
    });
    jpGeneral.add(cbContentType, c);

    c.gridx = 0;
    c.gridwidth = 2;
    c.gridy++;
    c.insets = new Insets(18, 7, 3, 7);
    c.weightx = 0.0;
    c.fill = GridBagConstraints.NONE;
    jlContentTypeExplanationPlaceholder = new JLabel();
    jlContentTypeExplanationPlaceholder.setPreferredSize(jlContentTypeExplanation.getPreferredSize());
    jpGeneral.add(jlContentTypeExplanationPlaceholder, c);
    c.gridwidth = 1;

    c.gridx = 0;
    c.gridy++;
    c.insets = new Insets(3, 7, 3, 3);
    c.weightx = 0.0;
    c.fill = GridBagConstraints.NONE;
    jlContentTypeLabelPlaceholder = new JLabel();
    jlContentTypeLabelPlaceholder.setPreferredSize(jlContentType.getPreferredSize());
    jpGeneral.add(jlContentTypeLabelPlaceholder, c);

    c.gridx++;
    c.insets = new Insets(3, 3, 3, 7);
    c.weightx = 1.0;
    c.fill = GridBagConstraints.HORIZONTAL;
    jlContentTypeFieldPlaceholder = new JLabel();
    jlContentTypeFieldPlaceholder.setPreferredSize(cbContentType.getPreferredSize());
    jpGeneral.add(jlContentTypeFieldPlaceholder, c);

    c.gridx = 0;
    c.gridy++;
    c.weightx = 0.0;
    c.fill = GridBagConstraints.NONE;
    c.insets = new Insets(3, 7, 8, 3);
    jlSendDataAs = new JLabel("Send data as:", infoIcon, JLabel.LEFT);
    jlSendDataAs.setToolTipText("Select the format for the data to be sent to the remote server");
    jlSendDataAs.setLabelFor(cbSendDataAs);
    jpGeneral.add(jlSendDataAs, c);

    c.gridx++;
    c.insets = new Insets(3, 3, 8, 7);
    c.weightx = 1.0;
    c.fill = GridBagConstraints.HORIZONTAL;
    cbSendDataAs = new JComboBox<>(DATA_FORMAT.values());
    cbSendDataAs.setEditable(false);
    jpGeneral.add(cbSendDataAs, c);

    c.gridx = 0;
    c.gridy++;
    c.insets = new Insets(3, 7, 8, 3);
    c.weightx = 0.0;
    c.fill = GridBagConstraints.NONE;
    jlSendDataAsLabelPlaceholder = new JLabel();
    jlSendDataAsLabelPlaceholder.setPreferredSize(jlSendDataAs.getPreferredSize());
    jpGeneral.add(jlSendDataAsLabelPlaceholder, c);

    c.gridx++;
    c.insets = new Insets(3, 3, 8, 7);
    c.weightx = 1.0;
    c.fill = GridBagConstraints.HORIZONTAL;
    jlSendDataAsFieldPlaceholder = new JLabel();
    jlSendDataAsFieldPlaceholder.setPreferredSize(cbSendDataAs.getPreferredSize());
    jpGeneral.add(jlSendDataAsFieldPlaceholder, c);

    JPanel finalPanel = new JPanel(new BorderLayout());
    finalPanel.add(jpGeneral, BorderLayout.NORTH);
    return (finalPanel);
}

From source file:com._17od.upm.gui.MainWindow.java

private void addComponentsToPane() {

    // Ensure the layout manager is a BorderLayout
    if (!(getContentPane().getLayout() instanceof GridBagLayout)) {
        getContentPane().setLayout(new GridBagLayout());
    }//from  www  .j  a  va  2s .c o  m

    // Create the menubar
    setJMenuBar(createMenuBar());

    GridBagConstraints c = new GridBagConstraints();

    // The toolbar Row
    c.gridx = 0;
    c.gridy = 0;
    c.anchor = GridBagConstraints.FIRST_LINE_START;
    c.insets = new Insets(0, 0, 0, 0);
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 3;
    c.fill = GridBagConstraints.HORIZONTAL;
    Component toolbar = createToolBar();
    getContentPane().add(toolbar, c);

    // Keep the frame background color consistent
    getContentPane().setBackground(toolbar.getBackground());

    // The seperator Row
    c.gridx = 0;
    c.gridy = 1;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 0, 0, 0);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 3;
    c.fill = GridBagConstraints.HORIZONTAL;
    getContentPane().add(new JSeparator(), c);

    // The search field row
    searchIcon = new JLabel(Util.loadImage("search.gif"));
    searchIcon.setDisabledIcon(Util.loadImage("search_d.gif"));
    searchIcon.setEnabled(false);
    c.gridx = 0;
    c.gridy = 2;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(5, 1, 5, 1);
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    getContentPane().add(searchIcon, c);

    searchField = new JTextField(15);
    searchField.setEnabled(false);
    searchField.setMinimumSize(searchField.getPreferredSize());
    searchField.getDocument().addDocumentListener(new DocumentListener() {
        public void changedUpdate(DocumentEvent e) {
            // This method never seems to be called
        }

        public void insertUpdate(DocumentEvent e) {
            dbActions.filter();
        }

        public void removeUpdate(DocumentEvent e) {
            dbActions.filter();
        }
    });
    searchField.addKeyListener(new KeyAdapter() {
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
                dbActions.resetSearch();
            } else if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                // If the user hits the enter key in the search field and
                // there's only one item
                // in the listview then open that item (this code assumes
                // that the one item in
                // the listview has already been selected. this is done
                // automatically in the
                // DatabaseActions.filter() method)
                if (accountsListview.getModel().getSize() == 1) {
                    viewAccountMenuItem.doClick();
                }
            }
        }
    });
    c.gridx = 1;
    c.gridy = 2;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(5, 1, 5, 1);
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    getContentPane().add(searchField, c);

    resetSearchButton = new JButton(Util.loadImage("stop.gif"));
    resetSearchButton.setDisabledIcon(Util.loadImage("stop_d.gif"));
    resetSearchButton.setEnabled(false);
    resetSearchButton.setToolTipText(Translator.translate(RESET_SEARCH_TXT));
    resetSearchButton.setActionCommand(RESET_SEARCH_TXT);
    resetSearchButton.addActionListener(this);
    resetSearchButton.setBorder(BorderFactory.createEmptyBorder());
    resetSearchButton.setFocusable(false);
    c.gridx = 2;
    c.gridy = 2;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(5, 1, 5, 1);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    getContentPane().add(resetSearchButton, c);

    // The accounts listview row
    accountsListview = new JList();
    accountsListview.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    accountsListview.setSelectedIndex(0);
    accountsListview.setVisibleRowCount(10);
    accountsListview.setModel(new SortedListModel());
    JScrollPane accountsScrollList = new JScrollPane(accountsListview, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    accountsListview.addFocusListener(new FocusAdapter() {
        public void focusGained(FocusEvent e) {
            // If the listview gets focus, there is one ore more items in
            // the listview and there is nothing
            // already selected, then select the first item in the list
            if (accountsListview.getModel().getSize() > 0 && accountsListview.getSelectedIndex() == -1) {
                accountsListview.setSelectionInterval(0, 0);
            }
        }
    });
    accountsListview.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            dbActions.setButtonState();
        }
    });
    accountsListview.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {
                viewAccountMenuItem.doClick();
            }
        }
    });
    accountsListview.addKeyListener(new KeyAdapter() {
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                viewAccountMenuItem.doClick();
            }
        }
    });
    // Create a shortcut to delete account functionality with DEL(delete)
    // key

    accountsListview.addKeyListener(new KeyAdapter() {
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_DELETE) {

                try {
                    dbActions.reloadDatabaseBefore(new DeleteAccountAction());
                } catch (InvalidPasswordException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                } catch (ProblemReadingDatabaseFile e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                } catch (IOException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                }

            }
        }
    });

    c.gridx = 0;
    c.gridy = 3;
    c.anchor = GridBagConstraints.CENTER;
    c.insets = new Insets(0, 1, 1, 1);
    c.weightx = 1;
    c.weighty = 1;
    c.gridwidth = 3;
    c.fill = GridBagConstraints.BOTH;
    getContentPane().add(accountsScrollList, c);

    // The "File Changed" panel
    c.gridx = 0;
    c.gridy = 4;
    c.anchor = GridBagConstraints.CENTER;
    c.insets = new Insets(0, 1, 0, 1);
    c.ipadx = 3;
    c.ipady = 3;
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 3;
    c.fill = GridBagConstraints.BOTH;
    databaseFileChangedPanel = new JPanel();
    databaseFileChangedPanel.setLayout(new BoxLayout(databaseFileChangedPanel, BoxLayout.X_AXIS));
    databaseFileChangedPanel.setBackground(new Color(249, 172, 60));
    databaseFileChangedPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    JLabel fileChangedLabel = new JLabel("Database file changed");
    fileChangedLabel.setAlignmentX(LEFT_ALIGNMENT);
    databaseFileChangedPanel.add(fileChangedLabel);
    databaseFileChangedPanel.add(Box.createHorizontalGlue());
    JButton reloadButton = new JButton("Reload");
    reloadButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                dbActions.reloadDatabaseFromDisk();
            } catch (Exception ex) {
                dbActions.errorHandler(ex);
            }
        }
    });
    databaseFileChangedPanel.add(reloadButton);
    databaseFileChangedPanel.setVisible(false);
    getContentPane().add(databaseFileChangedPanel, c);

    // Add the statusbar
    c.gridx = 0;
    c.gridy = 5;
    c.anchor = GridBagConstraints.CENTER;
    c.insets = new Insets(0, 1, 1, 1);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 3;
    c.fill = GridBagConstraints.HORIZONTAL;
    getContentPane().add(statusBar, c);

}

From source file:org.fhcrc.cpl.viewer.quant.gui.QuantitationReviewer.java

/**
 * Initialize all GUI components and display the UI
 *//*from  w w w  .j a v a 2s . c  o m*/
protected void initGUI() {
    settingsCLM = new ProteinQuantChartsCLM(false);

    setTitle("Qurate");
    try {
        setIconImage(ImageIO.read(WorkbenchFrame.class.getResourceAsStream("icon.gif")));
    } catch (Exception e) {
    }

    try {
        Localizer.renderSwixml("org/fhcrc/cpl/viewer/quant/gui/QuantitationReviewer.xml", this);
        assert null != contentPanel;
    } catch (Exception x) {
        ApplicationContext.errorMessage("error creating dialog", x);
        throw new RuntimeException(x);
    }

    //Menu
    openFileAction = new OpenFileAction(this);
    createChartsAction = new CreateChartsAction();
    filterPepXMLAction = new FilterPepXMLAction(this);
    proteinSummaryAction = new ProteinSummaryAction(this);

    try {
        JMenuBar jmenu = (JMenuBar) Localizer.getSwingEngine(this)
                .render("org/fhcrc/cpl/viewer/quant/gui/QuantitationReviewerMenu.xml");
        for (int i = 0; i < jmenu.getMenuCount(); i++)
            jmenu.getMenu(i).getPopupMenu().setLightWeightPopupEnabled(false);
        this.setJMenuBar(jmenu);
    } catch (Exception x) {
        ApplicationContext.errorMessage(TextProvider.getText("ERROR_LOADING_MENUS"), x);
        throw new RuntimeException(x);
    }

    //Global stuff
    setSize(fullWidth, fullHeight);
    setContentPane(contentPanel);
    ListenerHelper helper = new ListenerHelper(this);

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.BOTH;
    gbc.anchor = GridBagConstraints.PAGE_START;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.insets = new Insets(5, 5, 5, 5);
    gbc.weighty = 1;
    gbc.weightx = 1;

    leftPanel.setLayout(new GridBagLayout());
    leftPanel.setBorder(BorderFactory.createLineBorder(Color.gray));

    //Properties panel stuff
    propertiesTable = new QuantEvent.QuantEventPropertiesTable();
    propertiesScrollPane = new JScrollPane();
    propertiesScrollPane.setViewportView(propertiesTable);
    propertiesScrollPane.setMinimumSize(new Dimension(propertiesWidth, propertiesHeight));

    //event summary table; disembodied
    eventSummaryTable = new QuantEventsSummaryTable();
    eventSummaryTable.setVisible(true);
    ListSelectionModel tableSelectionModel = eventSummaryTable.getSelectionModel();
    tableSelectionModel.addListSelectionListener(new EventSummaryTableListSelectionHandler());
    JScrollPane eventSummaryScrollPane = new JScrollPane();
    eventSummaryScrollPane.setViewportView(eventSummaryTable);
    eventSummaryScrollPane.setSize(propertiesWidth, propertiesHeight);
    eventSummaryFrame = new Frame("All Events");
    eventSummaryFrame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent event) {
            eventSummaryFrame.setVisible(false);
        }
    });
    eventSummaryFrame.setSize(950, 450);
    eventSummaryFrame.add(eventSummaryScrollPane);

    //fields related to navigation
    navigationPanel = new JPanel();
    backButton = new JButton("<");
    backButton.setToolTipText("Previous Event");
    backButton.setMaximumSize(new Dimension(50, 30));
    backButton.setEnabled(false);
    forwardButton = new JButton(">");
    forwardButton.setToolTipText("Next Event");
    forwardButton.setMaximumSize(new Dimension(50, 30));
    forwardButton.setEnabled(false);
    showEventSummaryButton = new JButton("Show All");
    showEventSummaryButton.setToolTipText("Show all events in a table");
    showEventSummaryButton.setEnabled(false);

    helper.addListener(backButton, "buttonBack_actionPerformed");
    helper.addListener(forwardButton, "buttonForward_actionPerformed");
    helper.addListener(showEventSummaryButton, "buttonShowEventSummary_actionPerformed");

    gbc.fill = GridBagConstraints.NONE;
    gbc.gridwidth = GridBagConstraints.RELATIVE;
    gbc.anchor = GridBagConstraints.WEST;
    navigationPanel.add(backButton, gbc);
    gbc.gridwidth = GridBagConstraints.RELATIVE;
    navigationPanel.add(forwardButton, gbc);
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    navigationPanel.add(showEventSummaryButton, gbc);
    gbc.fill = GridBagConstraints.BOTH;
    navigationPanel.setBorder(BorderFactory.createTitledBorder("Event"));
    gbc.anchor = GridBagConstraints.PAGE_START;

    //Fields related to curation of events
    curationPanel = new JPanel();
    curationPanel.setLayout(new GridBagLayout());
    curationPanel.setBorder(BorderFactory.createTitledBorder("Curation"));
    //Quantitation curation
    JPanel quantCurationPanel = new JPanel();
    quantCurationPanel.setLayout(new GridBagLayout());
    quantCurationPanel.setBorder(BorderFactory.createTitledBorder("Quantitation"));
    quantCurationButtonGroup = new ButtonGroup();
    JRadioButton unknownRadioButton = new JRadioButton("?");
    JRadioButton goodRadioButton = new JRadioButton("Good");
    JRadioButton badRadioButton = new JRadioButton("Bad");
    onePeakRatioRadioButton = new JRadioButton("1-Peak");

    unknownRadioButton.setEnabled(false);
    goodRadioButton.setEnabled(false);
    badRadioButton.setEnabled(false);
    onePeakRatioRadioButton.setEnabled(false);

    quantCurationButtonGroup.add(unknownRadioButton);
    quantCurationButtonGroup.add(goodRadioButton);
    quantCurationButtonGroup.add(badRadioButton);
    quantCurationButtonGroup.add(onePeakRatioRadioButton);

    unknownRadioButtonModel = unknownRadioButton.getModel();
    goodRadioButtonModel = goodRadioButton.getModel();
    badRadioButtonModel = badRadioButton.getModel();
    onePeakRadioButtonModel = onePeakRatioRadioButton.getModel();

    helper.addListener(unknownRadioButton, "buttonCuration_actionPerformed");
    helper.addListener(goodRadioButton, "buttonCuration_actionPerformed");
    helper.addListener(badRadioButton, "buttonCuration_actionPerformed");
    helper.addListener(onePeakRadioButtonModel, "buttonCuration_actionPerformed");

    gbc.anchor = GridBagConstraints.WEST;
    quantCurationPanel.add(unknownRadioButton, gbc);
    quantCurationPanel.add(badRadioButton, gbc);
    quantCurationPanel.add(goodRadioButton, gbc);
    quantCurationPanel.add(onePeakRatioRadioButton, gbc);

    gbc.anchor = GridBagConstraints.PAGE_START;
    //ID curation
    JPanel idCurationPanel = new JPanel();
    idCurationPanel.setLayout(new GridBagLayout());
    idCurationPanel.setBorder(BorderFactory.createTitledBorder("ID"));
    idCurationButtonGroup = new ButtonGroup();
    JRadioButton idUnknownRadioButton = new JRadioButton("?");
    JRadioButton idGoodRadioButton = new JRadioButton("Good");
    JRadioButton idBadRadioButton = new JRadioButton("Bad");
    idUnknownRadioButton.setEnabled(false);
    idGoodRadioButton.setEnabled(false);
    idBadRadioButton.setEnabled(false);

    idCurationButtonGroup.add(idUnknownRadioButton);
    idCurationButtonGroup.add(idGoodRadioButton);
    idCurationButtonGroup.add(idBadRadioButton);
    idUnknownRadioButtonModel = idUnknownRadioButton.getModel();
    idGoodRadioButtonModel = idGoodRadioButton.getModel();
    idBadRadioButtonModel = idBadRadioButton.getModel();
    helper.addListener(idUnknownRadioButton, "buttonIDCuration_actionPerformed");
    helper.addListener(idGoodRadioButton, "buttonIDCuration_actionPerformed");
    helper.addListener(idBadRadioButton, "buttonIDCuration_actionPerformed");
    gbc.anchor = GridBagConstraints.WEST;
    idCurationPanel.add(idUnknownRadioButton, gbc);
    idCurationPanel.add(idBadRadioButton, gbc);
    idCurationPanel.add(idGoodRadioButton, gbc);

    gbc.gridwidth = GridBagConstraints.RELATIVE;
    curationPanel.add(quantCurationPanel, gbc);
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    curationPanel.add(idCurationPanel, gbc);

    //curation comment
    commentTextField = new JTextField();
    commentTextField.setToolTipText("Comment on this event");
    //saves after every keypress.  Would be more efficient to save when navigating away or saving to file
    commentTextField.addKeyListener(new KeyAdapter() {
        public void keyReleased(KeyEvent e) {
            if (quantEvents == null)
                return;
            QuantEvent quantEvent = quantEvents.get(displayedEventIndex);
            //save the comment, being careful about tabs and new lines
            quantEvent.setComment(commentTextField.getText().replace("\t", " ").replace("\n", " "));
        }

        public void keyTyped(KeyEvent e) {
        }

        public void keyPressed(KeyEvent e) {
        }
    });
    curationPanel.add(commentTextField, gbc);

    assessmentPanel = new JPanel();
    assessmentPanel.setLayout(new GridBagLayout());
    assessmentPanel.setBorder(BorderFactory.createTitledBorder("Algorithmic Assessment"));
    assessmentTypeTextField = new JTextField();
    assessmentTypeTextField.setEditable(false);
    assessmentPanel.add(assessmentTypeTextField, gbc);
    assessmentDescTextField = new JTextField();
    assessmentDescTextField.setEditable(false);
    assessmentPanel.add(assessmentDescTextField, gbc);

    //Theoretical peak distribution
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.CENTER;
    theoreticalPeaksPanel = new JPanel();
    theoreticalPeaksPanel.setBorder(BorderFactory.createTitledBorder("Theoretical Peaks"));
    theoreticalPeaksPanel.setLayout(new GridBagLayout());
    theoreticalPeaksPanel.setMinimumSize(new Dimension(leftPanelWidth - 10, theoreticalPeaksPanelHeight));
    theoreticalPeaksPanel.setMaximumSize(new Dimension(1200, theoreticalPeaksPanelHeight));
    showTheoreticalPeaks();

    //Add everything to the left panel
    gbc.insets = new Insets(0, 5, 0, 5);
    gbc.fill = GridBagConstraints.BOTH;
    gbc.anchor = GridBagConstraints.PAGE_START;
    leftPanel.addComponentListener(new LeftPanelResizeListener());
    gbc.weighty = 10;
    gbc.fill = GridBagConstraints.VERTICAL;
    leftPanel.add(propertiesScrollPane, gbc);
    gbc.fill = GridBagConstraints.NONE;
    gbc.weighty = 1;
    gbc.anchor = GridBagConstraints.PAGE_END;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    leftPanel.add(assessmentPanel, gbc);
    leftPanel.add(theoreticalPeaksPanel, gbc);
    gbc.fill = GridBagConstraints.HORIZONTAL;
    leftPanel.add(curationPanel, gbc);
    leftPanel.add(navigationPanel, gbc);
    gbc.fill = GridBagConstraints.BOTH;
    gbc.weighty = 1;
    gbc.anchor = GridBagConstraints.PAGE_START;

    //Chart display
    multiChartDisplay = new TabbedMultiChartDisplayPanel();
    multiChartDisplay.setResizeDelayMS(0);

    rightPanel.addComponentListener(new RightPanelResizeListener());
    rightPanel.add(multiChartDisplay, gbc);

    //status message
    messageLabel.setBackground(Color.WHITE);
    messageLabel.setFont(Font.decode("verdana plain 12"));
    messageLabel.setText(" ");

    setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    //paranoia.  Sometimes it seems Qurate doesn't exit when you close every window
    addWindowStateListener(new WindowStateListener() {
        public void windowStateChanged(WindowEvent e) {
            if (e.getNewState() == WindowEvent.WINDOW_CLOSED) {
                dispose();
                System.exit(0);
            }
        }
    });

}

From source file:net.sf.jabref.gui.plaintextimport.TextInputDialog.java

private JPanel setUpFieldListPanel() {
    JPanel inputPanel = new JPanel();

    // Panel Layout
    GridBagLayout gbl = new GridBagLayout();
    GridBagConstraints con = new GridBagConstraints();
    con.weightx = 0;/*from w  ww . j a va 2  s  . co m*/
    con.insets = new Insets(5, 5, 0, 5);
    con.fill = GridBagConstraints.HORIZONTAL;

    inputPanel.setLayout(gbl);

    // Border
    TitledBorder titledBorder1 = new TitledBorder(BorderFactory.createLineBorder(new Color(153, 153, 153), 2),
            Localization.lang("Work options"));
    inputPanel.setBorder(titledBorder1);
    inputPanel.setMinimumSize(new Dimension(10, 10));

    JScrollPane fieldScroller = new JScrollPane(fieldList);
    fieldScroller.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);

    // insert buttons
    insertButton.addActionListener(event -> insertTextForTag(override.isSelected()));

    // Radio buttons
    append.setToolTipText(Localization.lang("Append the selected text to BibTeX field"));
    append.setMnemonic(KeyEvent.VK_A);
    append.setSelected(true);

    override.setToolTipText(Localization.lang("Override the BibTeX field by the selected text"));
    override.setMnemonic(KeyEvent.VK_O);
    override.setSelected(false);

    //Group the radio buttons.
    ButtonGroup group = new ButtonGroup();
    group.add(append);
    group.add(override);

    JPanel radioPanel = new JPanel(new GridLayout(0, 1));
    radioPanel.add(append);
    radioPanel.add(override);

    // insert sub components
    JLabel label1 = new JLabel(Localization.lang("Available BibTeX fields"));
    con.gridwidth = GridBagConstraints.REMAINDER;
    gbl.setConstraints(label1, con);
    inputPanel.add(label1);

    con.gridwidth = GridBagConstraints.REMAINDER;
    con.gridheight = 8;
    con.weighty = 1;
    con.fill = GridBagConstraints.BOTH;
    gbl.setConstraints(fieldScroller, con);
    inputPanel.add(fieldScroller);

    con.fill = GridBagConstraints.HORIZONTAL;
    con.weighty = 0;
    con.gridwidth = 2;
    gbl.setConstraints(radioPanel, con);
    inputPanel.add(radioPanel);

    con.gridwidth = GridBagConstraints.REMAINDER;
    gbl.setConstraints(insertButton, con);
    inputPanel.add(insertButton);
    return inputPanel;
}

From source file:me.childintime.childintime.ui.window.tool.BmiToolDialog.java

/**
 * Build the UI student panel./*w ww  . ja  v  a2 s  .  co m*/
 *
 * @return Student panel.
 */
private JPanel buildUiStudentPanel() {
    // Create a grid bag constraints configuration
    GridBagConstraints c = new GridBagConstraints();

    // Create a panel for the student selector
    final JPanel studentPanel = new JPanel(new GridBagLayout());

    // Create a group filter property field
    this.groupFilterField = new EntityPropertyField(Core.getInstance().getGroupManager(), true);
    this.groupFilterField.setNull(true);

    // Add the student label
    c.fill = GridBagConstraints.NONE;
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 0;
    c.weighty = 0;
    c.insets = new Insets(0, 2, 2, 0);
    c.anchor = GridBagConstraints.SOUTHWEST;
    studentPanel.add(new JLabel("Student group filter:"), c);

    // Add the group filter
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx = 0;
    c.gridy = 1;
    c.weightx = 1;
    c.weighty = 0;
    c.insets = new Insets(0, 0, 8, 0);
    c.anchor = GridBagConstraints.CENTER;
    studentPanel.add(this.groupFilterField, c);

    // Create a student selector list
    this.studentList = new EntityListSelectorComponent(Core.getInstance().getStudentManager());

    // Create a listener to set the student list filter when the group changes
    this.groupFilterField.addValueChangeListenerListener(newValue -> {
        // Set or clear the filter
        if (newValue != null)
            this.studentList.setFilter(StudentFields.GROUP_ID, newValue);
        else
            this.studentList.clearFilter();
    });

    // Add the student label
    c.fill = GridBagConstraints.NONE;
    c.gridx = 0;
    c.gridy = 2;
    c.weightx = 0;
    c.weighty = 0;
    c.insets = new Insets(8, 2, 2, 0);
    c.anchor = GridBagConstraints.SOUTHWEST;
    studentPanel.add(new JLabel("Student:"), c);

    // Add the student list
    c.fill = GridBagConstraints.BOTH;
    c.gridx = 0;
    c.gridy = 3;
    c.weightx = 1;
    c.weighty = 1;
    c.insets = new Insets(0, 0, 0, 0);
    c.anchor = GridBagConstraints.CENTER;
    studentPanel.add(this.studentList, c);

    // Set the minimum preferred size
    studentPanel.setPreferredSize(new Dimension(200, 200));

    // Return the student panel
    return studentPanel;
}

From source file:org.nuclos.client.layout.wysiwyg.component.properties.PropertyChartPropertyDomainStep.java

private PanelComponent getPanelComponent(ChartFunction chartFunction, String prefix) {
    JPanel editor = new JPanel();
    editor.setLayout(new BorderLayout());

    JPanel valueEditor = new JPanel(new GridBagLayout());
    valueEditor.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Werte"));

    JLabel propValue = new JLabel(SpringLocaleDelegate.getInstance().getMessage(
            "wysiwyg.chart.wizard.domain.value", "Bestimmen Sie die Spalte, die die Werte enthlt:"));
    valueEditor.add(propValue, new GridBagConstraints(0, 0, 1, 1, 1D, 1D, GridBagConstraints.NORTHWEST,
            GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 0), 0, 0));

    ChartColumn[] valueColumns = chartFunction.getValueColumnDesc();
    for (int i = 0; i < valueColumns.length; i++) {
        ChartColumn chartColumn = valueColumns[i];
        PropertyEditorString propValueEditor = new PropertyEditorString(prefix + chartColumn.property,
                getFittingFieldnames(wysiwygChart.getEntityName(), chartColumn.clazz), true);
        propValueEditor.setEditorValue(getChartProperty(prefix + chartColumn.property));
        valueEditor.add(/*from   ww w.j a v  a  2s. c o  m*/
                new JLabel(SpringLocaleDelegate.getInstance()
                        .getMessage("wysiwyg.chart.wizard.domain.column." + chartColumn.property, "")),
                new GridBagConstraints(0, i + 1, 1, 1, 1D, 1D, GridBagConstraints.NORTHWEST,
                        GridBagConstraints.HORIZONTAL, new Insets(10, 0, 10, 0), 0, 0));
        valueEditor.add(propValueEditor.getComponent(true),
                new GridBagConstraints(1, i + 1, 1, 1, 1D, 1D, GridBagConstraints.NORTHWEST,
                        GridBagConstraints.HORIZONTAL, new Insets(10, -152, 10, 0), 0, 0));
        propertyEditorList.add(propValueEditor);
    }

    editor.add(valueEditor, BorderLayout.NORTH);

    JPanel domainEditor = new JPanel(new GridBagLayout());
    domainEditor.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Domain"));

    ChartColumn[] domainColumns = chartFunction.getDomainColumnDesc();
    if (domainColumns.length > 0) {
        JLabel propDomain = new JLabel(
                SpringLocaleDelegate.getInstance().getMessage("wysiwyg.chart.wizard.domain.compare",
                        "Geben Sie hier die Spalte(n) fr die vergleichenden Werte oder weitere Angaben an:"));
        domainEditor.add(propDomain, new GridBagConstraints(0, 0, 1, 1, 1D, 1D, GridBagConstraints.NORTHWEST,
                GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 0), 0, 0));

        int glue = 185;
        for (int i = 0; i < domainColumns.length; i++) {
            ChartColumn chartColumn = domainColumns[i];
            PropertyEditorString propDomainEditor = new PropertyEditorString(prefix + chartColumn.property,
                    getFittingFieldnames(wysiwygChart.getEntityName(), chartColumn.clazz), true);
            propDomainEditor.setEditorValue(getChartProperty(prefix + chartColumn.property));
            domainEditor.add(
                    new JLabel(SpringLocaleDelegate.getInstance()
                            .getMessage("wysiwyg.chart.wizard.domain.column." + chartColumn.property, "")),
                    new GridBagConstraints(0, i + 1, 1, 1, 1D, 1D, GridBagConstraints.NORTHWEST,
                            GridBagConstraints.HORIZONTAL, new Insets(10, 0, 10, 0), 0, 0));
            domainEditor.add(propDomainEditor.getComponent(true),
                    new GridBagConstraints(1, i + 1, 1, 1, 1D, 1D, GridBagConstraints.NORTHWEST,
                            GridBagConstraints.HORIZONTAL, new Insets(10, -240, 10, 0), 0, 0));
            glue -= propDomainEditor.comboBox.getPreferredSize().height + 10; // add size.
            propertyEditorList.add(propDomainEditor);
        }

        domainEditor.add(new JPanel(), new GridBagConstraints(0, 3, 1, 1, 1D, 1D, GridBagConstraints.NORTHWEST,
                GridBagConstraints.BOTH, new Insets(glue < 0 ? 0 : glue, 0, 10, 0), 0, 0));

        editor.add(domainEditor, BorderLayout.CENTER);
    }
    editor.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));

    PanelComponent pnlScroller = new PanelComponent(prefix, editor);
    pnlScroller.setPreferredSize(new Dimension(250, 80));
    pnlScroller.setAlignmentX(LEFT_ALIGNMENT);
    pnlScroller.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));

    return pnlScroller;
}

From source file:com.ciphertool.zodiacengine.gui.view.SwingUserInterface.java

public void init() {
    this.addWindowListener(getWindowClosingListener());
    this.setTitle(windowTitle);
    this.setSize(windowWidth, windowHeight);
    this.setLocationRelativeTo(null);
    this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    JPanel containerPanel = new JPanel();
    getContentPane().add(containerPanel);

    /*// www. j av  a 2 s  .  com
     * Use a BorderLayout for the main container so we can use the SOUTH
     * panel as a status bar and use the NORTH panel as a menu bar, etc.
     */
    containerPanel.setLayout(new BorderLayout());

    JPanel bottomPanel = new JPanel();
    containerPanel.add(bottomPanel, BorderLayout.SOUTH);
    bottomPanel.setLayout(new BorderLayout());

    JPanel buttonPanel = new JPanel();
    bottomPanel.add(buttonPanel, BorderLayout.CENTER);

    GridLayout gridLayout = new GridLayout(1, 2, 5, 5);
    buttonPanel.setLayout(gridLayout);
    buttonPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    startButton = new JButton(startButtonText);
    startButton.addActionListener(getStartButtonActionListener(false));

    buttonPanel.add(startButton);

    debugButton = new JButton(debugButtonText);
    debugButton.addActionListener(getStartButtonActionListener(true));

    buttonPanel.add(debugButton);

    continueButton = new JButton(continueButtonText);
    continueButton.addActionListener(getContinueButtonActionListener());

    buttonPanel.add(continueButton);
    continueButton.setEnabled(false);

    stopButton = new JButton(stopButtonText);
    stopButton.addActionListener(getStopButtonActionListener());

    buttonPanel.add(stopButton);
    stopButton.setEnabled(false);

    JPanel statusPanel = new JPanel();
    bottomPanel.add(statusPanel, BorderLayout.SOUTH);

    statusLabel = new JLabel(statusNotRunning);
    statusPanel.add(statusLabel);

    /*
     * Next make a grid bag for the thirteen input elements with labels on
     * the left and spinners on the right.
     */
    JPanel mainPanel = new JPanel();
    GridBagLayout gridBagLayout = new GridBagLayout();
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.fill = GridBagConstraints.BOTH;
    constraints.insets = new Insets(5, 5, 5, 5);
    constraints.anchor = GridBagConstraints.WEST;
    mainPanel.setLayout(gridBagLayout);
    mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    containerPanel.add(mainPanel, BorderLayout.CENTER);

    List<Cipher> ciphers = cipherDao.findAll();
    cipherMap = new HashMap<String, Cipher>();
    cipherComboBox = new JComboBox<String>();
    String cipherName;
    for (Cipher cipher : ciphers) {
        cipherName = cipher.getName();
        cipherMap.put(cipherName, cipher);

        cipherComboBox.addItem(cipherName);

        if (cipher.getName().equals(defaultCipher)) {
            cipherComboBox.setSelectedItem(cipherName);
        }
    }
    JLabel cipherNameLabel = new JLabel(cipherNameText);
    cipherComboBox.addActionListener(getCipherComboBoxActionListener());

    constraints.weightx = LAYOUT_LABEL_WEIGHT;
    constraints.gridwidth = GridBagConstraints.RELATIVE;
    gridBagLayout.setConstraints(cipherNameLabel, constraints);
    mainPanel.add(cipherNameLabel);
    constraints.weightx = LAYOUT_INPUT_WEIGHT;
    constraints.gridwidth = GridBagConstraints.REMAINDER;
    gridBagLayout.setConstraints(cipherComboBox, constraints);
    mainPanel.add(cipherComboBox);

    appendGenerationsSpinner(gridBagLayout, constraints, mainPanel);

    appendRunContinuouslyCheckBox(gridBagLayout, constraints, mainPanel);

    appendPopulationSpinner(gridBagLayout, constraints, mainPanel);

    appendLifespanSpinner(gridBagLayout, constraints, mainPanel);

    appendSurvivalRateSpinner(gridBagLayout, constraints, mainPanel);

    appendMutationRateSpinner(gridBagLayout, constraints, mainPanel);

    appendMaxMutationsPerIndividualSpinner(gridBagLayout, constraints, mainPanel);

    appendCrossoverRateSpinner(gridBagLayout, constraints, mainPanel);

    appendMutateDuringCrossoverCheckBox(gridBagLayout, constraints, mainPanel);

    appendFitnessEvaluatorComboBox(gridBagLayout, constraints, mainPanel);

    appendCrossoverAlgorithmComboBox(gridBagLayout, constraints, mainPanel);

    appendMutationAlgorithmComboBox(gridBagLayout, constraints, mainPanel);

    appendSelectionAlgorithmComboBox(gridBagLayout, constraints, mainPanel);

    appendSelectorComboBox(gridBagLayout, constraints, mainPanel);

    appendCompareToKnownSolutionCheckBox(gridBagLayout, constraints, mainPanel);

    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            setVisible(true);
            toFront();
        }
    });
}

From source file:ExtendedParagraphExample.java

protected void setPropertiesFromAttributes() {
    AttributeSet attr = getAttributes();
    if (attr != null) {
        super.setPropertiesFromAttributes();
        paraInsets = new Insets(getTopInset(), getLeftInset(), getBottomInset(), getRightInset());

        border = ExtendedStyleConstants.getParagraphBorder(attr);
        bgColor = ExtendedStyleConstants.getParagraphBackground(attr);
        if (bgColor != null && border == null) {
            // Provide a small margin if the background
            // is being filled and there is no border
            border = smallBorder;/* ww  w . j a  v a  2 s .  c  o  m*/
        }

        if (border != null) {
            Insets borderInsets = border.getBorderInsets(getContainer());
            setInsets((short) (paraInsets.top + borderInsets.top),
                    (short) (paraInsets.left + borderInsets.left),
                    (short) (paraInsets.bottom + borderInsets.bottom),
                    (short) (paraInsets.right + borderInsets.right));
        }
    }
}