askIT

Java Swing Graphics Creating a window with GUI form

document-save.png Download Java graphics_creating_a_window_with_gui_form code

IntelliJ has a very nice GUI form that you can use to create really nice graphics for Java. To use it create a new project. Right click on your package and select
New -> GUI form.

new_gui_form.png

Name = MainForm

new_gui_form_name.png

MainForm.java and a design file MainForm.form. Go to MainForm.form and give it a name:

field_name.png

Now head over to MainForm.java and write the public static void main(String[] args) code to view the Form:

package com.nettport.cofferegister;

import javax.swing.*;

public class MainForm {
    private JPanel jPanel;


    public static void main(String[] args) {
        JFrame jFrame = new JFrame("Coffe Register");
        jFrame.setContentPane(new MainForm().jPanel);
        jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        jFrame.pack();
        jFrame.setSize(1024, 768);
        jFrame.setVisible(true);
    }
   
}

Then Run the program by going to Run -> Run.

intellij_run.png

mainform.png

Your result:

jpanel.png

Add comment

avatar_blank_60.png

Comment:

Name:

Email:

Comments

No comments yet. You can be the first one to comment. Just write your comment in the form and click on the submit button.