Search in sources :

Example 76 with JComboBox

use of javax.swing.JComboBox in project cayenne by apache.

the class PKDBGeneratorPanel method initView.

private void initView() {
    attributes = new JComboBox();
    attributes.setEditable(false);
    attributes.setRenderer(new AttributeRenderer());
    DefaultFormBuilder builder = new DefaultFormBuilder(new FormLayout("right:70dlu, 3dlu, fill:200dlu", ""));
    builder.setDefaultDialogBorder();
    builder.append("Auto Incremented:", attributes);
    setLayout(new BorderLayout());
    add(builder.getPanel(), BorderLayout.CENTER);
}
Also used : FormLayout(com.jgoodies.forms.layout.FormLayout) JComboBox(javax.swing.JComboBox) BorderLayout(java.awt.BorderLayout) DefaultFormBuilder(com.jgoodies.forms.builder.DefaultFormBuilder)

Example 77 with JComboBox

use of javax.swing.JComboBox in project cayenne by apache.

the class DefaultWidgetFactory method createUndoableComboBox.

/**
 * Creates undoable JComboBox.
 */
public <T> JComboBox<T> createUndoableComboBox() {
    JComboBox<T> comboBox = new JComboBox<>();
    comboBox.addItemListener(new JComboBoxUndoListener());
    comboBox.setBackground(Color.WHITE);
    comboBox.setMaximumRowCount(ModelerPreferences.COMBOBOX_MAX_VISIBLE_SIZE);
    return comboBox;
}
Also used : JComboBox(javax.swing.JComboBox) JComboBoxUndoListener(org.apache.cayenne.modeler.undo.JComboBoxUndoListener)

Example 78 with JComboBox

use of javax.swing.JComboBox in project knime-core by knime.

the class JSnippetPanel method initComponents.

private void initComponents() {
    m_colList = new JList(new DefaultListModel());
    m_colList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    m_colList.addKeyListener(new KeyAdapter() {

        /**
         * {@inheritDoc}
         */
        @Override
        public void keyTyped(final KeyEvent e) {
            if (e.getKeyChar() == KeyEvent.VK_ENTER) {
                Object selected = m_colList.getSelectedValue();
                if (selected != null) {
                    onSelectionInColumnList(selected);
                }
            }
        }
    });
    m_colList.addMouseListener(new MouseAdapter() {

        /**
         * {@inheritDoc}
         */
        @Override
        public void mouseClicked(final MouseEvent e) {
            if (e.getClickCount() == 2) {
                Object selected = m_colList.getSelectedValue();
                if (selected != null) {
                    onSelectionInColumnList(selected);
                }
            }
        }
    });
    m_colList.setCellRenderer(new ListRenderer());
    m_flowVarsList = new JList(new DefaultListModel());
    m_flowVarsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    // enable tooltip
    m_flowVarsList.setToolTipText("");
    m_flowVarsList.addKeyListener(new KeyAdapter() {

        /**
         * {@inheritDoc}
         */
        @Override
        public void keyTyped(final KeyEvent e) {
            if (e.getKeyChar() == KeyEvent.VK_ENTER) {
                Object selected = m_flowVarsList.getSelectedValue();
                if (selected != null) {
                    onSelectionInVariableList(selected);
                }
            }
        }
    });
    m_flowVarsList.addMouseListener(new MouseAdapter() {

        /**
         * {@inheritDoc}
         */
        @Override
        public void mouseClicked(final MouseEvent e) {
            if (e.getClickCount() == 2) {
                Object selected = m_flowVarsList.getSelectedValue();
                if (selected != null) {
                    onSelectionInVariableList(selected);
                }
            }
        }
    });
    m_flowVarsList.setCellRenderer(new FlowVariableListCellRenderer());
    m_categories = new JComboBox(m_manipProvider.getCategories().toArray());
    m_categories.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            JComboBox cb = (JComboBox) e.getSource();
            String category = (String) cb.getSelectedItem();
            updateManipulatorList(category);
        }
    });
    m_manipulators = new JList(new DefaultListModel());
    m_manipulators.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    m_manipulators.setCellRenderer(new ManipulatorListCellRenderer());
    m_manipulators.addKeyListener(new KeyAdapter() {

        /**
         * {@inheritDoc}
         */
        @Override
        public void keyTyped(final KeyEvent e) {
            if (e.getKeyChar() == KeyEvent.VK_ENTER) {
                Object selected = m_manipulators.getSelectedValue();
                if (selected != null) {
                    onSelectionInManipulatorList(selected);
                }
            }
        }
    });
    m_manipulators.addMouseListener(new MouseAdapter() {

        /**
         * {@inheritDoc}
         */
        @Override
        public void mouseClicked(final MouseEvent e) {
            if (e.getClickCount() == 2) {
                Object selected = m_manipulators.getSelectedValue();
                if (selected != null) {
                    onSelectionInManipulatorList(selected);
                }
            }
        }
    });
    m_manipulators.addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(final ListSelectionEvent e) {
            Object selected = m_manipulators.getSelectedValue();
            if (selected != null) {
                Manipulator manipulator = (Manipulator) selected;
                m_description.setText(manipulator.getDescription());
                m_description.setCaretPosition(0);
            } else {
                m_description.setText("");
            }
        }
    });
    HTMLEditorKit kit = new HTMLEditorKit();
    StyleSheet css = new StyleSheet();
    css.addRule("* { font-family: sans-serif; }");
    kit.setStyleSheet(css);
    m_description = new JTextPane();
    m_description.setEditorKit(kit);
    m_description.setEditable(false);
    m_description.setBackground(getBackground());
    updateManipulatorList(ManipulatorProvider.ALL_CATEGORY);
    initSubComponents();
}
Also used : MouseEvent(java.awt.event.MouseEvent) JComboBox(javax.swing.JComboBox) ActionEvent(java.awt.event.ActionEvent) KeyAdapter(java.awt.event.KeyAdapter) MouseAdapter(java.awt.event.MouseAdapter) ListSelectionEvent(javax.swing.event.ListSelectionEvent) DefaultListModel(javax.swing.DefaultListModel) HTMLEditorKit(javax.swing.text.html.HTMLEditorKit) ListSelectionListener(javax.swing.event.ListSelectionListener) Manipulator(org.knime.base.node.preproc.stringmanipulation.manipulator.Manipulator) KeyEvent(java.awt.event.KeyEvent) FlowVariableListCellRenderer(org.knime.core.node.util.FlowVariableListCellRenderer) JTextPane(javax.swing.JTextPane) StyleSheet(javax.swing.text.html.StyleSheet) ActionListener(java.awt.event.ActionListener) JList(javax.swing.JList)

Example 79 with JComboBox

use of javax.swing.JComboBox in project knime-core by knime.

the class InFieldsTable method createInputCellEditor.

/**
 * Create cell editor for for the input columns / flow variables.
 */
private TableCellEditor createInputCellEditor() {
    JComboBox comboBox = new JComboBox();
    comboBox.setRenderer(new InputListCellRenderer());
    if (null != m_spec) {
        for (DataColumnSpec colSpec : m_spec) {
            comboBox.addItem(colSpec);
        }
    }
    if (null != m_flowVars) {
        for (FlowVariable flowVar : m_flowVars.values()) {
            comboBox.addItem(flowVar);
        }
    }
    DefaultCellEditor editor = new DefaultCellEditor(comboBox);
    editor.setClickCountToStart(2);
    return editor;
}
Also used : DataColumnSpec(org.knime.core.data.DataColumnSpec) JComboBox(javax.swing.JComboBox) FlowVariable(org.knime.core.node.workflow.FlowVariable) DefaultCellEditor(javax.swing.DefaultCellEditor)

Example 80 with JComboBox

use of javax.swing.JComboBox in project knime-core by knime.

the class DialogComponentDate method createDatePanel.

private JPanel createDatePanel() {
    // add the check box on top of the horizontal date panel
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    JPanel datePanel = new JPanel();
    // one text input field (year)
    m_yearUI = new JTextField(4);
    m_yearUI.addFocusListener(new FocusAdapter() {

        @Override
        public void focusGained(final FocusEvent e) {
            m_yearUI.selectAll();
        }
    });
    m_yearUI.getDocument().addDocumentListener(new AbstractValidateDocumentListener() {

        @Override
        protected void validate() {
            try {
                // if it is an integer it is a valid year
                updateModel();
            } catch (Exception e) {
                // else show error
                showError(m_yearUI);
            }
        }
    });
    datePanel.add(new JLabel("Year:"));
    datePanel.add(m_yearUI);
    // select boxes month
    Integer[] months = new Integer[12];
    for (int i = 0; i < 12; i++) {
        months[i] = Integer.valueOf(i + 1);
    }
    m_monthUI = new JComboBox(months);
    m_monthUI.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(final ItemEvent e) {
            try {
                updateModel();
            } catch (Exception ex) {
            // year may be invalid -> month is anyway a select box
            }
        }
    });
    datePanel.add(new JLabel("Month:"));
    datePanel.add(m_monthUI);
    // select box day
    Integer[] days = new Integer[31];
    for (int i = 0; i < 31; i++) {
        days[i] = Integer.valueOf(i + 1);
    }
    m_dayUI = new JComboBox(days);
    m_dayUI.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(final ItemEvent e) {
            try {
                updateModel();
            } catch (Exception ex) {
            // year may be invalid -> day is anyway a select box
            }
        }
    });
    datePanel.add(new JLabel("Day:"));
    datePanel.add(m_dayUI);
    panel.add(datePanel);
    return panel;
}
Also used : JPanel(javax.swing.JPanel) FocusAdapter(java.awt.event.FocusAdapter) ItemEvent(java.awt.event.ItemEvent) JComboBox(javax.swing.JComboBox) BoxLayout(javax.swing.BoxLayout) JLabel(javax.swing.JLabel) JTextField(javax.swing.JTextField) FocusEvent(java.awt.event.FocusEvent) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) NotConfigurableException(org.knime.core.node.NotConfigurableException) ItemListener(java.awt.event.ItemListener)

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