use of javax.swing.DefaultComboBoxModel in project OpenAM by OpenRock.
the class ListJPanel method addWebContainer.
public void addWebContainer(ImageListEntry entry) {
ComboBoxModel model = webContainerjComboBox.getModel();
if (model instanceof DefaultComboBoxModel) {
((DefaultComboBoxModel) model).addElement(entry);
} else {
DefaultComboBoxModel newModel = new DefaultComboBoxModel();
newModel.addElement(entry);
webContainerjComboBox.setModel(newModel);
}
}
use of javax.swing.DefaultComboBoxModel in project javatari by ppeccin.
the class JComboBoxNim method refreshJoysticks.
private void refreshJoysticks() {
if (refreshInProgress)
return;
refreshInProgress = true;
String pre = "But ";
String empty = " ";
Vector<DeviceOption> joyP0Opts = room.joystickControls().getJoystick0DeviceOptions();
if (!joyP0Opts.isEmpty()) {
joyP0Device.setModel(new DefaultComboBoxModel(joyP0Opts));
joyP0Device.setSelectedItem(room.joystickControls().getJoystick0DeviceOption());
joyP0Device.setEnabled(true);
} else {
joyP0Device.setModel(new DefaultComboBoxModel(new Vector<String>(Arrays.asList(new String[] { "Not Supported" }))));
joyP0Device.setSelectedIndex(0);
joyP0Device.setEnabled(false);
}
Vector<DeviceOption> joyP1Opts = room.joystickControls().getJoystick1DeviceOptions();
if (!joyP1Opts.isEmpty()) {
joyP1Device.setModel(new DefaultComboBoxModel(room.joystickControls().getJoystick1DeviceOptions()));
joyP1Device.setSelectedItem(room.joystickControls().getJoystick1DeviceOption());
joyP1Device.setEnabled(true);
} else {
joyP1Device.setModel(new DefaultComboBoxModel(new Vector<String>(Arrays.asList(new String[] { "Not Supported" }))));
joyP1Device.setSelectedIndex(0);
joyP1Device.setEnabled(false);
}
boolean joy0Present = room.joystickControls().isStarted() && room.joystickControls().getJoystick0() != null;
boolean joy1Present = room.joystickControls().isStarted() && room.joystickControls().getJoystick1() != null;
joyP0Button.setText(Parameters.JOY_P0_BUTTON == CONTROL_UNSET ? empty : pre + (Parameters.JOY_P0_BUTTON + 1));
joyP0Button2.setText(Parameters.JOY_P0_BUTTON2 == CONTROL_UNSET ? empty : pre + (Parameters.JOY_P0_BUTTON2 + 1));
joyP0Reset.setText(Parameters.JOY_P0_RESET == CONTROL_UNSET ? empty : pre + (Parameters.JOY_P0_RESET + 1));
joyP0Select.setText(Parameters.JOY_P0_SELECT == CONTROL_UNSET ? empty : pre + (Parameters.JOY_P0_SELECT + 1));
joyP0Pause.setText(Parameters.JOY_P0_PAUSE == CONTROL_UNSET ? empty : pre + (Parameters.JOY_P0_PAUSE + 1));
joyP0FastSpeed.setText(Parameters.JOY_P0_FAST_SPPED == CONTROL_UNSET ? empty : pre + (Parameters.JOY_P0_FAST_SPPED + 1));
joyP1Button.setText(Parameters.JOY_P1_BUTTON == CONTROL_UNSET ? empty : pre + (Parameters.JOY_P1_BUTTON + 1));
joyP1Button2.setText(Parameters.JOY_P1_BUTTON2 == CONTROL_UNSET ? empty : pre + (Parameters.JOY_P1_BUTTON2 + 1));
joyP1Reset.setText(Parameters.JOY_P1_RESET == CONTROL_UNSET ? empty : pre + (Parameters.JOY_P1_RESET + 1));
joyP1Select.setText(Parameters.JOY_P1_SELECT == CONTROL_UNSET ? empty : pre + (Parameters.JOY_P1_SELECT + 1));
joyP1Pause.setText(Parameters.JOY_P1_PAUSE == CONTROL_UNSET ? empty : pre + (Parameters.JOY_P1_PAUSE + 1));
joyP1FastSpeed.setText(Parameters.JOY_P1_FAST_SPPED == CONTROL_UNSET ? empty : pre + (Parameters.JOY_P1_FAST_SPPED + 1));
joyP0Deadzone.setEnabled(joy0Present);
joyP1Deadzone.setEnabled(joy1Present);
joyP0XAxis.setEnabled(joy0Present);
joyP1XAxis.setEnabled(joy1Present);
if (room.joystickControls().paddleMode) {
joyP0DeadzoneL.setText("Center");
joyP0Deadzone.setModel(new DefaultComboBoxModel(PADDLE_CENTER_OPTIONS));
joyP0Deadzone.setSelectedItem(Parameters.JOY_P0_PADDLE_CENTER == 0 ? PADDLE_CENTER_ZERO : String.format("%+d", Parameters.JOY_P0_PADDLE_CENTER));
joyP0Sensitivity.setEnabled(joy0Present);
joyP0Sensitivity.setSelectedItem(Parameters.JOY_P0_PADDLE_SENS == 0 ? PADDLE_SENS_DIGITAL : "" + Parameters.JOY_P0_PADDLE_SENS + "%");
joyP0XAxisL.setText("Axis");
joyP0XAxis.setSelectedIndex(Parameters.JOY_P0_PAD_AXIS + (Parameters.JOY_P0_PAD_AXIS_SIGNAL == -1 ? 6 : 0));
joyP0YAxis.setEnabled(false);
joyP0YAxis.setSelectedIndex(1);
joyP1DeadzoneL.setText("Center");
joyP1Deadzone.setModel(new DefaultComboBoxModel(PADDLE_CENTER_OPTIONS));
joyP1Deadzone.setSelectedItem(Parameters.JOY_P1_PADDLE_CENTER == 0 ? PADDLE_CENTER_ZERO : String.format("%+d", Parameters.JOY_P1_PADDLE_CENTER));
joyP1Sensitivity.setEnabled(joy1Present);
joyP1Sensitivity.setSelectedItem(Parameters.JOY_P1_PADDLE_SENS == 0 ? PADDLE_SENS_DIGITAL : "" + Parameters.JOY_P1_PADDLE_SENS + "%");
joyP1XAxisL.setText("Axis");
joyP1XAxis.setSelectedIndex(Parameters.JOY_P1_PAD_AXIS + (Parameters.JOY_P1_PAD_AXIS_SIGNAL == -1 ? 6 : 0));
joyP1YAxis.setEnabled(false);
joyP1YAxis.setSelectedIndex(1);
joystick0Icon.setIcon(joy0Present ? paddleIcon : paddleIconGrayed);
joystick1Icon.setIcon(joy1Present ? paddleIcon : paddleIconGrayed);
} else {
joyP0DeadzoneL.setText("Dead zone");
joyP0Deadzone.setModel(new DefaultComboBoxModel(JOY_DEADZONE_OPTIONS));
joyP0Deadzone.setSelectedItem("" + Parameters.JOY_P0_DEADZONE + "%");
joyP0Sensitivity.setEnabled(false);
joyP0Sensitivity.setSelectedIndex(0);
joyP0XAxisL.setText("X Axis");
joyP0XAxis.setSelectedIndex(Parameters.JOY_P0_XAXIS + (Parameters.JOY_P0_XAXIS_SIGNAL == -1 ? 6 : 0));
joyP0YAxis.setEnabled(joy0Present);
joyP0YAxis.setSelectedIndex(Parameters.JOY_P0_YAXIS + (Parameters.JOY_P0_YAXIS_SIGNAL == -1 ? 6 : 0));
joyP1DeadzoneL.setText("Dead zone");
joyP1Deadzone.setModel(new DefaultComboBoxModel(JOY_DEADZONE_OPTIONS));
joyP1Deadzone.setSelectedItem("" + Parameters.JOY_P1_DEADZONE + "%");
joyP1Sensitivity.setEnabled(false);
joyP1Sensitivity.setSelectedIndex(0);
joyP1XAxisL.setText("X Axis");
joyP1XAxis.setSelectedIndex(Parameters.JOY_P1_XAXIS + (Parameters.JOY_P1_XAXIS_SIGNAL == -1 ? 6 : 0));
joyP1YAxis.setEnabled(joy1Present);
joyP1YAxis.setSelectedIndex(Parameters.JOY_P1_YAXIS + (Parameters.JOY_P1_YAXIS_SIGNAL == -1 ? 6 : 0));
joystick0Icon.setIcon(joy0Present ? joystickIcon : joystickIconGrayed);
joystick1Icon.setIcon(joy1Present ? joystickIcon : joystickIconGrayed);
}
for (JTextField f : joystick0FieldsList) f.setEnabled(joy0Present);
for (JTextField f : joystick1FieldsList) f.setEnabled(joy1Present);
for (JTextField field : joysticksFieldsList) if (field == joystickEditField) {
field.setBackground(EDDITING);
field.setSelectionStart(0);
field.setSelectionEnd(0);
} else
field.setBackground(field.getText().trim().isEmpty() ? UNMAPPED : Color.WHITE);
joysticksEdittingL.setText(joystickEditField != null ? "- press button -" : "");
defaultsB.setText("Defaults");
defaultsB.setVisible(true);
String message;
if (room.awtControls().p1ControlsMode ^ room.joystickControls().swappedMode) {
joysticksPlayer1Lb.setText("Player 2");
joysticksPlayer2Lb.setText("Player 1");
message = "Swapped";
} else {
joysticksPlayer1Lb.setText("Player 1");
joysticksPlayer2Lb.setText("Player 2");
message = "";
}
joysticksMessageL.setText(message);
refreshInProgress = false;
}
use of javax.swing.DefaultComboBoxModel in project adempiere by adempiere.
the class PLAFEditor method setLFSelection.
// dynInit
/**
* Set Picks From Environment
*/
private void setLFSelection() {
m_setting = true;
// Search for PLAF
ValueNamePair plaf = null;
LookAndFeel lookFeel = UIManager.getLookAndFeel();
String look = lookFeel.getClass().getName();
for (int i = 0; i < AdempierePLAF.getPLAFs().length; i++) {
ValueNamePair vp = AdempierePLAF.getPLAFs()[i];
if (vp.getValue().equals(look)) {
plaf = vp;
break;
}
}
if (plaf != null)
lfField.setSelectedItem(plaf);
// Search for Theme
MetalTheme metalTheme = null;
ValueNamePair theme = null;
boolean metal = UIManager.getLookAndFeel() instanceof MetalLookAndFeel;
themeField.setModel(new DefaultComboBoxModel(AdempierePLAF.getThemes()));
if (metal) {
theme = null;
AppContext context = AppContext.getAppContext();
metalTheme = (MetalTheme) context.get("currentMetalTheme");
if (metalTheme != null) {
String lookTheme = metalTheme.getName();
for (int i = 0; i < AdempierePLAF.getThemes().length; i++) {
ValueNamePair vp = AdempierePLAF.getThemes()[i];
if (vp.getName().equals(lookTheme)) {
theme = vp;
break;
}
}
}
if (theme != null)
themeField.setSelectedItem(theme);
}
m_setting = false;
log.info(lookFeel + " - " + metalTheme);
}
use of javax.swing.DefaultComboBoxModel in project adempiere by adempiere.
the class VLookup method dispose.
// VLookup
/**
* Dispose
*/
public void dispose() {
m_text = null;
m_button = null;
m_lookup = null;
m_mField = null;
//
m_combo.getEditor().getEditorComponent().removeFocusListener(this);
m_combo.getEditor().getEditorComponent().removeMouseListener(mouseAdapter);
m_combo.removeFocusListener(this);
m_combo.removeActionListener(this);
// remove reference
m_combo.setModel(new DefaultComboBoxModel());
// m_combo.removeAllItems();
m_combo = null;
}
use of javax.swing.DefaultComboBoxModel in project adempiere by adempiere.
the class Find method actionPerformed.
// dispose
/**************************************************************************
* Action Listener
* @param e ActionEvent
*/
public void actionPerformed(ActionEvent e) {
log.info(e.getActionCommand());
//
if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL))
cmd_cancel();
else if (e.getActionCommand().equals(ConfirmPanel.A_REFRESH))
cmd_refresh();
else //
if (e.getActionCommand().equals(ConfirmPanel.A_NEW)) {
m_query = MQuery.getNoRecordQuery(m_tableName, true);
m_total = 0;
dispose();
} else //
if (e.getSource() == bIgnore)
cmd_ignore();
else if (e.getSource() == bNew)
cmd_new();
else if (e.getSource() == bSave)
cmd_save(true);
else if (e.getSource() == bDelete)
cmd_delete();
else //
if (e.getSource() == columns) {
String columnName = null;
Object selected = columns.getSelectedItem();
if (selected != null) {
if (selected instanceof ValueNamePair) {
ValueNamePair column = (ValueNamePair) selected;
columnName = column.getValue();
} else {
columnName = selected.toString();
}
}
if (columnName != null) {
log.config("Column: " + columnName);
if (columnName.endsWith("_ID") || columnName.endsWith("_Acct"))
operators.setModel(new DefaultComboBoxModel(MQuery.OPERATORS_ID));
else if (columnName.startsWith("Is"))
operators.setModel(new DefaultComboBoxModel(MQuery.OPERATORS_YN));
else
operators.setModel(new DefaultComboBoxModel(MQuery.OPERATORS));
}
} else if (e.getSource() == fQueryName) {
// fQueryName has changed.
int index = fQueryName.getSelectedIndex();
if (index < 0) {
if (fQueryName.getSelectedItem() == null || fQueryName.getSelectedItem().equals(m_sTipText)) {
return;
}
} else if (index == 0) {
// no query - wipe and start over.
advancedTable.stopEditor(false);
DefaultTableModel model = (DefaultTableModel) advancedTable.getModel();
int cnt = model.getRowCount();
if (cnt > 0) {
for (int i = cnt - 1; i >= 0; i--) {
model.removeRow(i);
}
// No row - create one.
cmd_new();
}
fQueryName.setSelectedIndex(-1);
fQueryName.setSelectedItem(m_sTipText);
advancedTable.requestFocusInWindow();
} else
parseUserQuery(userQueries[index - 1]);
} else // ConfirmPanel.A_OK and enter in fields
{
if (e.getSource() == confirmPanelA.getOKButton())
cmd_ok_Advanced();
else if (e.getSource() == confirmPanelS.getOKButton())
cmd_ok_Simple();
else if (e.getSource() instanceof JTextField && tabbedPane.getSelectedIndex() == 0)
cmd_ok_Simple();
}
}
Aggregations