Friday 26 January 2018

Swing examples in java

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

/**
  *
  * Description
  *
  * @version 1.0 from 10/16/2017
  * @author
  */

public class AA extends JFrame {
  // start attributes
  private JButton jButton1 = new JButton();
  // end attributes
 
  public AA() {
    // Frame-Init
    super();
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    int frameWidth = 342;
    int frameHeight = 334;
    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);
    setTitle("AA");
    setResizable(false);
    Container cp = getContentPane();
    cp.setLayout(null);
    // start components
   
    jButton1.setBounds(56, 80, 105, 41);
    jButton1.setText("jButton1");
    jButton1.setMargin(new Insets(2, 2, 2, 2));
    jButton1.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent evt) {
        jButton1_ActionPerformed(evt);
      }
    });
    cp.add(jButton1);
    // end components
   
    setVisible(true);
  } // end of public AA
 
  // start methods
 
  public static void main(String[] args) {
    new AA();
  } // end of main
 
  public void jButton1_ActionPerformed(ActionEvent evt) {
    // TODO add your code here
  } // end of jButton1_ActionPerformed

  // end methods
} // end of class AA

0 comments: