Java Swing: multiple windows

I am new to GUI programming, but I need to create a GUI with multiple windows. Does anyone know any good tutorial online or can you show a simple code that will launch 2 windows?

+3
source share
5 answers

Just create two JFrame objects, for example:

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); } }); } 
+4
source

I suggest you use NetBeans and create a project using the preexisting Swing Desktop Application template.

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

For example, what’s nice is that the progress bar is already set up to listen to any task of the task that you create, therefore, simply by creating a new action task, you will get a working progress bar that will be launched when the task is executed, without the need to code it.

In addition, you get a visual drag and drop editor that can sometimes be disappointing when it comes to resizing and layouts, but for simple layouts it’s very convenient and convenient. You can create an interface as soon as possible.

See here for more details.

+2
source

this website is the best IMO, gives you direct "How to" codes, with super brief descriptions

for GUI tutorials, find the β€œSwing” tutorials.

+2
source

http://java.sun.com/docs/books/tutorial/uiswing/components/internalframe.html

JDesktopPane is cool if you really want an integrated desktop .. it processes objects very similar to JFrames (they are really called JInternalFrame) and it automatically handles minimization, maximization, the top menu bar, like a regular document-based application.

+1
source

Java has a class called "Window" http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Window.html . Perhaps this is not what you want. A common top-level object in Swing is a JFrame ( http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JFrame.html ), which is a subclass of Window.

0
source

All Articles