Reputation: 61
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
Reputation: 15333
You can get it done by the following one line code
frame.setSize(Toolkit.getDefaultToolkit().getScreenSize());
Upvotes: 0
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