aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Message Box problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Message Box problem" Watch "Message Box problem" New topic
Author

Message Box problem

Sivaraman Lakshmanan
Ranch Hand

Joined: Aug 02, 2003
Posts: 231
Hey all,
I am developing an applcation where i have a class called IPAdder which has a internal class called EventDispatch. The IPAdder class extends JFrame. This EventDispatcher class is for event handling so it extends and implements the required event classes and listeners.

Inside this EventDispatch class I need to arise messages using JOptionPane.showMessageDialog() method. This method, the first arg is a component so if I give it as null, then the dialog box is displayed separetely.(ie out side my application window which is of size 300,300) I cannot give this or super since this is inside the EventDispatch class whose super isa Event class.

How to solve this prob. I want the dialog box to appear with in my application itself.

help pl,
regards,
siva.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

A JOptionPane will NEVER display within the application itself. It is always an external window. The Component Parameter you pass as the first argument is the parent class, but all that does is tell the JOptionPane what parent to be modal for. Basically, what window should it stay on top of.
Unless I misunderstood your question, you might need to be using a JInternalFrame on top of a DesktopPane if you want it to stay "inside" the application.
If I am misunderstanding you I apologize.


GenRocket - Experts at Building Test Data
VIJAY Yadlapati
Ranch Hand

Joined: Aug 04, 2003
Posts: 175
I think IPAdder class should not extend JFrame..
Frame should be a static final member of the class, and it will be initialised in the main() method. You can access the frame variable from any other class in the application by using the Class Name itself.
Then in EventDispatcher class, you can pass IPAdder.frame or IPAdder.getFrame() (depending on the scope of the variable) as parent of the message dialog.
 
Don't get me started about those stupid light bulbs.
 
subject: Message Box problem