Hi,
Please refer following example of JFrame class of java. Which containse the code for resizing a JFrame"
Code:
import javax.swing.JButton;
import javax.swing.JFrame;
public class JFrameDemo {
public static void main(String[] argso) {
JFrame.setDefaultLookAndFeelDecorated(true);
JFrame VY = new JFrame();
VY.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
VY.setTitle("JFrame Test");
VY.setLayout(new GridLayout(3, 2));
VY.add(new JLabel("First Name:"));
VY.add(new JTextField());
VY.add(new JLabel("Last Name:"));
VY.add(new JTextField());
VY.add(new JButton("Register"));
int VYWidth = 300;
int VYHeight = 200;
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
VY.setBounds((int) screenSize.getWidth() - VYWidth, 0, VYWidth, VYHeight);
VY.setVisible(true);
}
}
Bookmarks