Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

On click of button go to another class in core java

 
Mayur Saparia
Greenhorn
Posts: 19
Android Java PHP
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am doing a project where i want to display another frame when i click on it.
FOr eg. I have page named add customer record which has the button home, when i click on it it should display the home class ?
How can I do this ? Also am using netbeans GUI Builder so please consider that.
 
Kemal Sokolovic
Bartender
Posts: 825
5
Java Python Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to Use Buttons, ... and How to Write an Action Listener would be a good place to start.

Moving the thread to Swing forum.

Welcome to the Ranch!
 
K. Tsang
Bartender
Pie
Posts: 3222
12
Android Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the ranch.

First you mentioned Netbeans GUI builder... don't use it for your own good. It's better to learn the Swing/AWT API through coding. To get started with Swing check out the Swing tutorial here.

As for your question, buttons have a thing called action/event listener, which you use it to control what that button do (eg new frame pop-up, enable/disable something, etc).

Of course before you get there, learn the basics first such as layout managers, the available components (JFrame, JButton, JLabel, JTable, JXXXX etc).
 
Michael Dunn
Ranch Hand
Posts: 4632
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> I am doing a project where i want to display another frame when i click on it.

almost *always* a bad idea - the secondary display generally should be a JDialog (modal, if required)
 
K. Tsang
Bartender
Pie
Posts: 3222
12
Android Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Michael Dunn wrote:> I am doing a project where i want to display another frame when i click on it.

almost *always* a bad idea - the secondary display generally should be a JDialog (modal, if required)


Or it can be a JInternalFrame. Depends on the purpose.
 
Jay Orsaw
Ranch Hand
Posts: 356
Android Java Netbeans IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
K. Tsang wrote:Welcome to the ranch.

First you mentioned Netbeans GUI builder... don't use it for your own good. It's better to learn the Swing/AWT API through coding. To get started with Swing check out the Swing tutorial here.

As for your question, buttons have a thing called action/event listener, which you use it to control what that button do (eg new frame pop-up, enable/disable something, etc).

Of course before you get there, learn the basics first such as layout managers, the available components (JFrame, JButton, JLabel, JTable, JXXXX etc).



Always get the ones "Don't use the gui builder" "don't use IDEs they CHEAT!!!" Kawmon really.. Instead it should say "you should learn how to code the gui work, before going to the gui builder, as understanding the code behind it is the most important thing.... IF you get stuck without knowing what to do it's a bad bad thing."


I personally think the netbeans gui builder is one of the best tools out there... It's a lot better than Scene Builder >( I had to build 136 menu, sub menu, and sub sub menus, and with the gui builder took 6 hours.... Would have taken 10x that coding by hand. Why waste time and "be cool" hard coding things when there are tools to not only do it, but do it great?


As mentioned above you shouldn't have multiple Jframes as that is the top level. I would use JInternalFrames as suggested, or when customer records come in you should pop up a dialog to enter the customer data, then after clicking ok, sends you back to the home page.
 
Tony Docherty
Bartender
Pie
Posts: 2878
59
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jay Orsaw wrote:Always get the ones "Don't use the gui builder" "don't use IDEs they CHEAT!!!" Kawmon really.. Instead it should say "you should learn how to code the gui work, before going to the gui builder, as understanding the code behind it is the most important thing...

That's what K. Tsang did say. To quote "It's better to learn the Swing/AWT API through coding".
 
Jay Orsaw
Ranch Hand
Posts: 356
Android Java Netbeans IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tony Docherty wrote:
Jay Orsaw wrote:Always get the ones "Don't use the gui builder" "don't use IDEs they CHEAT!!!" Kawmon really.. Instead it should say "you should learn how to code the gui work, before going to the gui builder, as understanding the code behind it is the most important thing...

That's what K. Tsang did say. To quote "It's better to learn the Swing/AWT API through coding".


Yes, I know, it's how he said it, and saying "don't use it for your own good," again, isn't the correct way to phrase it, to which I said above, use it while learning how the code works, and how to fully utilize the gui builder and netbeans itself.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic