Would something like this help?
public class MyFrame extends JFrame{
private JCheckBox box1;
public MyFrame(){
box1 = new JCheckBox();
}
public void work(){
if(getbox().isSelected){
//work
}else{
//do else
}
}
public JCheckBox getbox1(){
return this.box1;
}
public JCheckBox setSelectedbox1(boolean set){
getbox1().setSelected(set);
}
If you want to keep that object alive you can use:
myFrame.setVisible(false)
myFrame.setVisible(true)