장난 삼아 만들었습니다.. ㅡ.ㅡ..
/*
우리 Java형님의 말씀은 하늘인거다.
우리 1조는 형님께 절대복종하고 셧더마우스상태에서
조용히 형이 먹으라는거 먹고오면 아무문제 없는거다.
형이 메뉴추가나 변경은 약간 수정해도 된다고 하더라...
월요일부터 java형이 먹으라는거 먹으면 되는거다..
Special Thanks to 용국..
*/
import java.awt.*;
import java.awt.event.*;
public class LunchRoulette extends Frame implements ActionListener
{
Panel pn;
Label lb0, lb1, lb2, lb3, lb4, lb5;
Button bt;
TextField tf;
public LunchRoulette()
{
super("우리 java형님의 말씀은 하늘인거다.");
setLayout(new GridLayout(8, 1, 7, 7));
setBackground(Color.darkGray);
//형이 정해준 메뉴 5가지..
lb0=new Label("아래는 점심메뉴인거다.");
lb0.setForeground(Color.white);
lb1=new Label("1 은 백반이다");
lb1.setForeground(Color.white);
lb2=new Label("2 는 짱깨다");
lb2.setForeground(Color.white);
lb3=new Label("3 은 뼈다귀해장국이다");
lb3.setForeground(Color.white);
lb4=new Label("4 는 햄버거다");
lb4.setForeground(Color.white);
lb5=new Label("5 는 설렁탕이다");
lb5.setForeground(Color.white);
bt=new Button("눌러라.");
bt.setBackground(Color.orange);
tf=new TextField("", 50);
add(lb0);
add(lb1);
add(lb2);
add(lb3);
add(lb4);
add(lb5);
add(bt);
add(tf);
tf.addActionListener(this);
bt.addActionListener(this);
addWindowListener(new WindowAdapter() {public void windowClosing(WindowEvent e) {System.exit(0);}});
}
public void Roulette()
{
//형이 랜덤으로 뽑아준 메뉴
String mr=(String)(Math.random()*5+1+"");
if (mr.startsWith("1"))
{
//형의 절대적인 명령..
tf.setText("메뉴는 백반이 당첨된거다!!! 오늘은 닥치고 백반 먹는거다!");
tf.setForeground(Color.black);
}
else if (mr.startsWith("2"))
{
tf.setText("메뉴는 짱개가 당첨된거다!!! 오늘은 닥치고 짱개 먹는거다!");
tf.setForeground(new Color(133, 91, 39));
}
else if (mr.startsWith("3"))
{
tf.setText("메뉴는 뼈다귀가 당첨된거다!!! 오늘은 닥치고 해장국에 쏘주반주 하는거다!");
tf.setForeground(Color.orange);
}
else if (mr.startsWith("4"))
{
tf.setText("메뉴는 햄버거가 당첨된거다!!! 오늘은 닥치고 맥도날드 가는거다!");
tf.setForeground(Color.red);
}
else if (mr.startsWith("5"))
{
tf.setText("메뉴는 설렁탕이 당첨된거다!!! 오늘은 닥치고 설렁탕 먹으러간다!");
tf.setForeground(new Color(110, 110, 110));
}
}
public void actionPerformed(ActionEvent e)
{
Object obj=e.getSource();
if (obj==bt)
{
tf.setText("");
Roulette();
tf.setText("");
Roulette();
tf.setText("");
Roulette();
tf.setText("");
Roulette();
tf.setText("");
Roulette();
tf.setText("");
Roulette();
tf.setText("");
Roulette();
tf.setText("");
Roulette();
tf.setText("");
Roulette();
tf.setText("");
Roulette();
tf.setText("");
Roulette();
tf.setText("");
Roulette();
tf.setText("");
Roulette();
tf.setText("");
Roulette();
tf.setText("");
Roulette();
tf.setText("");
Roulette();
tf.setText("");
Roulette();
}
}
public Insets getInsets()
{
return new Insets(70, 70, 70, 70);
}
public static void main(String[] args)
{
LunchRoulette lr=new LunchRoulette();
lr.setSize(550, 400);
lr.setVisible(true);
}
}