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?
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);
}
});
}
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With