Results 1 to 4 of 4
- 07-09-2011, 06:36 AM #1
Member
- Join Date
- May 2011
- Posts
- 7
- Rep Power
- 0
Main GUI's method to react to alert frame's buttons
I have a method called checkForm in my GUI class, where when called, an alert frame pops up (called from another class AlertFrame).
Depending on what button the user clicks, OK or Cancel, I would like the checkForm method to do an if/else statement,
ex. if(OK button was pressed in AlertFrame, do this) else (Cancel button was pressed in AlertFrame, do this)
it is important to note that the AlertFrame is called from my checkForm(), and the if else statement is also in the checkForm()...
Any ideas? I have tried to create separate threads, listeners etc...nothing worked
- 07-09-2011, 06:44 AM #2
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
Each button should have a listener attached to it which does what is required when that button is pressed.
- 07-09-2011, 07:08 AM #3
Member
- Join Date
- May 2011
- Posts
- 7
- Rep Power
- 0
So if i understand correctly, it is impossible to have one class alertframe used to display alerts throughout my program (where strings are passed through the alertframe's constructor representing the desired message)? Therefore every alert requires to be defined in separate classes?
Last edited by the_rider9; 07-09-2011 at 07:13 AM.
- 07-09-2011, 07:15 AM #4
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
You can pass a string argument into the constructor if you'd like, but having it do things based on the string message will require a bit more logic.
If you have a pre determined amount of possible alerts you can code the listeners of buttons to do something based on that string.
JOptionPane may be helpful for what you want: http://download.oracle.com/javase/6/...ptionPane.htmlLast edited by sunde887; 07-09-2011 at 07:17 AM.
Similar Threads
-
Set enable Button (in main panel) from internal frame
By Lisyandi in forum NetBeansReplies: 7Last Post: 04-03-2011, 12:35 PM -
Java slave Frame access to its owner main frame problem
By cagdaseckin in forum New To JavaReplies: 0Last Post: 12-10-2010, 10:40 AM -
Calling The main method from another method
By SwissR in forum New To JavaReplies: 3Last Post: 07-27-2010, 11:03 AM -
Buttons and Method
By imagiro1 in forum New To JavaReplies: 2Last Post: 05-03-2010, 04:09 AM -
calling method from main method
By bob_bee in forum New To JavaReplies: 4Last Post: 10-02-2009, 05:30 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks