import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/*public class Main extends JFrame {
JLabel la = new JLabel("러부 잡바");
Main(){
setSize(300,280);
setVisible(true);
Container c = getContentPane();
setLayout(new FlowLayout());
c.add(la);
la.addMouseListener(new MyMouseListner());
}
class MyMouseListner extends MouseAdapter {
public void mouseEntered(MouseEvent e) {
la.setText("JAVA");
}
public void mouseExited(MouseEvent e) {
la.setText("러부 잡바");
}
}
public static void main(String[] args) {
new Main();
}
}
public class Main extends JFrame {
JLabel la = new JLabel("Love Java");
Main(){
setSize(680,630);
setVisible(true);
Container c = getContentPane();
setLayout(new FlowLayout());
c.add(la);
la.addKeyListener(new hiKey());
la.setFocusable(true);
la.requestFocus();
}
class hiKey extends KeyAdapter {
public void keyPressed(KeyEvent e) {
System.out.println("OK");
int keyCode = e.getKeyCode();
if(keyCode == KeyEvent.VK_LEFT) {
if(la.getText().equals("avaJ evoL")) {
la.setText("Love Java");
}
else {
la.setText("avaJ evoL");
}
}
}
}
public static void main(String[] args) {
new Main();
}
}
public class Main extends JFrame {
JLabel la = new JLabel("C");
Main(){
setSize(600,600);
setVisible(true);
Container c = getContentPane();
setLayout(null);
c.add(la);
la.setLocation(100, 100);
la.setSize(60, 60);
la.addMouseListener(new hiMouse())
}
class hiMouse extends MouseAdapter {
public void mouseClicked(MouseEvent e) {
int x = (int)(Math.random()*500)+ 40;
int y = (int)(Math.random()*500)+ 40;
la.setLocation(x, y);
}
}
public static void main(String[] args) {
new Main();
}
}
public class Main extends JFrame {
JLabel la = new JLabel("hiJAVA");
Main(){
setSize(500,450);
setVisible(true);
Container c = getContentPane();
setLayout(new FlowLayout());
c.add(la);
la.addKeyListener(new hiKey());
}
class hiMouse extends KeyAdapter{
public void mouseWheelMoved(MouseWheelEvent e) {
int n = e.getWheelRotation();
Font f = la.getFont();
int s = f.getSize();
}
}
public static void main(String[] args) {
new Main();
}
public class Main extends JFrame {
JLabel nums[] = new JLabel[3];
JLabel la= new JLabel("시작합니다.");
Main(){
setSize(500,450);
setVisible(true);
Container c = getContentPane();
JPanel p1 = new JPanel();
JPanel p2 = new JPanel();
setLayout(new BorderLayout());
p1.setLayout(null);
p2.setLayout(null);
la.setFont(new Font("고딕",Font.BOLD,45));
la.setSize(55,55);
la.setLocation(170, 170);
for(int i=0;i<3;i++) {
nums[i] = new JLabel("0",SwingConstants.CENTER);
p1.add(nums[i]);
nums[i].setSize(75,75);
nums[i].setLocation(170*i+50, 150);
nums[i].setBackground(Color.WHITE);
nums[i].setForeground(Color.red);
nums[i].setFont(new Font("Javanese Text",Font.BOLD,60));
nums[i].setOpaque(true);
}
c.add(p1,BorderLayout.CENTER);
c.add(la,BorderLayout.SOUTH);
c.addKeyListener(new hiKey());
c.setFocusable(true);
c.requestFocus();
}
class hiKey extends KeyAdapter{
public void keyPressed(KeyEvent e) {
if(e.getKeyChar()=='\n') {
for(int i=0; i<3; i++){
int x = (int)(Math.random()*10);
nums[i].setText(Integer.toString(x));
}
if(nums[0].getText().equals(nums[1].getText()) && nums[1].getText().equals(nums[2].getText())) {
la.setText("SUC-SEE-SE");
}
else {
la.setText("a-sheep-zi-man X");
}
}
}
}
public static void main(String[] args) {
new Main();
*/
public class Main extends JFrame {
private JCheckBox[] fruits = new JCheckBox[3];
private String[] names = { "사과", "배", "체리" };
private JLabel sumLabel;
Main() {
setTitle("체에 1105 체쿠체쿠 Box...");
Container c = getContentPane();
c.setLayout(new FlowLayout());
c.add(new JLabel("사과 10c(1c=10원),배 10c,체리 2000c"));
hiItem hiItem = new hiItem();
for(int i = 0; i<fruits.length;i++) {
fruits[i] = new JCheckBox(names[i]);
fruits[i].setBorderPainted(true);
c.add(fruits[i]);
fruits[i].addItemListener(hiItem);
}
sumLabel = new JLabel("현재 0c");
c.add(sumLabel);
setSize(250,200);
setVisible(true);
}
class hiItem implements ItemListener {
private int sum = 0;
public void itemStateChanged(ItemEvent e) {
if(e.getStateChange()==ItemEvent.SELECTED) {
if(e.getItem()==fruits[0])
sum += 10;
else if(e.getItem()==fruits[1])
sum += 50;
else
sum += 2000;
}
else {
if(e.getItem()==fruits[0])
sum -= 10;
else if(e.getItem()==fruits[1])
sum -= 50;
else
sum-= 2000;
}
sumLabel.setText("현재 "+ sum + "c 입니다.");
}
}
public static void main(String[] args) {
new Main();
}
}



