버튼 찍고 늘려서 생성.
속성 들어가서 설정..

********* 아래코드는 전부 자동생성. ***********
package ch11;

import java.awt.Frame;
import java.awt.Panel;
import java.awt.GridBagLayout;
import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.Rectangle;
import java.awt.SystemColor;
import java.awt.Color;

import javax.swing.JOptionPane;

public class Ch1102 extends Frame {

 private static final long serialVersionUID = 1L;
 private Button button = null;
 /**
  * This is the default constructor
  */
 public Ch1102() {
  super();
  initialize();
 }

 /**
  * This method initializes this
  *
  * @return void
  */
 private void initialize() {
  this.setLayout(null);
  this.setSize(300, 200);
  this.setBackground(new Color(153, 204, 0));
  this.setTitle("AWT 윈도우");

  this.setVisible(true);
  this.add(getButton(), null);
  this.addWindowListener(new java.awt.event.WindowAdapter() {
   public void windowClosing(java.awt.event.WindowEvent e) {
    System.out.println("windowClosing()"); // TODO Auto-generated Event stub windowClosing()
    dispose();
   }
  });
 
 }

 /**
  * This method initializes button
  *  
  * @return java.awt.Button
  */
 private Button getButton() {
  if (button == null) {
   button = new Button();
   button.setBounds(new Rectangle(81, 69, 148, 47));
   button.setLabel("버튼 1");
   button.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent e) {
     System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()
     JOptionPane.showMessageDialog(null, "Hello");
    }
   });
  }
  return button;
 }

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

}

Posted by 말없제이
,