Say I have a JComboBox which contains elements that are in a vector...
public class Shade(){
//code for creating panels etc and other components/containers
JCheckBox primary = new JCheckBox("Primary", false);
Vector<String> colours = new Vector<String>();
}
public Shade(){
//setTitle, look&feel, defaultCloseOperation, Layouts etc etc...
colours.add(0, "Purple);
colours.add(1, "Red");
colours.add(2, "Blue");
colours.add(3, "Magenta");
JComboBox<String> colourSelector = new JComboBox<String>(colours);
}
If the JCheckBox primary is selected I want to 'hide' the colours purple and magneta from the JComboBox, once the primary JCheckBox has been deselected I would like to reveal the hidden elements, so that the original list pertains.
I tried doing this...
public class eventHandler implements itemListener(){
Shade refObj;
public eventHandler(Shade rinseFM){
refObj = rinseFM;
}
#Overriding abstract implemented method...
public void itemStateChanged(ItemEvent event){
if(refObj.primary.isSelected() == true){
refObj.colours.hide(// index of colours required to hide))
}
}
}
The hide method doesn't actually exist, is there anything analogous to this.