I've written a java app that does a few different things, using Netbeans 7.0.1 and its build in gui builder. The problem I'm having is that on screen there are some text fields for user input. Initially one set of fields and a button to add up to 10. I have also got a remove button which removes a field. So basically the buttons add and remove jTextFields and jLabels to/from the panel.
There seems to be a lag when I'd click the buttons so I added some System.out.prints and found that sometimes the button would be pressed, the system would print what it was supposed to but just ignore the adding/removing of components.
Is this a known issue?(I can't find anything as yet, although I'm not 100% sure how to be wording my searches) Or am I doing something wrong?
Sample of code: Note: current components is a map with each component and its value
private void addButtonMouseClicked(java.awt.event.MouseEvent evt) {
if(hiddenValue != 81) {
currentComponents.get(hiddenValue).setVisible(true);
currentComponents.get(hiddenValue + 1).setVisible(true);
currentComponents.get(hiddenValue + 2).setVisible(true);
currentComponents.get(hiddenValue + 3).setVisible(true);
currentComponents.get(hiddenValue + 4).setVisible(true);
currentComponents.get(hiddenValue + 5).setVisible(true);
currentComponents.get(hiddenValue + 6).setVisible(true);
currentComponents.get(hiddenValue + 7).setVisible(true);
currentComponents.get(hiddenValue + 8).setVisible(true);
hiddenValue = hiddenValue + 10;
numEntries++;
removeButton.setVisible(true);
removeButton.setEnabled(true);
System.out.println(hiddenValue);
}
else {
currentComponents.get(hiddenValue).setVisible(true);
currentComponents.get(hiddenValue + 1).setVisible(true);
currentComponents.get(hiddenValue + 2).setVisible(true);
currentComponents.get(hiddenValue + 3).setVisible(true);
currentComponents.get(hiddenValue + 4).setVisible(true);
currentComponents.get(hiddenValue + 5).setVisible(true);
currentComponents.get(hiddenValue + 6).setVisible(true);
currentComponents.get(hiddenValue + 7).setVisible(true);
currentComponents.get(hiddenValue + 8).setVisible(true);
hiddenValue = hiddenValue + 10;
numEntries++;
addButton.setVisible(false);
addButton.setEnabled(false);
System.out.println(hiddenValue);
}
}