Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Swing: multiple windows [closed]

Tags:

java

swing

I'm new to GUI programming, but need to create a multiple window GUI. Does anyone know of any good tutorial online or could you please show a simple code that will launch 2 windows?

like image 604
sivabudh Avatar asked Oct 31 '25 15:10

sivabudh


2 Answers

Just create two JFrame objects like this:

    public static void main(String[] args)  throws Exception {
        SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            new JFrame("frame1").setVisible(true);
            new JFrame("frame2").setVisible(true);
        }
    });
}
like image 153
Ramon Avatar answered Nov 02 '25 06:11

Ramon


I suggest you use NetBeans and create a project using the "Swing Desktop Application" pre-existing template.

It will create the basic infrastructure for your app including a main window with a menu and status bar with a progress bar, about box, event handlers, etc, all pre-wired.

What's nice about it for example is that the progress bar is already configured to listen to any action task that you create, so by simply creating a new action task, you get a working progress bar that will run when the task executes, without having to code it.

Furthermore, you get a visual drag-and drop Editor that certainly sometimes can be frustrating when it comes to resizing and layouts, but for simple layouts is very good and easy to use. You'll be able to create an interface in no time.

For more info see here.

like image 38
JRL Avatar answered Nov 02 '25 06:11

JRL



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!