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.ecoinformatics.seek.ecogrid.RegistrySearchDialog.java

/**
 * Construct of this dialog//w w  w. j  av  a  2 s.c o m
 * 
 * @param parent
 *            Frame
 * @param title
 *            String
 */
public RegistrySearchDialog(EcogridPreferencesTab parent, String title, Vector originalServiceList) {
    this.parent = parent;
    this.originalServiceList = originalServiceList;
    this.setLocation(parent.getLocation());
    setSize(new Dimension(WIDTH, HEIGHT));
    initMainPanel();
    getContentPane().add(Box.createVerticalStrut(EcogridPreferencesTab.MARGINGSIZE), BorderLayout.NORTH);
    getContentPane().add(Box.createHorizontalStrut(EcogridPreferencesTab.MARGINGSIZE), BorderLayout.EAST);
    getContentPane().add(mainPanel, BorderLayout.CENTER);
    getContentPane().add(Box.createVerticalStrut(EcogridPreferencesTab.MARGINGSIZE), BorderLayout.SOUTH);
    getContentPane().add(Box.createHorizontalStrut(EcogridPreferencesTab.MARGINGSIZE), BorderLayout.WEST);
    setVisible(true);
}

From source file:BoxLayoutPane.java

public BoxLayoutPane() {
    // Use a BorderLayout layout manager to arrange various Box components
    this.setLayout(new BorderLayout());

    // Give the entire panel a margin by adding an empty border
    // We could also do this by overriding getInsets()
    this.setBorder(new EmptyBorder(10, 10, 10, 10));

    // Add a plain row of buttons along the top of the pane
    Box row = Box.createHorizontalBox();
    for (int i = 0; i < 4; i++) {
        JButton b = new JButton("B" + i);
        b.setFont(new Font("serif", Font.BOLD, 12 + i * 2));
        row.add(b);//from w  w w.j  a v  a2s.  co  m
    }
    this.add(row, BorderLayout.NORTH);

    // Add a plain column of buttons along the right edge
    // Use BoxLayout with a different kind of Swing container
    // Give the column a border: can't do this with the Box class
    JPanel col = new JPanel();
    col.setLayout(new BoxLayout(col, BoxLayout.Y_AXIS));
    col.setBorder(new TitledBorder(new EtchedBorder(), "Column"));
    for (int i = 0; i < 4; i++) {
        JButton b = new JButton("Button " + i);
        b.setFont(new Font("sanserif", Font.BOLD, 10 + i * 2));
        col.add(b);
    }
    this.add(col, BorderLayout.EAST); // Add column to right of panel

    // Add a button box along the bottom of the panel.
    // Use "Glue" to space the buttons evenly
    Box buttonbox = Box.createHorizontalBox();
    buttonbox.add(Box.createHorizontalGlue()); // stretchy space
    buttonbox.add(new JButton("Okay"));
    buttonbox.add(Box.createHorizontalGlue()); // stretchy space
    buttonbox.add(new JButton("Cancel"));
    buttonbox.add(Box.createHorizontalGlue()); // stretchy space
    buttonbox.add(new JButton("Help"));
    buttonbox.add(Box.createHorizontalGlue()); // stretchy space
    this.add(buttonbox, BorderLayout.SOUTH);

    // Create a component to display in the center of the panel
    JTextArea textarea = new JTextArea();
    textarea.setText("This component has 12-pixel margins on left and top"
            + " and has 72-pixel margins on right and bottom.");
    textarea.setLineWrap(true);
    textarea.setWrapStyleWord(true);

    // Use Box objects to give the JTextArea an unusual spacing
    // First, create a column with 3 kids. The first and last kids
    // are rigid spaces. The middle kid is the text area
    Box fixedcol = Box.createVerticalBox();
    fixedcol.add(Box.createVerticalStrut(12)); // 12 rigid pixels
    fixedcol.add(textarea); // Component fills in the rest
    fixedcol.add(Box.createVerticalStrut(72)); // 72 rigid pixels

    // Now create a row. Give it rigid spaces on the left and right,
    // and put the column from above in the middle.
    Box fixedrow = Box.createHorizontalBox();
    fixedrow.add(Box.createHorizontalStrut(12));
    fixedrow.add(fixedcol);
    fixedrow.add(Box.createHorizontalStrut(72));

    // Now add the JTextArea in the column in the row to the panel
    this.add(fixedrow, BorderLayout.CENTER);
}

From source file:org.jdal.swing.form.SimpleBoxFormBuilder.java

public void addBox(Component c) {
    if (rows == 0 && rowsHeight.isEmpty()) {
        log.warn("You must call row() before adding components. I will add a row with default height for you");
        row();/*from w  w w. jav  a  2s.c o m*/
    }
    Box column = getColumn();

    if (rows > 1)
        column.add(Box.createVerticalStrut(defaultSpace));

    column.add(c);

    // don't add Labels to focus transversal
    if (!(c instanceof JLabel)) {
        focusTransversal.add(c);
    } else { // null or empty labels don't size well
        if (StringUtils.isEmpty(((JLabel) c).getText()))
            ((JLabel) c).setText(" ");
    }

    index++;

}

From source file:be.tutul.naheulcraft.launcher.auth.LogInForm.java

private void createUserDropdownPanel(Font labelFont) {
    this.userDropdownPanel.setLayout(new GridBagLayout());
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.fill = 2;/*  w w w . j ava 2  s .  co  m*/
    constraints.gridx = 0;
    constraints.gridy = -1;
    constraints.weightx = 1.0D;

    this.userDropdownPanel.add(Box.createVerticalStrut(8), constraints);

    JLabel userDropdownLabel = new JLabel("Pseudo : ");
    userDropdownLabel.setFont(labelFont);
    this.userDropdownPanel.add(userDropdownLabel, constraints);
    this.userDropdownPanel.add(this.userDropdown, constraints);

    this.userDropdownPanel.setVisible(false);
}

From source file:pcgen.gui2.tabs.bio.CampaignHistoryInfoPane.java

private void initComponents() {
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

    addButton.setText("Add Next Chronicle");
    addButton.setActionCommand(ADD_COMMAND);
    allButton.setText("All");
    allButton.setActionCommand(ALL_COMMAND);
    noneButton.setText("None");
    noneButton.setActionCommand(NONE_COMMAND);

    Box hbox = Box.createHorizontalBox();
    hbox.add(Box.createRigidArea(new Dimension(5, 0)));
    hbox.add(new JLabel("Check an item to include on your Character Sheet"));
    hbox.add(Box.createRigidArea(new Dimension(5, 0)));
    hbox.add(allButton);//  w w  w  .j  a v  a2s  .  co m
    hbox.add(Box.createRigidArea(new Dimension(3, 0)));
    hbox.add(noneButton);
    hbox.add(Box.createHorizontalGlue());

    add(Box.createVerticalStrut(5));
    add(hbox);
    add(Box.createVerticalStrut(10));
    JScrollPane pane = new JScrollPane(chroniclesPane) {

        @Override
        public Dimension getMaximumSize() {
            Dimension size = getPreferredSize();
            size.width = Integer.MAX_VALUE;
            return size;
        }

        @Override
        public boolean isValidateRoot() {
            return false;
        }

    };
    pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    add(pane);
    add(Box.createVerticalStrut(10));
    addButton.setAlignmentX(0.5f);
    add(addButton);
    add(Box.createVerticalStrut(5));
    add(Box.createVerticalGlue());
}

From source file:com.googlecode.vfsjfilechooser2.accessories.DefaultAccessoriesPanel.java

private void initComponents() {
    buttonsPanel = new JPanel();
    buttonsPanel.setLayout(new GridLayout(0, 1, 3, 3));

    Action action;/*from  w w  w.  ja v a2s  .com*/

    action = new ManageBookmarksAction(VFSResources.getMessage("VFSJFileChooser.bookmarksLabelText"),
            getIcon("book.png"));
    bookmarksButton = new JButton(action);
    bookmarksButton.setHorizontalAlignment(SwingConstants.LEFT);

    action = new ConnectionWizardAction(VFSResources.getMessage("VFSJFileChooser.connectionButtonText"),
            getIcon("connect.png"));
    connectionsButton = new JButton(action);
    connectionsButton.setHorizontalAlignment(SwingConstants.LEFT);

    action = new LocalFilesAction(VFSResources.getMessage("VFSJFileChooser.localFilesButtonText"),
            getIcon("drive.png"));
    localFSButton = new JButton(action);
    localFSButton.setHorizontalAlignment(SwingConstants.LEFT);

    buttonsPanel.add(bookmarksButton);
    buttonsPanel.add(Box.createVerticalStrut(20));
    buttonsPanel.add(connectionsButton);
    buttonsPanel.add(Box.createVerticalStrut(20));
    buttonsPanel.add(localFSButton);

    add(buttonsPanel, BorderLayout.NORTH);
    add(new JPanel(), BorderLayout.CENTER);

    final Frame c = (Frame) SwingUtilities.getWindowAncestor(fileChooser);

    bookmarksDialog = new BookmarksDialog(c, fileChooser);

    connectionDialog = new ConnectionDialog(c, bookmarksDialog, fileChooser);
}

From source file:com.game.ui.views.ItemPanel.java

public void doCommonStuffForDropDown(DefaultComboBoxModel model) {
    comboBox = new JComboBox(model);
    comboBox.setSelectedIndex(-1);//w  w  w.j a va  2 s.c  om
    comboBox.setMaximumSize(new Dimension(100, 30));
    comboBox.setAlignmentX(0);
    comboBox.setActionCommand("dropDown");
    comboBox.addActionListener(this);
    add(Box.createVerticalStrut(10));
    add(comboBox);
    add(Box.createVerticalStrut(10));
}

From source file:org.jdal.swing.table.TablePanel.java

/**
 * Creates a new Component with PageableTable.
 * @return PageableTableComponent./*  w  w w  . j  a  va2s  .  co m*/
 */
private Component createTableBox() {
    Box tableBox = Box.createVerticalBox();
    tableBox.add(createControlBox());
    tableBox.add(Box.createVerticalStrut(5));
    table.setAlignmentX(Container.LEFT_ALIGNMENT);
    tableBox.add(table);

    return tableBox;
}

From source file:org.cytoscape.dyn.internal.graphMetrics.SaveChartDialog.java

public SaveChartDialog(JFrame frame, JFreeChart chart) {
    super(frame, "Save Chart to File", false);
    this.chart = chart;
    JPanel sizePanel = new JPanel(new GridLayout(2, 3, 4, 4));
    sizePanel.setBorder(BorderFactory.createTitledBorder("Image Size"));

    // Add a spinner for choosing width
    sizePanel.add(new JLabel("Width:", SwingConstants.RIGHT));
    int width = ChartPanel.DEFAULT_WIDTH;
    int minWidth = ChartPanel.DEFAULT_MINIMUM_DRAW_WIDTH;
    int maxWidth = ChartPanel.DEFAULT_MAXIMUM_DRAW_WIDTH;
    SpinnerModel widthSettings = new SpinnerNumberModel(width, minWidth, maxWidth, 1);
    sizePanel.add(widthSpinner = new JSpinner(widthSettings));
    sizePanel.add(new JLabel("pixels"));

    // Add a spinner for choosing height
    sizePanel.add(new JLabel("Height:", SwingConstants.RIGHT));
    int height = ChartPanel.DEFAULT_HEIGHT;
    int minHeight = ChartPanel.DEFAULT_MINIMUM_DRAW_HEIGHT;
    int maxHeight = ChartPanel.DEFAULT_MAXIMUM_DRAW_HEIGHT;
    SpinnerModel heightSettings = new SpinnerNumberModel(height, minHeight, maxHeight, 1);
    sizePanel.add(heightSpinner = new JSpinner(heightSettings));
    sizePanel.add(new JLabel("pixels"));

    JPanel buttonsPanel = new JPanel(new GridLayout(1, 2, 4, 0));
    saveChartButton = new JButton("Save");
    saveChartButton.setMaximumSize(new Dimension(Short.MAX_VALUE, saveChartButton.getHeight()));
    saveChartButton.addActionListener(this);
    cancelButton = new JButton("Cancel");
    cancelButton.setMaximumSize(new Dimension(Short.MAX_VALUE, cancelButton.getHeight()));
    cancelButton.addActionListener(this);
    buttonsPanel.add(saveChartButton);/* ww  w .  j av a 2  s  .c  o  m*/
    buttonsPanel.add(cancelButton);
    Box buttonsBox = Box.createHorizontalBox();
    buttonsBox.add(Box.createHorizontalGlue());
    buttonsBox.add(buttonsPanel);
    buttonsBox.add(Box.createHorizontalGlue());

    Container contentPane = getContentPane();
    contentPane.add(sizePanel, BorderLayout.NORTH);
    contentPane.add(Box.createVerticalStrut(3));
    contentPane.add(buttonsBox, BorderLayout.PAGE_END);
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    getRootPane().setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
    pack();
    setModal(true);
    setResizable(false);
    setLocationRelativeTo(frame);

}

From source file:org.datacleaner.widgets.OpenAnalysisJobFileChooserAccessory.java

public OpenAnalysisJobFileChooserAccessory(WindowContext windowContext, DataCleanerConfiguration configuration,
        DCFileChooser fileChooser,//from  w ww .j  a va2s  .  c  o  m
        Provider<OpenAnalysisJobActionListener> openAnalysisJobActionListenerProvider) {
    super();
    _windowContext = windowContext;
    _configuration = configuration;
    _centerPanel = new DCPanel();
    _centerPanel.setLayout(new VerticalLayout(0));
    _fileChooser = fileChooser;
    _fileChooser.addPropertyChangeListener(this);
    _openJobButton = getOpenJobButton();
    _openAnalysisJobActionListenerProvider = openAnalysisJobActionListenerProvider;

    setPreferredSize(WIDTH, 10);

    setBorder(new EmptyBorder(0, 10, 0, 0));
    setLayout(new BorderLayout());
    setVisible(false);

    final JLabel iconLabel = new JLabel(ICON_APP);

    final JLabel headerLabel = new JLabel("DataCleaner analysis job:");
    headerLabel.setFont(WidgetUtils.FONT_HEADER1);

    final DCPanel northPanel = new DCPanel();
    northPanel.setLayout(new VerticalLayout(0));
    northPanel.add(iconLabel);
    northPanel.add(Box.createVerticalStrut(10));
    northPanel.add(headerLabel);
    northPanel.add(Box.createVerticalStrut(10));
    northPanel.add(_centerPanel);
    northPanel.add(Box.createVerticalStrut(10));

    final DCPanel southPanel = new DCPanel();
    southPanel.setLayout(new VerticalLayout(0));
    northPanel.add(Box.createVerticalStrut(4));
    southPanel.add(_openJobButton);
    southPanel.add(Box.createVerticalStrut(4));
    southPanel.add(getOpenAsTemplateButton());

    add(WidgetUtils.scrolleable(northPanel), BorderLayout.CENTER);
    add(southPanel, BorderLayout.SOUTH);
}