Vaibhav Aralkar
Vaibhav Aralkar

Reputation: 61

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.

Upvotes: 5

Views: 15625

Answers (2)

gprathour
gprathour

Reputation: 15333

You can get it done by the following one line code

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

Upvotes: 0

Rob
Rob

Reputation: 16002

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();
    }
}

Upvotes: 4

Related Questions