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);
}
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;
}
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();
}
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;
}
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;
}
Aggregations