/*
import java.awt.*;
import javax.swing.*;
class TimerThread extends Thread {
private JLabel timerLabel;
public TimerThread(JLabel timerLabel) {
this.timerLabel = timerLabel;
}
public void run() {
int n=0;;
while(true) {
timerLabel.setText(Integer.toString(n));
n++;
try {
Thread.sleep(1000);
}
catch(InterruptedException e) {
return;
}
}
}
}
public class Main extends JFrame{
public Main() {
setTitle("Thread를 상속받은 타이머 스레드 예제");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c= getContentPane();
c.setLayout(new FlowLayout());
JLabel timerLabel= new JLabel();
timerLabel.setFont(new Font("Gothic",Font.ITALIC,80));
c.add(timerLabel);
TimerThread th = new TimerThread(timerLabel);
setSize(300,170);
setVisible(true);
th.start();
}
public static void main(String[] args) {
new Main();
}
}
*/
/*
import java.awt.*;
import javax.swing.*;
class TimerRunnable implements Runnable{
private JLabel timerLabel;
public TimerRunnable(JLabel timerLabel) {
this.timerLabel = timerLabel;
}
public void run() {
int n=0;
while(true) {
timerLabel.setText(Integer.toString(n));
n++;
try {
Thread.sleep(1000);
}
catch(InterruptedException e) {
return;
}
}
}
}
public class Main extends JFrame{
public Main() {
setTitle("Runnable을 구현한 타이머 스레드 예제");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c = getContentPane();
c.setLayout(new FlowLayout());
JLabel timerLabel= new JLabel();
timerLabel.setFont(new Font("Gothic", Font.ITALIC,80));
c.add(timerLabel);
TimerRunnable runnable = new TimerRunnable(timerLabel);
Thread th = new Thread(runnable);
setSize(250,150);
setVisible(true);
th.start();
}
public static void main(String[] args) {
new Main();
}
}
*/
/*
import java.awt.*;
import javax.swing.*;
class FlickeringLabel extends JLabel implements Runnable{
private long delay;
public FlickeringLabel(String text, long delay) {
super(text);
this.delay= delay;
setOpaque(true);
Thread th= new Thread(this);
th.start();
}
public void run() {
int n=0;
while(true) {
if(n==0) setBackground(Color.YELLOW);
else setBackground(Color.GREEN);
if(n==0) n=1;
else n=0;
try {
Thread.sleep(delay);
}
catch(InterruptedException e) {
return;
}
}
}
}
public class Main extends JFrame{
public Main() {
setTitle("FlickeringLabelEx 예제");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c = getContentPane();
c.setLayout(new FlowLayout());
FlickeringLabel fLabel = new FlickeringLabel("깜박",500);
JLabel label = new JLabel("안깜박");
FlickeringLabel fLabel2 = new FlickeringLabel("깜박",300);
c.add(fLabel);
c.add(label);
c.add(fLabel2);
setSize(300,150);
setVisible(true);
}
public static void main(String[] args) {
new Main();
}
}
*/
/*
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class TimerRunnable implements Runnable {
private JLabel timerLabel;
public TimerRunnable(JLabel timerLabel) {
this.timerLabel = timerLabel;
}
public void run() {
int n=0;
while(true) {
timerLabel.setText(Integer.toString(n));
n++;
try {
Thread.sleep(1000);
}
catch(InterruptedException e) {
return;
}
}
}
}
public class Main extends JFrame{
private Thread th;
public Main() {
setTitle("ThreadInterruptEx 예제");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c = getContentPane();
c.setLayout(new FlowLayout());
JLabel timerLabel = new JLabel();
timerLabel.setFont(new Font("Gothic",Font.ITALIC,80));
TimerRunnable runnable = new TimerRunnable(timerLabel);
th=new Thread(runnable);
c.add(timerLabel);
JButton btn = new JButton("kill Timer");
btn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
th.interrupt();
JButton btn = (JButton)e.getSource();
btn.setEnabled(false);
}
});
c.add(btn);
setSize(300,170);
setVisible(true);
th.start();
}
public static void main(String[] args) {
new Main();
}
}
*/
/*
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class RandomThread extends Thread{
private Container contentPane;
private boolean flag=false;
public RandomThread(Container contentPane) {
this.contentPane = contentPane;
}
public void finish() {
flag = true;
}
public void run() {
while(true) {
int x = ((int)(Math.random()*contentPane.getWidth()));
int y = ((int)(Math.random()*contentPane.getHeight()));
JLabel label = new JLabel("java");
label.setSize(80,30);
label.setLocation(x,y);
contentPane.add(label);
contentPane.repaint();
try {
Thread.sleep(300);
if(flag==true) {
contentPane.removeAll();
label = new JLabel("finish");
label.setSize(80,30);
label.setLocation(100,100);
label.setForeground(Color.RED);
contentPane.add(label);
contentPane.repaint();
return;
}
}
catch(InterruptedException e) {return;}
}
}
}
public class Main extends JFrame{
private RandomThread th;
public Main() {
setTitle("ThreadFinsihFlagEx 예제");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c = getContentPane();
c.setLayout(null);
c.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
th.finish();
}
});
setSize(300,200);
setVisible(true);
th = new RandomThread(c);
th.start();
}
public static void main(String[] args) {
new Main();
}
}
*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class clock extends Thread{
public void run() {
}
}