Hello, JAVA community.

I am currently working on developing a system (Hotel Reservation System) as academic work.

I am using Netbean IDE 6.7 and MySQL or MS SQL as development tools. I am quite amateur with the use of Netbean, I also find that manual coding is very tedious. So, I hope I could find some helps or at least some good guides here.

My questions are as followed:
-------------------------------------
I have created multiple frames as each of them is designated for different functions. Say between the 2 Jframe i have now namely JFrame01 and JFrame02,

  • I need to know how do I open JFrame02 from JFrame01 using button
  • disable only JFrame01 or make invisible to JFrame01
  • close JFrame02 and open and enable JFrame01

I may add more questions in this thread in the future.

Edited 7 Years Ago by pvt_geeker: n/a

Hello, JAVA community.

I am currently working on developing a system (Hotel Reservation System) as academic work.

I am using Netbean IDE 6.7 and MySQL or MS SQL as development tools. I am quite amateur with the use of Netbean, I also find that manual coding is very tedious. So, I hope I could find some helps or at least some good guides here.

My questions are as followed:
-------------------------------------
I have created multiple frames as each of them is designated for different functions. Say between the 2 Jframe i have now namely JFrame01 and JFrame02,

  • I need to know how do I open JFrame02 from JFrame01 using button
  • disable only JFrame01 or make invisible to JFrame01
  • close JFrame02 and open and enable JFrame01

I may add more questions in this thread in the future.

I don't know that I have every had a program with more than one JFrame. I've normally used just one and had multiple panels on it. I'd imagine you'll want to use the setEnabled and setVisible functions to make this visible/invisible and enabled/not-enabled.

Regarding the button, it would be a matter of having an ActionListener on that button and having the code that enables/disables, etc. execute when that button is pushed.

There are lots of good ActionListener tutorials out there. Google "ActionListener tutorial", "ActionListener sample code", stuff like that. It would probably be worth your while to also check the Daniweb code snippets section. Lots of sample code floating around regarding having things done when a button is pressed. Here's the Sun tutorial:

http://java.sun.com/docs/books/tutorial/uiswing/events/actionlistener.html

With multiple frames it's usually a good idea to have a separate controller class (instance) that has methods for opening frames, hiding frames, switching between frames etc. If that class creates and opens the frames it will have references to them that it can use for setting their visibility etc. If you pass the controller instance to each frame when it's created (as a parameter to the frame's constructor) then the frames can call the appropriate methods in the controller when buttons are pressed etc.

Comments
Agreed
This article has been dead for over six months. Start a new discussion instead.