Set Maximum Popup Displayed Items
Show Popup
Enable LightWeight Popup
Set Width by Rendered String
Set Action
Set Action Command Text
Set Enabled
Set New Item Type
Show Popup
Enable LightWeight Popup
Set Width by Rendered String
Set Action
Set Action Command Text
Set Enabled
Set New Item Type
Set Maximum Popup Displayed Items
jComboBox1.setMaximumRowCount(3);
Reset:
jComboBox1.setMaximumRowCount(8);
Show Popup
jComboBox1.showPopup();
Reset:
jComboBox1.hidePopup();
Enable LightWeight Popup
jComboBox1.setLightWeightPopupEnabled(true); //default
Reset:
jComboBox1.setLightWeightPopupEnabled(true); //default
Note:
Determines if the Popup is composed of light or heavy weight components
Set Width by Rendered String
jComboBox1.setPrototypeDisplayValue("Use this string to determine the width of the JComboBox");
Reset:
jComboBox1.setPrototypeDisplayValue(null);
Set Action
jComboBox1.setAction(new AbstractAction("New Action") {
@Override
public void actionPerformed(ActionEvent e) {
System.out.println("The new action has fired");
}
});
Reset:
jComboBox1.setAction(null);
Set Action Command Text
jComboBox1.setActionCommand("The New Action Command");
Reset:
jComboBox1.setActionCommand("comboBoxChanged");
Set Enabled
jComboBox1.setEnabled(true); //default
Reset:
jComboBox1.setEnabled(true); //default
Set New Item Type
jComboBox1.setModel(new DefaultComboBoxModel(new Color[]{Color.WHITE,Color.BLUE,Color.MAGENTA}));
Reset:
jComboBox1.setModel(new DefaultComboBoxModel());
Note:
Will have to add a new ListDataListener to the new Model (if needed)