/*import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Main extends JFrame{
int g=0;
private JLabel[] l=new JLabel[10];
Main()
{
setTitle("랜ㄷ");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c=getContentPane();
c.setLayout(null);
for(int i=0;i<10;i++)
{
l[i]=new JLabel();
}
for(int i=0;i<10;i++)
{
c.setLayout(null);
int x=(int)(Math.random()*200)+50;
int y=(int)(Math.random()*200)+50;
l[i].setLocation(x, y);
c.add(l[i]);
l[i].setSize(10,10);
l[i].setText(Integer.toString(i));
l[i].setForeground(Color.magenta);
l[i].addMouseListener(new MyMouseListener());
l[i].setOpaque(true);
}
setVisible(true);
setSize(300,300);
}
class MyMouseListener extends MouseAdapter
{
public void mousePressed(MouseEvent e) {
JLabel pre = (JLabel)e.getSource();
System.out.println(g);
if(l[g]==pre)
{
l[g].setVisible(false);
g++;
}
if(g==10)
{
for(int i=0;i<10;i++)
{
int x=(int)(Math.random()*260)+25;
int y=(int)(Math.random()*260)+25;
l[i].setLocation(x, y);
l[i].setVisible(true);
g=0;
}
}
}
}
public static void main(String[] args) {
new Main();
}
}
*/
/*
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.event.ChangeListener;
import javax.swing.event.ChangeEvent;
public class Main extends JFrame{
int size=1;
JLabel l=new JLabel("100");
JSlider s=new JSlider(JSlider.HORIZONTAL,100,200,100);
Main()
{
setTitle("TextArea Practice Frame");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c=getContentPane();
c.setLayout(new FlowLayout());
c.add(s,BorderLayout.NORTH);
c.add(l);
l.setOpaque(true);
l.setBackground(Color.green);
l.setForeground(Color.black);
s.setPaintLabels(true);
s.setPaintTicks(true);
s.setPaintTrack(true);
s.setMajorTickSpacing(20);
s.addMouseMotionListener(new MyMouseListener());
setSize(500,300);
setVisible(true);
}
class MyMouseListener extends MouseMotionAdapter{
public void mouseDragged(MouseEvent e) {
l.setText(Integer.toString(s.getValue()));
}
}
public static void main(String[] args) {
new Main();
}
}
/*
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Main extends JFrame{
JButton b=new JButton("test button");
JCheckBox c1=new JCheckBox();
JCheckBox c2=new JCheckBox();
JLabel l=new JLabel("버튼 비활성화");
JLabel l1=new JLabel("버튼 감추기");
Main()
{
setTitle("체크박스 만들기 에제");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c=getContentPane();
c.setLayout(new FlowLayout());
c1.setBorderPainted(true);
c2.setBorderPainted(true);
c.add(c1);
c1.addItemListener(new MyItemListener());
c.add(l);
c.add(c2);
c2.addItemListener(new MyItemListener1());
c.add(l1);
l.setOpaque(true);
l1.setOpaque(true);
c.add(b);
setSize(300,300);
setVisible(true);
}
class MyItemListener implements ItemListener
{
public void itemStateChanged(ItemEvent e) {
if(e.getStateChange()==ItemEvent.DESELECTED)
{
b.setEnabled(true);
return;
}
else
{
b.setEnabled(false);
}
}
}
class MyItemListener1 implements ItemListener
{
public void itemStateChanged(ItemEvent e) {
if(e.getStateChange()==ItemEvent.DESELECTED)
{
b.setVisible(true);
return;
}
else
{
b.setVisible(false);
}
}
}
public static void main(String[] args) {
new Main();
}
}
*/
/*
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Main extends JFrame{
JTextField t=new JTextField(10);
JComboBox b=new JComboBox();
Main()
{
setTitle("체크박스 만들기 에제");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c=getContentPane();
c.setLayout(new FlowLayout());
t.addKeyListener(new MyKeyListener());
c.add(t);
c.add(b);
t.setFocusable(true);
t.requestFocus();
setSize(300,300);
setVisible(true);
}
class MyKeyListener extends KeyAdapter
{
public void keyPressed(KeyEvent e) {
if(e.getKeyCode() == KeyEvent.VK_LEFT)
{
b.addItem(t.getText());
t.setText("");
}
}
}
public static void main(String[] args) {
new Main();
}
}
*/
/*
import javax.swing.*;
import java.awt.*;
public class Main extends JFrame{
private String [] fruits= {"apple","banana","kiwi","mango","pear","peach","berry","strawberry","blackberry"};
private ImageIcon [] images= {new ImageIcon("src/d.PNG"),
new ImageIcon("src/d1.PNG"),
new ImageIcon("src/d2.PNG"),
new ImageIcon("src/d3.PNG")};
Main(){
setTitle("리스트 만들기 예제");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c=getContentPane();
c.setLayout(new FlowLayout());
JList<String> strList=new JList<String>(fruits);
c.add(strList);
JList<ImageIcon> imageList=new JList<ImageIcon>(images);
imageList.setListData(images);
c.add(imageList);
JList<String> scrollPane=new JList<String>(fruits);
c.add(new JScrollPane(scrollPane));
setSize(300,300);
setVisible(true);
}
public static void main(String[] args) {
new Main();
}
}
*/
/*
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
public class Main extends JFrame{
private JTextField tf=new JTextField(10);
private Vector<String> v=new Vector<String>();
private JList<String> nameList=new JList<String>(v);
Main()
{
setTitle("리스트 변경 예제");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c=getContentPane();
c.setLayout(new FlowLayout());
c.add(new JLabel("이름 입력후 <Enter> 키"));
c.add(tf);
v.add("황기태");
v.add("이재문");
nameList.setVisibleRowCount(5);
nameList.setFixedCellWidth(100);
c.add(new JScrollPane(nameList));
setSize(300,300);
setVisible(true);
tf.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JTextField t=(JTextField)e.getSource();
v.add(t.getText());
t.setText("");
nameList.setListData(v);
}
});
}
public static void main(String[] args) {
new Main();
}
}
*/
/*
import javax.swing.*;
import java.awt.*;
public class Main extends JFrame{
private String [] fruits= {"apple","banana","kiwi","mango","pear","peach","berry","strawberry","blackberry"};
private String [] names= {"kitea","jeamoon","hyosoo","namyun"};
Main()
{
setTitle("콤보박스 만들기 예제");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c=getContentPane();
c.setLayout(new FlowLayout());
JComboBox<String> strCombo=new JComboBox<String>(fruits);
c.add(strCombo);
JComboBox<String> nameCombo=new JComboBox<String>();
for(int i=0;i<names.length;i++)
{
nameCombo.addItem(names[i]);
}
c.add(nameCombo);
setSize(300,300);
setVisible(true);
}
public static void main(String[] args) {
new Main();
}
}
*/
/*
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Main extends JFrame{
private String [] fruits= {"apple","banana","kiwi","mango","java"};
private ImageIcon [] images= {new ImageIcon("src/d.PNG"),
new ImageIcon("src/d1.PNG"),
new ImageIcon("src/d2.PNG"),
new ImageIcon("src/d3.PNG"),
new ImageIcon("src/d4.PNG")};
private JLabel imgLabel=new JLabel(images[0]);
private JComboBox<String> strCombo=new JComboBox<String>(fruits);
Main()
{
setTitle("콤보박스 활용 예제");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c=getContentPane();
c.setLayout(new FlowLayout());
c.add(strCombo);
c.add(imgLabel);
strCombo.addActionListener(new MyActionListener());
setSize(300,250);
setVisible(true);
}
class MyActionListener implements ActionListener
{
public void actionPerformed(ActionEvent e) {
JComboBox<String> cb=(JComboBox<String>)e.getSource();
int index=cb.getSelectedIndex();
imgLabel.setIcon(images[index]);
}
}
public static void main(String[] args) {
new Main();
}
}
*/
/*
import javax.swing.*;
public class Main extends JFrame{
Main(){
setTitle("Menu 만들기 예제");
createMenu();
setSize(250,200);
setVisible(true);
}
private void createMenu()
{
JMenuBar mb=new JMenuBar();
JMenu screenMenu =new JMenu("Screen");
screenMenu.add(new JMenuItem("Load"));
screenMenu.addSeparator();
screenMenu.add(new JMenuItem("Hide"));
screenMenu.addSeparator();
screenMenu.add(new JMenuItem("ReShow"));
screenMenu.addSeparator();
screenMenu.add(new JMenuItem("Exit"));
mb.add(screenMenu);
mb.add(new JMenu("Edit"));
mb.add(new JMenu("Source"));
mb.add(new JMenu("Project"));
mb.add(new JMenu("Run"));
setJMenuBar(mb);
}
public static void main(String[] args) {
new Main();
}
}
*/
/*
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class Main extends JFrame{
private JLabel imgLabel=new JLabel();
int g=0;
Main(){
setTitle("Menu에 Action 리스너 만들기 예제");
createMenu();
getContentPane().add(imgLabel,BorderLayout.CENTER);
setSize(250,200);
setVisible(true);
}
private void createMenu()
{
JMenuBar mb=new JMenuBar();
JMenuItem[] menuItem=new JMenuItem[4];
JMenuItem[] tem=new JMenuItem[2];
String[] itemTitle= {"Load","Hide","ReShow","Exit"};
String[] Title= {"Up","Down"};
JMenu screenMenu =new JMenu("Screen");
JMenu Menu =new JMenu("Move");
MenuActionListener listener=new MenuActionListener();
mbActionListener llistener=new mbActionListener();
for(int i=0;i<menuItem.length;i++)
{
menuItem[i]=new JMenuItem(itemTitle[i]);
menuItem[i].addActionListener(listener);
screenMenu.add(menuItem[i]);
}
mb.add(screenMenu);
mb.add(Menu);
for(int i=0;i<2;i++)
{
tem[i]=new JMenuItem(Title[i]);
tem[i].addActionListener(llistener);
Menu.add(tem[i]);
}
setJMenuBar(mb);
}
class MenuActionListener implements ActionListener
{
public void actionPerformed(ActionEvent e) {
String cmd=e.getActionCommand();
switch(cmd)
{
case "Load":if(imgLabel.getIcon()!=null)
{
return;
}
imgLabel.setIcon(new ImageIcon("src/d.PNG"));
break;
case "Hide":
imgLabel.setVisible(false);
break;
case "ReShow" :
imgLabel.setVisible(true);
break;
case "Exit" :
System.exit(0);
break;
}
}
}
class mbActionListener implements ActionListener
{
public void actionPerformed(ActionEvent e) {
String cmd=e.getActionCommand();
switch(cmd)
{
case "Up":
if(g==3)
{
return;
}
g++;
image(g);
break;
case "Down":
if(g==0)
{
return;
}
g--;
image(g);
break;
}
}
private void image(int g)
{
if(g==0)
{
imgLabel.setIcon(new ImageIcon("src/d.PNG"));
}
else if(g==1)
{
imgLabel.setIcon(new ImageIcon("src/d1.PNG"));
}
else if(g==2)
{
imgLabel.setIcon(new ImageIcon("src/d2.PNG"));
}
else if(g==3)
{
imgLabel.setIcon(new ImageIcon("src/d3.PNG"));
}
}
}
public static void main(String[] args) {
new Main();
}
}
*/
/*
import javax.swing.*;
import java.awt.*;
public class Main extends JFrame{
private Container contentPane;
Main(){
setTitle("툴바 만들기 예제");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
contentPane=getContentPane();
createToolBar();
setSize(400,200);
setVisible(true);
}
private void createToolBar() {
JToolBar toolBar =new JToolBar("Kitea Menu");
toolBar.setBackground(Color.LIGHT_GRAY);
toolBar.add(new JButton("new"));
toolBar.add(new JButton(new ImageIcon("src/d.PNG")));
toolBar.addSeparator();
toolBar.add(new JButton(new ImageIcon("src/save.PNG")));
toolBar.add(new JLabel("search"));
toolBar.add(new JTextField("text field"));
JComboBox<String> combo=new JComboBox<String>();
combo.addItem("Java");
combo.addItem("C#");
combo.addItem("C");
combo.addItem("C++");
toolBar.add(combo);
contentPane.add(toolBar,BorderLayout.NORTH);
}
public static void main(String[] args) {
new Main();
}
}
*/
/*
import javax.swing.*;
import java.awt.*;
public class Main extends JFrame{
private Container contentPane;
Main(){
setTitle("툴팁 예제");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
contentPane=getContentPane();
createToolBar();
setSize(400,150);
setVisible(true);
}
private void createToolBar() {
JToolBar bar =new JToolBar("Kitea Menu");
bar.setBackground(Color.LIGHT_GRAY);
JButton newBth=new JButton("New");
newBth.setToolTipText("파일을 생성합니다.");
bar.add(newBth);
JButton openBth=new JButton(new ImageIcon("src/d.PNG"));
openBth.setToolTipText("파일을 엽니다");
bar.add(openBth);
bar.addSeparator();
JButton saveBth=new JButton(new ImageIcon("src/d1.PNG"));
saveBth.setToolTipText("파일을 저장합니다");
bar.add(saveBth);
bar.addSeparator();
JTextField tf=new JTextField("text field");
tf.setToolTipText("찾고자하는 문자열을 입력하세요");
bar.add(tf);
contentPane.add(bar,BorderLayout.NORTH);
}
public static void main(String[] args) {
new Main();
}
}
*/
/*
import java.awt.*;
import javax.swing.*;
public class Main extends JFrame
{
Main()
{
setTitle("툴팁 지연 시간 제어 예제");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c=getContentPane();
c.setLayout(new FlowLayout());
JLabel cherryLabel=new JLabel(new ImageIcon("src/d.PNG"));
cherryLabel.setToolTipText("체리 이미지 어때요");
JLabel appleLabel=new JLabel(new ImageIcon("src/d1.PNG"));
appleLabel.setToolTipText("사과 이미지 어때요");
c.add(cherryLabel);
c.add(appleLabel);
ToolTipManager m=ToolTipManager.sharedInstance();
m.setInitialDelay(0);
m.setDismissDelay(10000);
setSize(400,200);
setVisible(true);
}
public static void main(String[] args) {
new Main();
}
}
*/