Search in sources :

Example 11 with JComboBox

use of javax.swing.JComboBox in project OpenNotebook by jaltekruse.

the class EnumeratedAdjuster method addPanelContent.

@Override
public void addPanelContent() {
    if (displayFormat == COMBO_BOX) {
        setLayout(new GridBagLayout());
        GridBagConstraints con = new GridBagConstraints();
        con.fill = GridBagConstraints.HORIZONTAL;
        con.weightx = .1;
        con.gridx = 0;
        con.gridy = 0;
        con.insets = new Insets(0, 10, 0, 0);
        add(new JLabel(mAtt.getName()), con);
        con.insets = new Insets(0, 10, 0, 5);
        con.weightx = 1;
        con.gridx = 1;
        final JComboBox valueChoices = new JComboBox(mAtt.getPossibleValues());
        valueChoices.setSelectedItem(mAtt.getValue());
        valueChoices.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent ev) {
                mAtt.setValue((String) valueChoices.getSelectedItem());
                if (notebookPanel != null) {
                    notebookPanel.getCurrentDocViewer().addUndoState();
                    notebookPanel.getCurrentDocViewer().repaintDoc();
                }
            }
        });
        this.add(valueChoices, con);
    } else if (displayFormat == RADIO_BUTTON_ROW) {
        setLayout(new GridBagLayout());
        GridBagConstraints con = new GridBagConstraints();
        con.fill = GridBagConstraints.HORIZONTAL;
        con.weightx = .1;
        con.gridwidth = mAtt.getPossibleValues().length;
        con.gridx = 0;
        con.gridy = 0;
        con.insets = new Insets(2, 2, 2, 2);
        Font f = new Font("Arial", Font.PLAIN, 12);
        Font smallF = new Font("Arial", Font.PLAIN, 11);
        JLabel label = new JLabel(mAtt.getName());
        label.setFont(f);
        add(label, con);
        con.gridwidth = 1;
        con.weightx = 1;
        con.gridy++;
        final ButtonGroup group = new ButtonGroup();
        for (final String s : mAtt.getPossibleValues()) {
            final JRadioButton button = new JRadioButton(s);
            button.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent ev) {
                    mAtt.setValue(s);
                    if (notebookPanel != null) {
                        notebookPanel.getCurrentDocViewer().addUndoState();
                        notebookPanel.getCurrentDocViewer().repaintDoc();
                    }
                }
            });
            if (mAtt.getValue().equals(s)) {
                button.setSelected(true);
            }
            button.setFont(smallF);
            this.add(button, con);
            group.add(button);
            con.gridx++;
        }
    } else if (displayFormat == RADIO_BUTTON_COLOUMN) {
    }
}
Also used : GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) JRadioButton(javax.swing.JRadioButton) GridBagLayout(java.awt.GridBagLayout) JComboBox(javax.swing.JComboBox) ActionListener(java.awt.event.ActionListener) ButtonGroup(javax.swing.ButtonGroup) ActionEvent(java.awt.event.ActionEvent) JLabel(javax.swing.JLabel) Font(java.awt.Font)

Example 12 with JComboBox

use of javax.swing.JComboBox in project qi4j-sdk by Qi4j.

the class EntityViewer method $$$setupUI$$$.

/**
     * Method generated by IntelliJ IDEA GUI Designer
     * >>> IMPORTANT!! <<<
     * DO NOT edit this method OR call it in your code!
     *
     */
private void $$$setupUI$$$() {
    mainPane = new JPanel();
    mainPane.setLayout(new BorderLayout(0, 0));
    splitPane = new JSplitPane();
    mainPane.add(splitPane, BorderLayout.CENTER);
    propertiesAreaPane = new JPanel();
    propertiesAreaPane.setLayout(new BorderLayout(0, 0));
    splitPane.setRightComponent(propertiesAreaPane);
    final JPanel panel1 = new JPanel();
    panel1.setLayout(new GridBagLayout());
    propertiesAreaPane.add(panel1, BorderLayout.NORTH);
    entitiesCombo = new JComboBox();
    GridBagConstraints gbc;
    gbc = new GridBagConstraints();
    gbc.gridx = 2;
    gbc.gridy = 0;
    gbc.gridwidth = 3;
    gbc.weightx = 0.3;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    panel1.add(entitiesCombo, gbc);
    final JLabel label1 = new JLabel();
    label1.setText("Entity");
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.anchor = GridBagConstraints.WEST;
    panel1.add(label1, gbc);
    final JPanel spacer1 = new JPanel();
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    panel1.add(spacer1, gbc);
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) BorderLayout(java.awt.BorderLayout) GridBagLayout(java.awt.GridBagLayout) JComboBox(javax.swing.JComboBox) JLabel(javax.swing.JLabel) JSplitPane(javax.swing.JSplitPane)

Example 13 with JComboBox

use of javax.swing.JComboBox in project checkstyle by checkstyle.

the class MainFrame method createButtonsPanel.

/**
     * Create buttons panel.
     * @return buttons panel.
     */
private JPanel createButtonsPanel() {
    final JButton openFileButton = new JButton(new FileSelectionAction());
    openFileButton.setMnemonic(KeyEvent.VK_S);
    openFileButton.setText("Open File");
    reloadAction.setEnabled(false);
    final JButton reloadFileButton = new JButton(reloadAction);
    reloadFileButton.setMnemonic(KeyEvent.VK_R);
    reloadFileButton.setText("Reload File");
    final JComboBox<ParseMode> modesCombobox = new JComboBox<>(ParseMode.values());
    modesCombobox.setSelectedIndex(0);
    modesCombobox.addActionListener(e -> {
        model.setParseMode((ParseMode) modesCombobox.getSelectedItem());
        reloadAction.actionPerformed(null);
    });
    final JLabel modesLabel = new JLabel("Modes:", SwingConstants.RIGHT);
    final int leftIndentation = 10;
    modesLabel.setBorder(BorderFactory.createEmptyBorder(0, leftIndentation, 0, 0));
    final JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new GridLayout(1, 2));
    buttonPanel.add(openFileButton);
    buttonPanel.add(reloadFileButton);
    final JPanel modesPanel = new JPanel();
    modesPanel.add(modesLabel);
    modesPanel.add(modesCombobox);
    final JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BorderLayout());
    mainPanel.add(buttonPanel);
    mainPanel.add(modesPanel, BorderLayout.LINE_END);
    return mainPanel;
}
Also used : JPanel(javax.swing.JPanel) GridLayout(java.awt.GridLayout) JComboBox(javax.swing.JComboBox) BorderLayout(java.awt.BorderLayout) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) ParseMode(com.puppycrawl.tools.checkstyle.gui.MainFrameModel.ParseMode)

Example 14 with JComboBox

use of javax.swing.JComboBox in project pcgen by PCGen.

the class ComboSelectionBox method initComponents.

private void initComponents() {
    comboBox = new JComboBox();
    setBorder(comboBox.getBorder());
    comboBox.setBorder(BorderFactory.createEmptyBorder());
    button = new JButton(new ButtonAction());
    button.setEnabled(false);
    button.setMargin(new java.awt.Insets(0, 0, 0, 0));
    add(comboBox, BorderLayout.CENTER);
    add(button, BorderLayout.LINE_END);
}
Also used : JComboBox(javax.swing.JComboBox) JButton(javax.swing.JButton)

Example 15 with JComboBox

use of javax.swing.JComboBox in project Info-Evaluation by TechnionYP5777.

the class InteractiveFrame method addEventButtonOnClick.

public void addEventButtonOnClick() {
    btnAddEvent.addActionListener(l -> {
        inputAccepted = false;
        String input = txtEnterYourEvent.getText();
        if (!"".equals(input))
            try {
                txtEnterYourEvent.setText("Loading please wait...");
                events.addSource(input, "2017");
                txtEnterYourEvent.setText(input);
            } catch (Exception e) {
                txtEnterYourEvent.setText("Could not parse, please try again");
                return;
            }
        inputAccepted = true;
        for (InteractiveTableTuple itt : events.getInteractiveData()) {
            Object[] e = new Object[3];
            e[0] = itt.getName();
            e[1] = utilDateToSQLDateConvertor(itt.getRegularDate());
            JComboBox<String> reasonsOptions = new JComboBox<>();
            itt.getReasons().stream().forEach(x -> reasonsOptions.addItem(x.getReason()));
            reasonsOptions.setVisible(true);
            txtEnterYourEvent.setText("Click to choose the most suitable reason");
            table.getColumnModel().getColumn(2).setCellEditor(new DefaultCellEditor(reasonsOptions));
            e[2] = itt.getReasons().get(0).getReason();
            ((DefaultTableModel) table.getModel()).addRow(e);
        }
    });
}
Also used : JComboBox(javax.swing.JComboBox) DefaultTableModel(javax.swing.table.DefaultTableModel) DefaultCellEditor(javax.swing.DefaultCellEditor)

Aggregations

JComboBox (javax.swing.JComboBox)226 JLabel (javax.swing.JLabel)97 JPanel (javax.swing.JPanel)88 ActionEvent (java.awt.event.ActionEvent)69 ActionListener (java.awt.event.ActionListener)66 JButton (javax.swing.JButton)55 GridBagLayout (java.awt.GridBagLayout)42 GridBagConstraints (java.awt.GridBagConstraints)41 Insets (java.awt.Insets)40 Dimension (java.awt.Dimension)39 JScrollPane (javax.swing.JScrollPane)37 JTextField (javax.swing.JTextField)36 BoxLayout (javax.swing.BoxLayout)34 JCheckBox (javax.swing.JCheckBox)33 DefaultCellEditor (javax.swing.DefaultCellEditor)27 JTable (javax.swing.JTable)26 BorderLayout (java.awt.BorderLayout)25 Component (java.awt.Component)25 TableColumn (javax.swing.table.TableColumn)23 DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)22