Me.Enabled = False
What I can't figure out is how to reference the button from within the form
I have an Addin button (called Analyze) that processes some data, then calls a modeless form. I want the button to be disabled until the user closes the form, or else it will be possible for the user to accidentially have multiple instances of the form open at the same time.
To disable the button I useMe.Enabled = Falsein the button's OnClick event. What I can't figure out is how to reference the button from within the form. I was planning on changing the button's Enabled attribute back to True in the form's FormClosing event, unless someone knows of a better way.
Any Ideas?
public class Button1 extends Button {
private MyForm myForm = null;
@Override
public void onClick() throws IOException, AutomationException {
if(myForm == null){
myForm = MyForm.getInstance();
}
myForm.setVisible(true);
}
}
public class MyForm extends JFrame {
private JPanel contentPane;
private static MyForm instance = null;
public static MyForm getInstance(){
if(instance == null){
instance = new MyForm();
}
return instance;
}
/**
* Create the frame.
*/
public MyForm() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
contentPane.setLayout(new BorderLayout(0, 0));
setContentPane(contentPane);
}
// handle closing of the form, maybe dispose on close...
}
// Enable the save button SaveEditingButton saveButton = AddIn.FromID<SaveEditingButton>(ThisAddIn.IDs.RasterEditor_EditorMenu_Edition_SaveEditingButton); saveButton.IsEnabled = true;