There are many ways to accomplish this but one way I might accomplish this is with a WindowListener or WindowAdapter. Below is a skeleton structure:
package pkg;
public class ExampleMainFrame extends JDialog
{
public ExampleMainFrame(final Window parent)
{
super(parent);
// ... Do other stuff for initialization here or in another internal method
addWindowListener(new WindowAdapter()
{
public void WindowClosed(WindowEvent e)
{
(new ExampleDialog2(parent)).setVisible(true);
}
}
}
// ... Other methods
}
(In different .java source file)
package pkg
public class ExampleDialog2 extends JDialog
{
public class ExampleDialog2(final Window parent)
{
super(parent);
// ... Do other stuff for initialization here or in another internal method
}
// ... Other methods
}
Explanation:
WindowListener is an Interface - WindowAdapter is a class that defines empty method definitions for each of the methods so you can effectively define/override one of the methods and instantiate a WindowAdapter and it won't do anything but what you've overridden. In this example, I've overridden WindowClosed and upon that event occuring, it'll create and show the 2nd frame.
Chat with our AI personalities
Same as that of the applet we need to run this frame...........
No, Java only allows a method to be defined within a class, not within another method.
That means, the header of a function. The header is the top part, before the opening braces.
The language was originally called 'Green' but was renamed after Java coffee due to the large amounts of it consumed by the developers.
There are classes in java.awt Menu and MenuItem which are used for the creation of menus and they can be put inside Frame.