How to resize jframe to screen resolution in netbeans?

I am trying to develop an application using a swing in netbeans. Therefore, I want to change the size of the application frame to the screen resolution. Please help me with this problem.

+5
source share
2 answers
frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
frame.setVisible(true);
// If you want to always keep the frame at this size
frame.setResizable(false);

Here is a very simple example, it might be a good start for your application:

import javax.swing.JFrame;

public class MyFrame
{
    private JFrame frame;

    public MyFrame()
    {
        frame = new JFrame();

        frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
        frame.setVisible(true);
        frame.setResizable(false);
    }
    public static void main(String[] args)
    {
        new MyFrame();
    }
}
+4
source

You can do this with the following line code

     frame.setSize(Toolkit.getDefaultToolkit().getScreenSize());
0
source

All Articles