Header Ads Widget

Responsive Advertisement

Ticker

6/recent/ticker-posts

Set jframe size and it's location when click on maximize button (Java)


***********************************************************
COMPLETE SOURCE CODE FOR : SettingBound.java
***********************************************************
/**
 *THIS TUTORIAL WILL SHOW YOU HOW TO SET THE MAXIMUM SIZE OF YOUR FRAME
 *AND IT'S LOCATION WHEN YOU CLICK
 *MAXIMIZE BUTTON BESIDE JFRAME CLOSE BUTTON
 **/

import java.awt.Rectangle;
import javax.swing.JFrame;

public class SettingBound
{
 public static void main(String[]args)
 {
  //first value, 400=x coordinate on your screen
  //second value, 400=y coordinate on your screen
  //third value, 800=JFrame width
  //fourth value, 200=JFrame height
  Rectangle rec=new Rectangle(400,400,800,200);
 
  JFrame frame1=new JFrame("Setting Bound");
 
  frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame1.setMaximizedBounds(rec);//set maximize setting for your JFrame
  frame1.setVisible(true);
 }
}


***********************************************************
JUST COMPILE AND EXECUTE IT
***********************************************************