티스토리 뷰
package com.sist;
import java.awt.*;
import java.awt.Event.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class Woonse extends JFrame implements ActionListener,Runnable{
JLabel la1,la2,la3,la4,la5,la6,la7;
JProgressBar bar1,bar2,bar3,bar4,bar5,bar6;
JButton b1;
public Woonse()
{
la1=new JLabel("운세 보기",JLabel.CENTER);
la1.setFont(new Font("궁서체",Font.BOLD,35));
la2=new JLabel("금전운");
la3=new JLabel("건강운");
la4=new JLabel("애정운");
la5=new JLabel("금전운");
la6=new JLabel("건강운");
la7=new JLabel("애정운");
bar1=new JProgressBar();
bar1.setMaximum(100);
bar1.setMinimum(0);
bar1.setStringPainted(true);//%를 출력
bar1.setBackground(Color.white);
bar1.setForeground(Color.yellow);
bar2=new JProgressBar();
bar2.setMaximum(100);
bar2.setMinimum(0);
bar2.setStringPainted(true);//%를 출력
bar2.setBackground(Color.white);
bar2.setForeground(Color.magenta);
bar3=new JProgressBar();
bar3.setMaximum(100);
bar3.setMinimum(0);
bar3.setStringPainted(true);//%를 출력
bar3.setBackground(Color.white);
bar3.setForeground(Color.pink);
bar4=new JProgressBar();
bar4.setMaximum(100);
bar4.setMinimum(0);
bar4.setStringPainted(true);//%를 출력
bar4.setBackground(Color.white);
bar4.setForeground(Color.green);
bar5=new JProgressBar();
bar5.setMaximum(100);
bar5.setMinimum(0);
bar5.setStringPainted(true);//%를 출력
bar5.setBackground(Color.white);
bar5.setForeground(Color.blue);
bar6=new JProgressBar();
bar6.setMaximum(100);
bar6.setMinimum(0);
bar6.setStringPainted(true);//%를 출력
bar6.setBackground(Color.white);
bar6.setForeground(Color.red);
b1=new JButton("실행");
//배치
setLayout(null);
la1.setBounds(10,15,450,50);
la2.setBounds(10,75,60,30);
bar1.setBounds(75,75,350,30);
la3.setBounds(10,115,60,30);
bar2.setBounds(75,115,350,30);
la4.setBounds(10,155,60,30);
bar3.setBounds(75,155,350,30);
la5.setBounds(10,195,60,30);
bar4.setBounds(75,195,350,30);
la6.setBounds(10,235,60,30);
bar5.setBounds(75,235,350,30);
la7.setBounds(10,275,60,30);
bar6.setBounds(75,275,350,30);
b1.setBounds(10,315,100,30);
add(la1);
add(la2);add(bar1);
add(la3);add(bar2);
add(la4);add(bar3);
add(la5);add(bar4);
add(la6);add(bar5);
add(la7);add(bar6);
add(b1);
setSize(480,390);
setVisible(true);
b1.addActionListener(this);
}
public void go()
{
try
{
int a=(int)(Math.random()*101);
int b=(int)(Math.random()*101);
int c=(int)(Math.random()*101);
int d=(int)(Math.random()*101);
int e=(int)(Math.random()*101);
int f=(int)(Math.random()*101);
for(int i=0; i<=a;i++)
{
bar1.setValue(i);
Thread.sleep(30);
}
for(int i=0; i<=b;i++)
{
bar2.setValue(i);
Thread.sleep(30);
}
for(int i=0; i<=c;i++)
{
bar3.setValue(i);
Thread.sleep(30);
}
for(int i=0; i<=d;i++)
{
bar4.setValue(i);
Thread.sleep(30);
}
for(int i=0; i<=e;i++)
{
bar5.setValue(i);
Thread.sleep(30);
}
for(int i=0; i<=f;i++)
{
bar6.setValue(i);
Thread.sleep(30);
}
}catch(Exception ex){}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
new Woonse();
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(e.getSource()==b1)
{
new Thread(this).start();
}
}
@Override
public void run() {
// TODO Auto-generated method stub
go();
}
}
옆에 써있는건 소스 수정하면 말 그대로 복불복 프로그램이 됨...
음료수 내기나 피시방 내기할때 급 좋음
'Programming? > JAVA' 카테고리의 다른 글
Java I/O 파일 복사 (0) | 2012.08.01 |
---|---|
매우 건전한 슬롯머신 (0) | 2012.07.30 |
쓰레드를 이용한 타임워치 (0) | 2012.07.30 |
달력 출력 ver 메소드 (0) | 2012.07.12 |
숫자야구게임-메소드ver (0) | 2012.07.11 |
- Total
- Today
- Yesterday
- 무사헌터G
- Unleashed
- GOD EATER2
- HTML
- oracle
- jdbc
- PSP
- 이건사야되!
- C Programming
- DnF_카인
- spring
- java
- Android
- Talesweaver_Palshu
- 포세리앙 시밤...
- jsp
- League of legends
- PS VITA
- XML
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |