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.
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.
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.