Thursday, March 20, 2008


Maximize a Frame using Swing

In this program, you will learn how to maximize a frame using setMaximizedBounds() to set the bounds for a maximized frame. Here is the source code :

import java.awt.*;
import javax.swing.*;

public class SwingSetBounds{
public static void main(String[] args){
JFrame frame = new JFrame();
Rectangle bounds = new Rectangle(0, 0, 500, 500);
frame.setMaximizedBounds(bounds);
frame.setSize(400, 400);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}