Wednesday 24 January 2018

Jframe example in java

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

/**
  *
  * Description
  *
  * @version 1.0 from 2/25/2010
  * @author
  */

public class rr extends JFrame {
  // start attributes
  // end attributes

  public rr(String title) {
    // Frame-Init
    super(title);
    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    int frameWidth = 300;
    int frameHeight = 300;
    setSize(frameWidth, frameHeight);
    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
    int x = (d.width - getSize().width) / 2;
    int y = (d.height - getSize().height) / 2;
    setLocation(x, y);
    Container cp = getContentPane();
    cp.setLayout(null);
    // start components

    // end components

    setResizable(false);
    setVisible(true);
  }

  // start methods
  // end methods

  public static void main(String[] args) {
    new rr("rr");
  }
}

0 comments: