/*
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Main extends JFrame
{
public Main()
{
super("JComponent의 공통 메소드 예제");
Container c = getContentPane();
c.setLayout(new FlowLayout());
JButton b1 = new JButton("Magenta/Yellow Button");
JButton b2 = new JButton(" Disabled Button ");
JButton b3 = new JButton("getX(), getY()");
b1.setBackground(Color.YELLOW);
b1.setBackground(Color.magenta);
b1.setFont(new Font("Arial",Font.ITALIC,20));
b2.setEnabled(false);
b3.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
JButton b = (JButton)e.getSource();
Main frame = (Main)b.getTopLevelAncestor();
frame.setTitle(b.getX() + "," + b.getY());
}
});
c.add(b1); c.add(b2); c.add(b3);
setSize(260,200);
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 FlowLayout());
ImageIcon normalIcon = new ImageIcon("C:\\Users\\user\\Desktop\\보통상태.gif");
ImageIcon rolloverIcon = new ImageIcon("C:\\Users\\user\\Desktop\\버튼 위로.gif");
ImageIcon pressedIcon = new ImageIcon("C:\\Users\\user\\Desktop\\마우스 클릭.gif");
JButton btn = new JButton("call~~",normalIcon);
btn.setPressedIcon(pressedIcon);
btn.setRolloverIcon(rolloverIcon);
c.add(btn);
setSize(250,150);
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 FlowLayout());
ImageIcon cherryIcon = new ImageIcon("C:\\Users\\user\\Desktop\\cherry.jpg");
ImageIcon selectedCherryIcon = new ImageIcon("C:\\Users\\user\\Desktop\\selectedCherry.jpg");
JCheckBox apple = new JCheckBox("사과");
JCheckBox pear = new JCheckBox("배",true);
JCheckBox cherry = new JCheckBox("체리",cherryIcon);
cherry.setBorderPainted(true);
cherry.setSelectedIcon(selectedCherryIcon);
c.add(apple);
c.add(pear);
c.add(cherry);
setSize(250,150);
setVisible(true);
}
public static void main(String[] args) {
new Main();
}
}
*/
//import javax.swing.*;
//import java.awt.event.*;
//import java.awt.*;
//
//public class Main extends JFrame
//{
// private JCheckBox [] fruits = new JCheckBox[3];
// private String [] names = {"사과", "배", "체리"};
//
// private JLabel sumLabel;
// public Main()
// {
// setTitle("체크박스와 ItemEvent 예제");
// setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// Container c = getContentPane();
// c.setLayout(new FlowLayout());
//
// c.add(new JLabel("사과 100원, 배 500원, 체리 20000원 "));
//
// MyItemListener listener = new MyItemListener();
// 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(listener);
// }
//
// sumLabel = new JLabel("현재 0원 입니다.");
// c.add(sumLabel);
// setSize(250,300);
// setVisible(true);
// }
//
// class MyItemListener implements ItemListener
// {
// private int sum = 0;
//
// public void itemStateChanged(ItemEvent e)
// {
//
// if(e.getStateChange()== ItemEvent.SELECTED)
// {
// if(e.getItem() == fruits[0])
// sum += 100;
// else if(e.getItem() == fruits[1])
// {
// sum += 500;
// }
// else
// {
// sum += 20000;
// }
// }
// else
// {
// if(e.getItem() == fruits[0])
// {
// sum -= 100;
// }
// else if(e.getItem() == fruits[1])
// {
// sum -= 500;
// }
// else
// {
// sum -= 20000;
// }
// }
// sumLabel.setText("현재 " + sum + "원 입니다.");
// }
// }
// 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 FlowLayout());
ImageIcon cherryIcon = new ImageIcon("C:\\Users\\user\\Desktop\\cherry.jpg");
ImageIcon selectedCherryIcon = new ImageIcon("C:\\Users\\user\\Desktop\\selectedCherry.jpg");
ButtonGroup g = new ButtonGroup();
JRadioButton apple = new JRadioButton("사과");
JRadioButton pear = new JRadioButton("배",true);
JRadioButton cherry = new JRadioButton("체리",cherryIcon);
cherry.setBorderPainted(true);
cherry.setSelectedIcon(selectedCherryIcon);
g.add(apple);
g.add(pear);
g.add(cherry);
c.add(apple);
c.add(pear);
c.add(cherry);
setSize(250,150);
setVisible(true);
}
public static void main(String[] args) {
new Main();
}
}
*/
/*
import javax.swing.*;
import javax.swing.border.Border;
import java.awt.event.*;
import java.awt.*;
public class Main extends JFrame
{
private JRadioButton [] radio = new JRadioButton [3];
private String [] text = {"사과", "배", "체리"};
private ImageIcon [] image =
{
new ImageIcon("C:\\Users\\user\\Desktop\\apple.jpg"),
new ImageIcon("C:\\Users\\user\\Desktop\\pear.jpg"),
new ImageIcon("C:\\Users\\user\\Desktop\\cherry.jpg")
};
private JLabel imageLabel = new JLabel();
public Main()
{
setTitle("라디오 버튼 Item Event 예제");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c = getContentPane();
c.setLayout(new BorderLayout());
JPanel radioPanel = new JPanel();
radioPanel.setBackground(Color.GRAY);
ButtonGroup g = new ButtonGroup();
for(int i = 0; i < radio.length; i++)
{
radio[i] = new JRadioButton(text[i]);
g.add(radio[i]);
radioPanel.add(radio[i]);
radio[i].addItemListener(new MyItemListener());
}
radio[2].setSelected(true);
c.add(radioPanel,BorderLayout.NORTH);
c.add(imageLabel,BorderLayout.CENTER);
imageLabel.setHorizontalAlignment(SwingConstants.CENTER);
setSize(250,200);
setVisible(true);
}
class MyItemListener implements ItemListener
{
public void itemStateChanged(ItemEvent e)
{
if(e.getStateChange() == ItemEvent.DESELECTED)
{
return;
}
if(radio[0].isSelected())
{
imageLabel.setIcon(image[0]);
}
else if(radio[1].isSelected())
{
imageLabel.setIcon(image[1]);
}
else
{
imageLabel.setIcon(image[2]);
}
}
}
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 FlowLayout());
//
// c.add(new JLabel("이름 "));
// c.add(new JTextField(20));
// c.add(new JLabel("학과"));
// c.add(new JTextField("컴공",20));
// c.add(new JLabel("주소 "));
// c.add(new JTextField("서울시 ...",20));
//
// setSize(300,150);
// setVisible(true);
// }
// public static void main(String[] args) {
// new Main();
// }
//}
/*
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class Main extends JFrame
{
private JTextField tf = new JTextField(20);
private JTextArea ta = new JTextArea(7,20);
public Main() {
setTitle("텍스트영역 만들기 예제");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c = getContentPane();
c.setLayout(new FlowLayout());
c.add(new JLabel("입력 후 <Enter>키 입력하시오"));
c.add(tf);
c.add(new JScrollPane(ta));
tf.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
JTextField t = (JTextField)e.getSource();
ta.append(t.getText() + "\n");
t.setText("");
}
});
}
}
*/