sark9012
sark9012

Reputation: 5717

How to link a button to a form in java?

I am trying to load a form when clicking a button.

 private void btnAddRecordMouseClicked(java.awt.event.MouseEvent evt) {
    // TODO add your handling code here:
}

This is my method. The form name is Admin.java.

Any ideas? Thanks

Upvotes: 0

Views: 4657

Answers (2)

Makhosonke Mdletshe
Makhosonke Mdletshe

Reputation: 1

Hmm i just had a problem like yours and I managed to sort it out... so I'm willing to share.

  1. You need to select the option of JFrame form and that Mouse Event listerner will change to ActionEvent
  2. Type that second code of yours to link the forms and make sure that the name is the same as the other form... I hope it could work because to me it just did work.

Upvotes: 0

camickr
camickr

Reputation: 324088

Maybe something like:

Admin form = new Admin();
form.setVisible( true );

I suggest you start reading the Swing tutorial for the basics of using Swing. Maybe something like "How to Write an Action Listener".

And use proper terms. What is a form? We have to guess what you are talking about. There is no component by that name in Swing.

Upvotes: 1

Related Questions