Search in sources :

Example 36 with SpringLayout

use of javax.swing.SpringLayout in project processdash by dtuma.

the class TaskScheduleChart method createConfigurationButton.

private void createConfigurationButton() {
    configurationButton = new ConfigurationButton();
    configurationButtonToggler = new ConfigurationButtonToggler();
    JPanel glassPane = new GlassPane();
    SpringLayout l = new SpringLayout();
    glassPane.setLayout(l);
    glassPane.add(configurationButton);
    l.putConstraint(SpringLayout.NORTH, configurationButton, 10, SpringLayout.NORTH, glassPane);
    l.putConstraint(SpringLayout.EAST, configurationButton, -8, SpringLayout.EAST, glassPane);
    setGlassPane(glassPane);
}
Also used : JPanel(javax.swing.JPanel) SpringLayout(javax.swing.SpringLayout)

Example 37 with SpringLayout

use of javax.swing.SpringLayout in project gate-core by GateNLP.

the class SpringUtilities method getConstraintsForCell.

/* Used by makeCompactGrid. */
private static SpringLayout.Constraints getConstraintsForCell(int row, int col, Container parent, int cols) {
    SpringLayout layout = (SpringLayout) parent.getLayout();
    Component c = parent.getComponent(row * cols + col);
    return layout.getConstraints(c);
}
Also used : SpringLayout(javax.swing.SpringLayout)

Example 38 with SpringLayout

use of javax.swing.SpringLayout in project gate-core by GateNLP.

the class SpringUtilities method makeCompactGrid.

/**
 * Aligns the first <code>rows</code> * <code>cols</code>
 * components of <code>parent</code> in
 * a grid. Each component in a column is as wide as the maximum
 * preferred width of the components in that column;
 * height is similarly determined for each row.
 * The parent is made just big enough to fit them all.
 *
 * @param rows number of rows
 * @param cols number of columns
 * @param initialX x location to start the grid at
 * @param initialY y location to start the grid at
 * @param xPad x padding between cells
 * @param yPad y padding between cells
 */
public static void makeCompactGrid(Container parent, int rows, int cols, int initialX, int initialY, int xPad, int yPad) {
    SpringLayout layout;
    try {
        layout = (SpringLayout) parent.getLayout();
    } catch (ClassCastException exc) {
        System.err.println("The first argument to makeCompactGrid must use SpringLayout.");
        return;
    }
    // Align all cells in each column and make them the same width.
    Spring x = Spring.constant(initialX);
    for (int c = 0; c < cols; c++) {
        Spring width = Spring.constant(0);
        for (int r = 0; r < rows; r++) {
            width = Spring.max(width, getConstraintsForCell(r, c, parent, cols).getWidth());
        }
        for (int r = 0; r < rows; r++) {
            SpringLayout.Constraints constraints = getConstraintsForCell(r, c, parent, cols);
            constraints.setX(x);
            constraints.setWidth(width);
        }
        x = Spring.sum(x, Spring.sum(width, Spring.constant(xPad)));
    }
    // Align all cells in each row and make them the same height.
    Spring y = Spring.constant(initialY);
    for (int r = 0; r < rows; r++) {
        Spring height = Spring.constant(0);
        for (int c = 0; c < cols; c++) {
            height = Spring.max(height, getConstraintsForCell(r, c, parent, cols).getHeight());
        }
        for (int c = 0; c < cols; c++) {
            SpringLayout.Constraints constraints = getConstraintsForCell(r, c, parent, cols);
            constraints.setY(y);
            constraints.setHeight(height);
        }
        y = Spring.sum(y, Spring.sum(height, Spring.constant(yPad)));
    }
    // Set the parent's size.
    SpringLayout.Constraints pCons = layout.getConstraints(parent);
    pCons.setConstraint(SpringLayout.SOUTH, y);
    pCons.setConstraint(SpringLayout.EAST, x);
}
Also used : SpringLayout(javax.swing.SpringLayout)

Example 39 with SpringLayout

use of javax.swing.SpringLayout in project bioformats by openmicroscopy.

the class ConfigWindow method doFormatLayout.

private void doFormatLayout(FormatEntry entry) {
    if (entry != null) {
        // build list of extensions
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < entry.suffixes.length; i++) {
            if (i > 0)
                sb.append(", ");
            sb.append(entry.suffixes[i]);
        }
        extensions.setText(sb.toString());
    }
    enabledBox.setSelected(isReaderEnabled(entry));
    windowlessBox.setSelected(isReaderWindowless(entry));
    formatInfo.removeAll();
    formatInfo.setLayout(new SpringLayout());
    formatInfo.add(makeLabel("Extensions", false));
    formatInfo.add(extensions);
    formatInfo.add(makeLabel("Enabled", false));
    formatInfo.add(enabledBox);
    formatInfo.add(makeLabel("Windowless", false));
    formatInfo.add(windowlessBox);
    // format-specific widgets
    int rows = entry == null ? 0 : entry.widgets.length;
    for (int i = 0; i < rows; i++) {
        formatInfo.add(makeLabel(entry.labels[i], false));
        formatInfo.add(entry.widgets[i]);
    }
    SpringUtilities.makeCompactGrid(formatInfo, 3 + rows, 2, PAD, PAD, PAD, PAD);
    formatInfo.validate();
    formatInfo.repaint();
}
Also used : SpringLayout(javax.swing.SpringLayout)

Example 40 with SpringLayout

use of javax.swing.SpringLayout in project bioformats by openmicroscopy.

the class SpringUtilities method getConstraintsForCell.

/* Used by makeCompactGrid. */
private static SpringLayout.Constraints getConstraintsForCell(int row, int col, Container parent, int cols) {
    SpringLayout layout = (SpringLayout) parent.getLayout();
    Component c = parent.getComponent(row * cols + col);
    return layout.getConstraints(c);
}
Also used : SpringLayout(javax.swing.SpringLayout) Component(java.awt.Component)

Aggregations

SpringLayout (javax.swing.SpringLayout)57 JLabel (javax.swing.JLabel)21 JPanel (javax.swing.JPanel)21 Spring (javax.swing.Spring)21 BorderLayout (java.awt.BorderLayout)18 JTextField (javax.swing.JTextField)17 ActionEvent (java.awt.event.ActionEvent)15 ActionListener (java.awt.event.ActionListener)15 Component (java.awt.Component)12 JDialog (javax.swing.JDialog)12 Dimension (java.awt.Dimension)11 JButton (javax.swing.JButton)10 JScrollPane (javax.swing.JScrollPane)10 EmptyBorder (javax.swing.border.EmptyBorder)9 FlowLayout (java.awt.FlowLayout)8 JMenuItem (javax.swing.JMenuItem)7 Constraints (javax.swing.SpringLayout.Constraints)6 ItemEvent (java.awt.event.ItemEvent)5 Callable (java.util.concurrent.Callable)5 JMenu (javax.swing.JMenu)5