I'm new to Java. I have a jFrame with 3 buttons. Button2 performs some action on a SwingWorker. I want to click Button3 and open a new dialog. When I am in the "Design" mode and click Button3 it sticks the Button3 actionevent code in the middle of Button2's code. Of course this doesn't work for Button3 and breaks Button2's code also.
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
SwingWorker <Void,Void> worker = new SwingWorker<Void,Void>() {
@Override
protected Void doInBackground() throws Exception {
for(int i=1;i <=100;i +=1){
//jLabel1.setText(String.valueOf(i));
//this.repaint();
jLabel1.setText(String.valueOf(i));
Thread.sleep(500);
System.out.print(i + " ");
// TODO add your handling code here:
}
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
return null;
}
@Override
protected void done() {
}
}
}
The only way to get rid of the code is by deleting the button. If I add the button back and try to add the code manually it doesn't work (I think because the "generated" code required isn't there).