awt에서 Frame 만들어서 실행시키면 뜨는거까지는 좋다 이거야

근데 왜 안꺼지냐고..ㅡㅡ;;

꺼져라 꺼져라!!

ctrl + alt + del 눌러서 끄기 귀찮단 말이다


import java.awt.*;
import java.awt.event.*;

class  ListActive extends Frame implements ItemListener, ActionListener
{
 public ListActive()
 {
  super("ListActive");
  Panel panel = new Panel();
  List list = new List(4, false);
  String msg[] = {"one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten"};
  for(int i=0; i<msg.length; i++)
  {
   list.add(msg[i]);
  }

  list.addItemListener(this);
  list.addActionListener(this);
  panel.add(list);
  add(panel);
  setSize(150, 100);
  setVisible(true);

  this.addWindowListener(new WindowAdapter(){public void windowClosing(WindowEvent we){System.exit(0);}});  //이거 추가
 }

 public void itemStateChanged(ItemEvent e)
 {
  System.out.println("Do something here with your choice of "+((List)e.getSource()).getSelectedItem());
 }
 public void actionPerformed(ActionEvent e)
 {
  System.out.println("Action is required for "+((List)e.getSource()).getSelectedItem());
 }
 public static void main(String agrs[])
 {
  new ListActive();
 }
}

Posted by 성주

Trackback Address :: http://www.7zelkova.pe.kr/trackback/155 관련글 쓰기

댓글을 달아 주세요

  1. 좋은 정보 2011/11/06 00:39 Address Modify/Delete Reply

    감사합니다