Search in sources :

Example 66 with GridLayout

use of java.awt.GridLayout in project java-design-patterns by iluwatar.

the class Client method setup.

private void setup() {
    setLayout(new BorderLayout());
    JPanel panel = new JPanel();
    add(jl, BorderLayout.SOUTH);
    add(panel, BorderLayout.CENTER);
    panel.setLayout(new GridLayout(6, 2));
    panel.add(new JLabel("Name"));
    panel.add(jtFields[0]);
    panel.add(new JLabel("Contact Number"));
    panel.add(jtFields[1]);
    panel.add(new JLabel("Address"));
    panel.add(jtAreas[0]);
    panel.add(new JLabel("Deposit Number"));
    panel.add(jtFields[2]);
    panel.add(new JLabel("Order"));
    panel.add(jtAreas[1]);
    panel.add(clearButton);
    panel.add(processButton);
    clearButton.addActionListener(e -> {
        for (JTextArea i : jtAreas) {
            i.setText("");
        }
        for (JTextField i : jtFields) {
            i.setText("");
        }
    });
    processButton.addActionListener(e -> {
        Order order = new Order(jtFields[0].getText(), jtFields[1].getText(), jtAreas[0].getText(), jtFields[2].getText(), jtAreas[1].getText());
        jl.setText(sendRequest(order));
    });
    JRootPane rootPane = SwingUtilities.getRootPane(processButton);
    rootPane.setDefaultButton(processButton);
    setVisible(true);
}
Also used : JPanel(javax.swing.JPanel) GridLayout(java.awt.GridLayout) JTextArea(javax.swing.JTextArea) BorderLayout(java.awt.BorderLayout) JLabel(javax.swing.JLabel) JRootPane(javax.swing.JRootPane) JTextField(javax.swing.JTextField)

Example 67 with GridLayout

use of java.awt.GridLayout in project n2a by frothga.

the class Lay method GLtg.

public static JPanel GLtg(Container target, int rows, int cols, Object... args) {
    HintList hints = new HintList();
    List<Component> cmpsChosen = new ArrayList<Component>();
    for (Object arg : args) {
        // Add any hints
        if (arg instanceof String) {
            hints.addHints(parseHints((String) arg));
        // Add components
        } else if (arg instanceof Component) {
            cmpsChosen.add((Component) arg);
        }
    // Else ignore
    }
    Container cont = chooseContainer(target, hints);
    GridLayout gl = new GridLayout(rows, cols, 0, 0);
    cont.setLayout(gl);
    for (Component c : cmpsChosen) {
        cont.add(c);
    }
    setHints(cont, hints);
    return (target == null) ? (JPanel) cont : null;
}
Also used : Container(java.awt.Container) RootPaneContainer(javax.swing.RootPaneContainer) GridLayout(java.awt.GridLayout) ArrayList(java.util.ArrayList) Component(java.awt.Component) JComponent(javax.swing.JComponent) JTextComponent(javax.swing.text.JTextComponent)

Example 68 with GridLayout

use of java.awt.GridLayout in project cayenne by apache.

the class MultiColumnBrowser method adjustViewColumns.

/**
 * Expands or contracts the view by <code>delta</code> columns. Never
 * contracts the view below <code>minColumns</code>.
 */
private void adjustViewColumns(int delta) {
    if (delta == 0) {
        return;
    }
    setLayout(new GridLayout(1, columns.size() + delta, 3, 3));
    if (delta > 0) {
        for (int i = 0; i < delta; i++) {
            appendColumn();
        }
    } else {
        for (int i = -delta; i > 0 && columns.size() > minColumns; i--) {
            removeLastColumn();
        }
    }
    refreshPreferredSize();
    revalidate();
}
Also used : GridLayout(java.awt.GridLayout)

Example 69 with GridLayout

use of java.awt.GridLayout in project knime-core by knime.

the class StringManipulationNodeDialog method createPanel.

/**
 * @since 3.3
 */
protected JPanel createPanel() {
    JPanel southPanel = new JPanel(new GridLayout(0, 2));
    JPanel replaceOrAppend = createAndOrReplacePanel();
    southPanel.add(replaceOrAppend);
    JPanel returnTypeAndCompilation = createReturnTypeAndCompilationPanel();
    southPanel.add(returnTypeAndCompilation);
    JPanel p = new JPanel(new BorderLayout());
    p.add(m_snippetPanel, BorderLayout.CENTER);
    p.add(southPanel, BorderLayout.SOUTH);
    p.setPreferredSize(new Dimension(820, 420));
    return p;
}
Also used : JPanel(javax.swing.JPanel) GridLayout(java.awt.GridLayout) BorderLayout(java.awt.BorderLayout) Dimension(java.awt.Dimension)

Example 70 with GridLayout

use of java.awt.GridLayout in project knime-core by knime.

the class TimeMissingValueHandlingPanel method createWarningLabel.

private static Component createWarningLabel(final List<String> warningMessages) {
    JPanel thin = new JPanel(new GridLayout(warningMessages.size(), 1));
    for (int i = 0; i < warningMessages.size(); i++) {
        String message = warningMessages.get(i);
        thin.add(new JLabel(message));
    }
    return thin;
}
Also used : JPanel(javax.swing.JPanel) GridLayout(java.awt.GridLayout) JLabel(javax.swing.JLabel)

Aggregations

GridLayout (java.awt.GridLayout)189 JPanel (javax.swing.JPanel)149 JLabel (javax.swing.JLabel)79 BorderLayout (java.awt.BorderLayout)67 Dimension (java.awt.Dimension)51 JButton (javax.swing.JButton)41 ActionEvent (java.awt.event.ActionEvent)36 JScrollPane (javax.swing.JScrollPane)34 ActionListener (java.awt.event.ActionListener)32 Insets (java.awt.Insets)28 JCheckBox (javax.swing.JCheckBox)28 JTextField (javax.swing.JTextField)28 GridBagConstraints (java.awt.GridBagConstraints)24 GridBagLayout (java.awt.GridBagLayout)23 ButtonGroup (javax.swing.ButtonGroup)22 FlowLayout (java.awt.FlowLayout)21 BoxLayout (javax.swing.BoxLayout)21 TitledBorder (javax.swing.border.TitledBorder)19 PlotCanvas (smile.plot.PlotCanvas)16 EmptyBorder (javax.swing.border.EmptyBorder)15