asked on
private void addCombo(String name) {
java.awt.GridBagConstraints gridBagConstraints;
JMappedComboBox newCombo = new anecho.gui.JMappedComboBox();
newCombo.setSize(new Dimension(500,100));
newCombo.setName(name);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = comboPosition;
gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL;
gridBagConstraints.ipady = 1;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
newCombo.addItem(name,"1");
newCombo.addItem("Two","2");
newCombo.addItem("Three","3");
newCombo.addItem("Four","4");
jPanel2.add(newCombo, gridBagConstraints);
//jPanel2.setl
reloadLayout(true);
}
private void subCombo(String name) {
Component[] combos = jPanel2.getComponents();
for (int i = 0; i < combos.length; i++)
{
if (name.equals(combos[i].getName())){
jPanel2.remove(combos[i]);
reloadLayout(false);
}
}
}
private void reloadLayout(boolean insert){
int width = 0;
int widest = 0;
if(insert){
comboPosition = comboPosition + 1;
Component[] combos = jPanel2.getComponents();
for (int i = 0; i < combos.length; i++)
{
width = combos[i].getWidth();
if(width > widest){widest = width;}
}
for (int i = 0; i < combos.length; i++)
{
combos[i].setSize(widest,combos[i].getHeight());
}
}
else{
// do nothing
}
jPanel2.revalidate();
jPanel2.repaint();
}
ASKER
Java is a platform-independent, object-oriented programming language and run-time environment, designed to have as few implementation dependencies as possible such that developers can write one set of code across all platforms using libraries. Most devices will not run Java natively, and require a run-time component to be installed in order to execute a Java program.
TRUSTED BY
;JOOP!