Java awt에서 창 끄기
Study/Java(Script),JSP 2008/05/18 00:03 |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();
}
}
댓글을 달아 주세요
감사합니다