/*
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.util.*;
public class Main extends JFrame {
public Main() {
setTitle("마우스로 폐다각형 그리기");
setSize(304,304);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setContentPane(new NUpnl());
setVisible(true);
}
class NUpnl extends JPanel {
private Vector<Point> VecPnt = new Vector<Point>();
public NUpnl() {
addMouseListener(new MouseListener() {
@Override
public void mouseClicked(MouseEvent e) { }
@Override
public void mousePressed(MouseEvent e) {
VecPnt.add(e.getPoint());
repaint();
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) { }
@Override
public void mouseExited(MouseEvent e) { }
});
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.setColor(Color.magenta);
if(VecPnt.size() >= 2) {
for(int i = 0; i < VecPnt.size()-1; i++) {
g.drawLine((int)VecPnt.elementAt(i).getX(), (int)VecPnt.elementAt(i).getY(), (int)VecPnt.get(i+1).getX(), (int)VecPnt.get(i+1).getY());
}
if(VecPnt.size() >= 3) {
g.drawLine((int)VecPnt.elementAt(0).getX(), (int)VecPnt.elementAt(0).getY(), (int)VecPnt.get(VecPnt.size()-1).getX(), (int)VecPnt.get(VecPnt.size()-1).getY());
}
}
}
}
public static void main(String[] args) {
new Main();
}
}
*/
/*
import java.awt.*;
import javax.swing.*;
class TimerThread extends Thread {
private JLabel timerLabel;
public TimerThread(JLabel timerLabel) {
this.timerLabel = timerLabel;
}
@Override
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;
}
@Override
public void run() {
int n=0;
while(true) {
timerLabel.setText(Integer.toString(n));
System.out.println("ID : "+ Thread.currentThread().getId());
System.out.println("Name : "+Thread.currentThread().getName());
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
}
}*/
/*
import java.awt.*;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.*;
import java.util.*;
class ThreadCS extends Thread implements Runnable {
public ThreadCS() {
}
@Override
public void run() {
System.out.println();
System.out.println("------ Imforamtion List ------");
System.out.println("Name |:| " + getId());
System.out.println("Id |:| " + getName());
System.out.print("------------------------------");
System.out.println();
}
}
public class Main extends JFrame {
Vector<ThreadCS> threads = new Vector<ThreadCS>();
public Main() {
setTitle("setTitle");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c = getContentPane();
c.setLayout(new FlowLayout());
addKeyListener(new KeyListener() {
@Override
public void keyTyped(KeyEvent e) { }
@Override
public void keyReleased(KeyEvent e) { }
@Override
public void keyPressed(KeyEvent e) {
if(e.getKeyCode() == KeyEvent.VK_SPACE) {
threads .add(new ThreadCS());
threads.get(threads.size()-1).start();
System.out.println(threads.size());
}
}
});
setSize(500,500);
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;
}
@Override
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("ThreadInterrupetEx 예제");
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() {
@Override
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.*;