/*
import javax.swing.*;
import java.awt.*;
public class Main extends JFrame {
public Main() {
final int SIZE = 10;
final int M_SEC = 1000; // MILLI- SECONDS
setTitle("eclipse-workspace - 최준우/src/Main.java - Eclipse IDE");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c = getContentPane();
c.setLayout(null);
setSize(600,600);
setVisible(true);
JLabel la = new JLabel("Hello, Press Buttons!");
JButton[] b = new JButton[SIZE];
la.setLocation((int)(Math.random()*500)+1,(int)(Math.random()*500)+1);
la.setSize(220,40);
c.add(la);
for(int i=0 ; i<SIZE ; i++) {
b[i] = new JButton(Integer.toString(i));
b[i].setLocation((int)(Math.random()*500)+1,(int)(Math.random()*500)+1);
b[i].setSize(70,30);
c.add(b[i]);
b[i].setVisible(false);
try{
Thread.sleep(M_SEC);
}catch(InterruptedException e){
e.printStackTrace();
}
b[i].setVisible(true);
}
b[5].setBackground(Color.red);
}
public static void main(String[] args) {
new Main();
}
}
*/
/*
import javax.swing.*;
import java.awt.*;
public class Main extends JFrame {
public Main() {
setTitle("BorderLayout Practice");
setSize(400,200);
setVisible(true);
Container c = getContentPane();
c.setLayout(new BorderLayout(5,7));
c.add(new JButton("Center"),BorderLayout.CENTER);
c.add(new JButton("North"),BorderLayout.NORTH);
c.add(new JButton("South"),BorderLayout.SOUTH);
c.add(new JButton("East"),BorderLayout.EAST);
c.add(new JButton("South"),BorderLayout.WEST);
}
public static void main(String[] args) {
new Main();
}
}
*/
/*
import javax.swing.*;
import java.awt.*;
public class Main extends JFrame {
public Main() {
Container c= getContentPane();
setTitle("Ten Color Buttons Frame");
c.setLayout(new GridLayout(4,4));
Color[] color = {Color.cyan, Color.blue,Color.orange, Color.yellow, Color.green,Color.white,Color.red, Color.orange, Color.yellow, Color.green, Color.cyan, Color.blue, Color.magenta, Color.DARK_GRAY, Color.pink, Color.gray,};
for(int i=0 ; i<16 ; i++) {
String num = Integer.toString(i);
JButton b = new JButton(num);
b.setBackground(color[i]);
c.add(b);
}
setSize(700,350);
setVisible(true);
}
public static void main(String[] args) {
new Main();
}
}
*/
/*
import javax.swing.*;
import java.awt.*;
public class Main extends JFrame {
public Main() {
Container c= getContentPane();
c.setLayout(null);
Color[] col = {Color.blue};
setTitle("Random Labels");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
for(int i=0 ; i<20 ; i++) {
int x = (int)(Math.random()*200)+50;
int y = (int)(Math.random()*200)+50;
String num = Integer.toString(i);
JLabel l = new JLabel(num);
l.setLocation(x,y);
l.setSize(20,20);
l.setOpaque(true);
l.setBackground(Color.blue);
c.add(l);
}
setSize(300,300);
setVisible(true);
}
public static void main(String[] args) {
new Main();
}
}
*/
//import javax.swing.*;
//import java.awt.*;
//public class Main extends JFrame {
// public Main() {
// setTitle("▒▒▒▒▒▒ 계산기");
// setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//
// Container c = getContentPane();
// c.setLayout(new BorderLayout());
//
// Color color = new Color(242,241,238);
// Color co = new Color(252,252,252);
//
// JPanel p1 = new JPanel();
// c.add(p1,BorderLayout.NORTH);
// p1.setLayout(new FlowLayout());
// p1.add(new JLabel("수식 입력"));
// p1.add(new JTextField(10));
// p1.setBackground(co);
//
// JPanel p2 = new JPanel();
//
// c.add(p2,BorderLayout.CENTER);
// p2.setBackground(color);
// p2.setLayout(new GridLayout(4,4,5,5));
// for(int i=0 ; i<10 ; i++) {
// String num = Integer.toString(i);
// JButton b = new JButton(num);
//
// // Red Green Blue
// b.setBackground(co);
// p2.add(b);
//
//
// }
//
// p2.add(new JButton("CE"));
// p2.add(new JButton("="));
//
//
//
// JPanel p3 = new JPanel();
// c.add(p3,BorderLayout.SOUTH);
// p3.setLayout(new FlowLayout());
// p3.add(new JLabel("계산결과"));
// p3.add(new JTextField(10));
// p3.setBackground(Color.blue);
//
//
// Color[] col = { Color.gray };
//
//
// setSize(500,400);
// setVisible(true);
// }
// public static void main(String[] args) {
// new Main();
// }
//}
//import javax.swing.*;
//import java.awt.*;
//public class Main extends JFrame {
// public Main() {
// int i = 0;
// setTitle("여 개 패 가 프");
// setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//
// Container c = getContentPane();
// c.setLayout(new BorderLayout());
//
//
// JPanel p1 = new JPanel();
// c.add(p1,BorderLayout.NORTH);
// p1.setLayout(new FlowLayout());
// p1.add(new JButton("열기"));
// p1.add(new JButton("닫기"));
// p1.add(new JButton("나가기"));
// p1.setBackground(Color.gray);
//
// JPanel p2 = new JPanel();
// c.add(p2,BorderLayout.CENTER);
// p2.setBackground(Color.white);
// p2.setLayout(null);
// for(i=1 ; i<=10 ; i++) {
// int x = (int)(Math.random()*400)+1;
// int y = (int)(Math.random()*300)+1;
// String num = Integer.toString(i);
// JLabel l = new JLabel(num);
// l.setLocation(x,y);
// l.setSize(20, 15);
// l.setForeground(Color.red);
// p2.add(l);
// }
//
//
// JPanel p3 = new JPanel();
// c.add(p3,BorderLayout.SOUTH);
// p3.setLayout(new FlowLayout());
// p3.add(new JButton("Word Input"));
// p3.add(new JTextField(10));
// p3.setBackground(Color.yellow);
//
// setSize(500,400);
// setVisible(true);
// }
// public static void main(String[] args) {
// new Main();
// }
//}
/*
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class Main extends JFrame {
JPanel p1 = new JPanel();
public Main() {
int i = 0;
setTitle("여 개 패 가 프");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c = getContentPane();
c.setLayout(new BorderLayout());
c.add(p1,BorderLayout.NORTH);
p1.setLayout(new FlowLayout());
JButton b = new JButton("Hello");
b.addActionListener(new myActionListener());
p1.add(b);
p1.setBackground(Color.gray);
JPanel p3 = new JPanel();
c.add(p3,BorderLayout.SOUTH);
p3.setLayout(new FlowLayout());
p3.add(new JButton("Word Input"));
p3.add(new JTextField(10));
p3.setBackground(Color.yellow);
setSize(500,400);
setVisible(true);
}
class myActionListener implements ActionListener{
public void actionPerformed(ActionEvent e) {
if(Color.gray.equals(p1.getBackground()) ) {
p1.setBackground(Color.red);
}
else {
p1.setBackground(Color.gray);
}
}
}
public static void main(String[] args) {
new Main();
}
}
*/
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class Main extends JFrame {
JPanel p1 = new JPanel();
JPanel p2 = new JPanel();
JButton b = new JButton("PLUS");
JButton a = new JButton("REMOVE");
int cnt=1;
public Main() {
setTitle("Program That Plus "+"\"NUMBERS\"");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c = getContentPane();
c.setLayout(new BorderLayout());
c.add(p1,BorderLayout.NORTH);
c.add(p2,BorderLayout.CENTER);
p1.setLayout(new FlowLayout());
p2.setLayout(null);
b.addActionListener(new myActionListener());
p1.add(b);
b.addActionListener(new myAL());
p1.add(a);
setSize(500,400);
setVisible(true);
}
class myActionListener implements ActionListener{
public void actionPerformed(ActionEvent e) {
//버튼만들고 cnt++ 버튼 위치 , 크기 정하기
int x = (int)(Math.random()*400)+1;
int y = (int)(Math.random()*300)+1;
String num = Integer.toString(cnt);
cnt++;
JLabel l = new JLabel(num);
l.setLocation(x,y);
l.setSize(20, 15);
l.setForeground(Color.red);
p2.add(l);
p2.repaint();
p2.revalidate();
}
}
class myAL implements ActionListener {
public void actionPerformed(ActionEvent e) {
p1.remove(cnt);
}
}
public static void main(String[] args) {
new Main();
}
}