Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to resize the jframe to the screen resolution in netbeans?

I am trying to develop application using swings in netbeans. So I want to resize my application frame to the screen resolution. Kindly help me out in this problem.

like image 567
Vaibhav Aralkar Avatar asked Oct 04 '22 20:10

Vaibhav Aralkar


1 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 of it, may 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();
    }
}
like image 99
Rob Avatar answered Oct 10 '22 03:10

Rob