Example usage for javax.swing Box createVerticalStrut

List of usage examples for javax.swing Box createVerticalStrut

Introduction

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

Prototype

public static Component createVerticalStrut(int height) 

Source Link

Document

Creates an invisible, fixed-height component.

Usage

From source file:org.ohdsi.whiteRabbit.WhiteRabbitMain.java

private JPanel createScanPanel() {
    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());

    JPanel tablePanel = new JPanel();
    tablePanel.setLayout(new BorderLayout());
    tablePanel.setBorder(new TitledBorder("Tables to scan"));
    tableList = new JList<String>();
    tableList.setToolTipText("Specify the tables (or CSV files) to be scanned here");
    tablePanel.add(new JScrollPane(tableList), BorderLayout.CENTER);

    JPanel tableButtonPanel = new JPanel();
    tableButtonPanel.setLayout(new GridLayout(3, 1));
    addAllButton = new JButton("Add all in DB");
    addAllButton.setToolTipText("Add all tables in the database");
    addAllButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            addAllTables();/* w  w w .  j  a v  a2 s.  co m*/
        }
    });
    addAllButton.setEnabled(false);
    tableButtonPanel.add(addAllButton);
    JButton addButton = new JButton("Add");
    addButton.setToolTipText("Add tables to list");
    addButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            pickTables();
        }
    });
    tableButtonPanel.add(addButton);
    JButton removeButton = new JButton("Remove");
    removeButton.setToolTipText("Remove tables from list");
    removeButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            removeTables();
        }
    });
    tableButtonPanel.add(removeButton);
    tablePanel.add(tableButtonPanel, BorderLayout.EAST);

    panel.add(tablePanel, BorderLayout.CENTER);

    JPanel southPanel = new JPanel();
    southPanel.setLayout(new BoxLayout(southPanel, BoxLayout.Y_AXIS));

    JPanel scanOptionsPanel = new JPanel();
    scanOptionsPanel.setLayout(new BoxLayout(scanOptionsPanel, BoxLayout.X_AXIS));

    scanValueScan = new JCheckBox("Scan field values", true);
    scanValueScan.setToolTipText("Include a frequency count of field values in the scan report");
    scanValueScan.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent arg0) {
            scanMinCellCount.setEnabled(((JCheckBox) arg0.getSource()).isSelected());
            scanRowCount.setEnabled(((JCheckBox) arg0.getSource()).isSelected());
            scanValuesCount.setEnabled(((JCheckBox) arg0.getSource()).isSelected());
        }
    });
    scanOptionsPanel.add(scanValueScan);
    scanOptionsPanel.add(Box.createHorizontalGlue());

    scanOptionsPanel.add(new JLabel("Min cell count "));
    scanMinCellCount = new JSpinner();
    scanMinCellCount.setValue(5);
    scanMinCellCount.setToolTipText("Minimum frequency for a field value to be included in the report");
    scanOptionsPanel.add(scanMinCellCount);
    scanOptionsPanel.add(Box.createHorizontalGlue());

    scanOptionsPanel.add(new JLabel("Max distinct values "));
    scanValuesCount = new JComboBox<String>(new String[] { "100", "1,000", "10,000" });
    scanValuesCount.setSelectedIndex(1);
    scanValuesCount.setToolTipText("Maximum number of distinct values per field to be reported");
    scanOptionsPanel.add(scanValuesCount);
    scanOptionsPanel.add(Box.createHorizontalGlue());

    scanOptionsPanel.add(new JLabel("Rows per table "));
    scanRowCount = new JComboBox<String>(new String[] { "100,000", "500,000", "1 million", "all" });
    scanRowCount.setSelectedIndex(0);
    scanRowCount.setToolTipText("Maximum number of rows per table to be scanned for field values");
    scanOptionsPanel.add(scanRowCount);

    southPanel.add(scanOptionsPanel);

    southPanel.add(Box.createVerticalStrut(3));

    JPanel scanButtonPanel = new JPanel();
    scanButtonPanel.setLayout(new BoxLayout(scanButtonPanel, BoxLayout.X_AXIS));
    scanButtonPanel.add(Box.createHorizontalGlue());

    JButton scanButton = new JButton("Scan tables");
    scanButton.setBackground(new Color(151, 220, 141));
    scanButton.setToolTipText("Scan the selected tables");
    scanButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scanRun();
        }
    });
    componentsToDisableWhenRunning.add(scanButton);
    scanButtonPanel.add(scanButton);
    southPanel.add(scanButtonPanel);

    panel.add(southPanel, BorderLayout.SOUTH);

    return panel;
}

From source file:org.isatools.isacreatorconfigurator.configui.DataEntryPanel.java

private void createMainSector() {

    JPanel topContainer = new JPanel();
    topContainer.setLayout(new BoxLayout(topContainer, BoxLayout.PAGE_AXIS));
    topContainer.setBackground(UIHelper.BG_COLOR);

    // add logo to the top
    topContainer.add(createMenu());/*from  w  w w.  j a v  a  2  s .  c  o  m*/

    JPanel headerImagePanel = new JPanel(new GridLayout(1, 2));
    headerImagePanel.setOpaque(false);

    JLabel logo = new JLabel("");
    logo.setOpaque(false);

    headerImagePanel.add(logo);

    tableInformationDisplay = UIHelper.createLabel("", UIHelper.VER_12_PLAIN, UIHelper.DARK_GREEN_COLOR,
            SwingConstants.RIGHT);
    tableInformationDisplay.setVerticalAlignment(SwingConstants.TOP);
    tableInformationDisplay.setHorizontalAlignment(SwingConstants.RIGHT);

    headerImagePanel.add(UIHelper.wrapComponentInPanel(tableInformationDisplay));

    topContainer.add(headerImagePanel);
    topContainer.add(Box.createVerticalStrut(10));

    add(topContainer, BorderLayout.NORTH);

    // create central console with majority of content!
    createNavigationPanel();

    JPanel bottomContainer = new JPanel();
    bottomContainer.setLayout(new BoxLayout(bottomContainer, BoxLayout.PAGE_AXIS));
    bottomContainer.setBackground(UIHelper.BG_COLOR);

    add(bottomContainer, BorderLayout.SOUTH);

}

From source file:com.ejie.uda.jsonI18nEditor.Editor.java

public void updateUI() {
    TranslationTreeNode selectedNode = translationTree.getSelectedNode();

    resourcesPanel.removeAll();//from ww  w  . j  a va2  s .c o  m
    resourceFields.stream().sorted().forEach(field -> {
        field.setEditable(selectedNode != null && selectedNode.isEditable());
        resourcesPanel.add(Box.createVerticalStrut(5));
        resourcesPanel.add(new JLabel(field.getResource().getLocale().getDisplayName()));
        resourcesPanel.add(Box.createVerticalStrut(5));
        resourcesPanel.add(field);
        resourcesPanel.add(Box.createVerticalStrut(5));
    });
    if (!resourceFields.isEmpty()) {
        resourcesPanel.remove(0);
        resourcesPanel.remove(resourcesPanel.getComponentCount() - 1);
    }

    editorMenu.setEnabled(resourcesDir != null);
    editorMenu.setEditable(!resources.isEmpty());
    translationTree.setEditable(!resources.isEmpty());
    translationField.setEditable(!resources.isEmpty());

    updateTitle();
    validate();
    repaint();
}

From source file:org.isatools.isacreatorconfigurator.configui.DataEntryPanel.java

private JPanel createTableListPanel() {

    JPanel container = new JPanel();
    container.setBackground(UIHelper.BG_COLOR);
    container.setLayout(new BoxLayout(container, BoxLayout.PAGE_AXIS));

    JLabel lab = new JLabel(tableListTitle);

    container.add(UIHelper.wrapComponentInPanel(lab));
    container.add(Box.createVerticalStrut(5));

    tableModel = new DefaultListModel();
    tableList = new JList(tableModel);
    tableList.setCellRenderer(new TableListRenderer());
    tableList.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    tableList.setBackground(UIHelper.BG_COLOR);
    tableList.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent event) {
            try {
                saveCurrentField(false, false);
            } catch (DataNotCompleteException dce) {
                showMessagePane(dce.getMessage(), JOptionPane.ERROR_MESSAGE);
            }/*from   ww  w  .  ja v  a 2  s  . c  o  m*/

            MappingObject currentlyEditedTable = getCurrentlySelectedTable();
            ApplicationManager.setCurrentMappingObject(currentlyEditedTable);

            // update the view error button visibility depending on selected tables error state.
            viewErrorsButton.setVisible(areThereErrorsInThisCurrentObject());

            updateTableInfoDisplay(currentlyEditedTable);
            reformFieldList(currentlyEditedTable);
        }
    });

    JScrollPane listScroller = new JScrollPane(tableList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    listScroller.getViewport().setBackground(UIHelper.BG_COLOR);
    listScroller.setBorder(null);
    listScroller.setPreferredSize(new Dimension(((int) (WIDTH * 0.25)), ((int) (HEIGHT * 0.75))));

    IAppWidgetFactory.makeIAppScrollPane(listScroller);

    container.add(listScroller);
    container.add(Box.createVerticalStrut(5));

    tableCountInfo = UIHelper.createLabel("", UIHelper.VER_11_PLAIN, UIHelper.DARK_GREEN_COLOR);
    container.add(UIHelper.wrapComponentInPanel(tableCountInfo));
    container.add(Box.createVerticalStrut(5));

    // create button panel to add and remove tables
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS));
    buttonPanel.setBackground(UIHelper.BG_COLOR);

    final JLabel addTableButton = new JLabel(addTable, JLabel.LEFT);
    UIHelper.renderComponent(addTableButton, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR, false);
    addTableButton.setOpaque(false);

    addTableButton.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseEntered(MouseEvent mouseEvent) {
            addTableButton.setIcon(addTableOver);
        }

        @Override
        public void mouseExited(MouseEvent mouseEvent) {
            addTableButton.setIcon(addTable);
        }

        public void mousePressed(MouseEvent event) {
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    addTableButton.setIcon(addTable);
                    applicationContainer.showJDialogAsSheet(addTableUI);
                }
            });

        }

    });

    addTableButton.setToolTipText("<html><b>Add table</b><p>Add a new table definition.</p></html>");

    final JLabel removeTableButton = new JLabel(removeTable, JLabel.LEFT);
    UIHelper.renderComponent(removeTableButton, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR, false);
    removeTableButton.setOpaque(false);

    removeTableButton.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseEntered(MouseEvent mouseEvent) {
            removeTableButton.setIcon(removeTableOver);
        }

        @Override
        public void mouseExited(MouseEvent mouseEvent) {
            removeTableButton.setIcon(removeTable);
        }

        public void mousePressed(MouseEvent event) {
            removeTableButton.setIcon(removeTable);
            if (tableList.getSelectedValue() != null) {
                String selectedTable = tableList.getSelectedValue().toString();
                MappingObject toRemove = null;
                for (MappingObject mo : tableFields.keySet()) {
                    if (mo.getAssayName().equals(selectedTable)) {
                        toRemove = mo;
                        break;
                    }
                }

                if (toRemove != null) {
                    tableFields.remove(toRemove);
                    reformTableList();
                }
            }
        }

    });

    removeTableButton.setToolTipText("<html><b>Remove table</b><p>Remove table from definitions?</p></html>");

    viewErrorsButton = new JLabel(viewErrorsIcon);
    viewErrorsButton.setVisible(false);
    viewErrorsButton.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent mouseEvent) {
            viewErrorsButton.setIcon(viewErrorsIcon);
            // show error pane for current table only.

            Validator validator = new Validator();
            validateFormOrTable(validator, ApplicationManager.getCurrentMappingObject());

            ValidationReport report = validator.getReport();

            ConfigurationValidationUI validationUI = new ConfigurationValidationUI(tableFields.keySet(),
                    report);
            validationUI.createGUI();
            validationUI.setLocationRelativeTo(getApplicationContainer());
            validationUI.setAlwaysOnTop(true);
            validationUI.setVisible(true);
        }

        @Override
        public void mouseEntered(MouseEvent mouseEvent) {
            viewErrorsButton.setIcon(viewErrorsIconOver);
        }

        @Override
        public void mouseExited(MouseEvent mouseEvent) {
            viewErrorsButton.setIcon(viewErrorsIcon);
        }
    });

    buttonPanel.add(addTableButton);
    buttonPanel.add(removeTableButton);
    buttonPanel.add(viewErrorsButton);
    buttonPanel.add(Box.createHorizontalGlue());

    container.add(buttonPanel);

    container.add(Box.createVerticalGlue());

    return container;
}

From source file:com.jvms.i18neditor.editor.Editor.java

public void updateUI() {
    TranslationTreeNode selectedNode = translationTree.getSelectionNode();

    resourcesPanel.removeAll();//from w ww  . j a va2s .  c om
    resourceFields = resourceFields.stream().sorted().collect(Collectors.toList());
    resourceFields.forEach(field -> {
        Locale locale = field.getResource().getLocale();
        String label = locale != null ? locale.getDisplayName() : MessageBundle.get("resources.locale.default");
        field.setEnabled(selectedNode != null && selectedNode.isEditable());
        field.setRows(settings.getDefaultInputHeight());
        resourcesPanel.add(Box.createVerticalStrut(5));
        resourcesPanel.add(new JLabel(label));
        resourcesPanel.add(Box.createVerticalStrut(5));
        resourcesPanel.add(field);
        resourcesPanel.add(Box.createVerticalStrut(10));
    });

    Container container = getContentPane();
    if (project != null) {
        container.add(contentPane);
        container.remove(introText);
        List<Resource> resources = project.getResources();
        editorMenu.setEnabled(true);
        editorMenu.setEditable(!resources.isEmpty());
        translationField.setEditable(!resources.isEmpty());
    } else {
        container.add(introText);
        container.remove(contentPane);
        editorMenu.setEnabled(false);
        editorMenu.setEditable(false);
        translationField.setEditable(false);
    }

    translationField.setVisible(settings.isKeyFieldEnabled());
    translationTree.setToggleClickCount(settings.isDoubleClickTreeToggling() ? 2 : 1);

    updateTitle();
    validate();
    repaint();
}

From source file:org.openmicroscopy.shoola.agents.util.ui.ScriptingDialog.java

/**
 * Builds the panel hosting the components.
 *
 * @return See above.//from w w w .  j av  a 2s . com
 */
private JPanel buildControlPanel() {
    JPanel controlPanel = new JPanel();
    controlPanel.setBorder(null);
    controlPanel.add(cancelButton);
    controlPanel.add(Box.createRigidArea(H_SPACER_SIZE));
    controlPanel.add(applyButton);
    controlPanel.add(Box.createRigidArea(H_SPACER_SIZE));
    JPanel bar = new JPanel();
    bar.setLayout(new BoxLayout(bar, BoxLayout.Y_AXIS));
    bar.add(controlPanel);
    bar.add(Box.createVerticalStrut(10));

    JPanel all = new JPanel();
    all.setLayout(new BoxLayout(all, BoxLayout.X_AXIS));
    all.add(UIUtilities.buildComponentPanel(menuButton));
    all.add(UIUtilities.buildComponentPanelRight(bar));
    return all;
}

From source file:it.staiger.jmeter.protocol.http.config.gui.DynamicFilePanel.java

/**
 * Create the main GUI panel which contains the file table and control buttons.
 *
 * @return the main GUI panel/*from   w w  w  .j  a v a2s  . c om*/
 */
protected JPanel makeFilePanel() {
    JPanel mainPanel = new JPanel(new BorderLayout(0, 5));

    if (standalone) {
        mainPanel.add(makeSettingsPanel(), BorderLayout.NORTH);
    } else {
        mainPanel.add(StaigerUtils.makeLabelPanel(tableLabel), BorderLayout.NORTH);
    }

    initializeTableModel();
    table = new JTable(tableModel);
    table.getTableHeader().setDefaultRenderer(new HeaderAsPropertyRenderer());
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    mainPanel.add(StaigerUtils.makeScrollPanel(table), BorderLayout.CENTER);
    mainPanel.add(Box.createVerticalStrut(70), BorderLayout.WEST);
    mainPanel.add(makeButtonPanel(), BorderLayout.SOUTH);

    return mainPanel;
}

From source file:com.ibm.issw.odc.gui.BPMArgumentsPanel.java

/**
 * Initialize the components and layout of this component.
 *///w ww .  j  a  v a2s  .  c o  m
private void init() {
    JPanel p = this;

    if (standalone) {
        setLayout(new BorderLayout(0, 5));
        setBorder(makeBorder());
        add(makeTitlePanel(), BorderLayout.NORTH);
        p = new JPanel();
    }

    p.setLayout(new BorderLayout());

    p.add(makeLabelPanel(), BorderLayout.NORTH);
    p.add(makeMainPanel(), BorderLayout.CENTER);
    // Force a minimum table height of 70 pixels
    p.add(Box.createVerticalStrut(70), BorderLayout.WEST);
    p.add(makeButtonPanel(), BorderLayout.SOUTH);

    if (standalone) {
        add(p, BorderLayout.CENTER);
    }

    table.revalidate();
    sizeColumns(table);
}

From source file:org.openmicroscopy.shoola.agents.util.ui.ScriptingDialog.java

/**
 * Returns the component displaying the description of the script.
 *
 * @return See above.//from  ww w. j av a  2  s  .  co  m
 */
private JComponent buildDescriptionPane() {
    String description = script.getDescription();
    if (StringUtils.isBlank(description))
        return null;
    OMEWikiComponent area = new OMEWikiComponent(false);
    area.setEnabled(false);
    area.setText(description);
    JPanel content = new JPanel();
    content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS));
    JLabel label = UIUtilities.setTextFont(script.getName());
    Font f = label.getFont();
    label.setFont(f.deriveFont(f.getStyle(), f.getSize() + 2));
    content.add(UIUtilities.buildComponentPanel(label));
    content.add(Box.createVerticalStrut(5));
    JPanel p = UIUtilities.buildComponentPanel(area);
    p.setBackground(BG_COLOR);
    area.setBackground(BG_COLOR);
    content.add(p);
    return content;
}

From source file:org.apache.jmeter.config.gui.ArgumentsPanel.java

/**
 * Initialize the components and layout of this component.
 *///from w  w w  . j a v  a 2s  . c  om
private void init() { // WARNING: called from ctor so must not be overridden (i.e. must be private or final)
    JPanel p = this;

    if (standalone) {
        setLayout(new BorderLayout(0, 5));
        setBorder(makeBorder());
        add(makeTitlePanel(), BorderLayout.NORTH);
        p = new JPanel();
    }

    p.setLayout(new BorderLayout());

    p.add(makeLabelPanel(), BorderLayout.NORTH);
    p.add(makeMainPanel(), BorderLayout.CENTER);
    // Force a minimum table height of 70 pixels
    p.add(Box.createVerticalStrut(70), BorderLayout.WEST);
    p.add(makeButtonPanel(), BorderLayout.SOUTH);

    if (standalone) {
        add(p, BorderLayout.CENTER);
    }

    table.revalidate();
    sizeColumns(table);
}