/*
import javax.swing.*;
public class Main extends JFrame {
public 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.add(new JMenuItem("Hide"));
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();
public Main() {
setTitle("Menu에 Action 리스너 만들기 예제");
createMenu();
getContentPane().add(imgLabel, BorderLayout.CENTER);
setSize(250,220);
setVisible(true);
}
private void createMenu() {
JMenuBar mb = new JMenuBar();
JMenuItem [] menuItem = new JMenuItem [4];
String[] itemTitle = {"Load", "Hide", "ReShow", "Exit"};
JMenu screenMenu = new JMenu("Screen");
MenuActionListener listener = new MenuActionListener();
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);
setJMenuBar(mb);
}
class MenuActionListener implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
String cmd = e.getActionCommand();
switch(cmd) {
case "Load" :
if(imgLabel.getIcon() != null)
return;
imgLabel.setIcon(new ImageIcon("images/img.jpg"));
break;
case "Hide" :
imgLabel.setVisible(false);
break;
case "ReShow" :
imgLabel.setVisible(true);
break;
case "Exit" :
System.exit(0);
break;
}
}
}
public static void main(String[] args) {
new Main();
}
}
*/
/*
import javax.swing.*;
import java.awt.*;
public class Main extends JFrame {
private Container contentPane;
public Main() {
setTitle("툴바 만들기 예제");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
contentPane = getContentPane();
createToolBar();
setSize(400,200);
setVisible(true);
}
private void createToolBar() {
JToolBar toolBar = new JToolBar("Kitae Menu");
toolBar.setBackground(Color.LIGHT_GRAY);
toolBar.add(new JButton("New"));
toolBar.add(new JButton(new ImageIcon("images/open.jpg")));
toolBar.addSeparator();
toolBar.add(new JButton(new ImageIcon("images/save.jpg")));
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 javax.swing.border.Border;
import java.awt.*;
public class Main extends JFrame {
private Container contentPane;
public Main() {
setTitle("튤팁 예제");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
contentPane = getContentPane();
createToolBar();
setSize(400,150);
setVisible(true);
}
private void createToolBar() {
JToolBar bar = new JToolBar("Kitae Menu");
bar.setBackground(Color.LIGHT_GRAY);
JButton newBtn = new JButton("New");
newBtn.setToolTipText("파일을 생성합니다.");
bar.add(newBtn);
JButton openBtn = new JButton(new ImageIcon("images/open.jpg"));
openBtn.setToolTipText("파일을 엽니다.");
bar.add(openBtn);
bar.addSeparator();
JButton saveBtn = new JButton(new ImageIcon("images/save.jpg"));
saveBtn.setToolTipText("파일을 저장합니다.");
bar.add(saveBtn);
bar.add(new JLabel("search"));
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 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());
JLabel cherryLabel = new JLabel(new ImageIcon("images/cherry.jpg"));
cherryLabel.setToolTipText("체리 이미지 어때요");
JLabel appleLabel = new JLabel(new ImageIcon("images/apple.jpg"));
appleLabel.setToolTipText("사과 이미지 어때요");
c.add(cherryLabel);
c.add(appleLabel);
ToolTipManager m = ToolTipManager.sharedInstance();
m.setInitialDelay(0);
m.setDismissDelay(10000);
setSize(400,220);
setVisible(true);
}
public static void main(String[] args) {
new Main();
}
}
*/
/*
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class MyDialog extends JDialog {
private JTextField tf = new JTextField(10);
private JButton okButton = new JButton("OK");
public MyDialog(JFrame frame, String title) {
super(frame,title);
setLayout(new FlowLayout());
add(tf);
add(okButton);
setSize(200, 100);
okButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
setVisible(true);
}
});
}
}
public class Main extends JFrame {
private MyDialog dialog;
public Main() {
super("dialogEx 예제 프레임");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JButton btn = new JButton("Show Dialog");
dialog = new MyDialog(this, "Test Dialog");
btn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
dialog.setVisible(true);
}
});
getContentPane().add(btn);
setSize(250,200);
setVisible(true);
}
public static void main(String[] args) {
new Main();
}
}
*/
/*
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class MyModalDialog extends JDialog {
private JTextField tf = new JTextField(10);
private JButton okBtton = new JButton("OK");
public MyModalDialog(JFrame frame, String title) {
super(frame, title, true);
setLayout(new FlowLayout());
add(tf);
add(okBtton);
setSize(200,100);
okBtton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
setVisible(false);
}
});
}
public String getInput() {
if(tf.getText().length() == 0) return null;
else return tf.getText();
}
}
public class Main extends JFrame {
private MyModalDialog dialog;
public Main() {
super("DialogEx2 예제 프레임");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JButton btn = new JButton("Show Modal Dialog");
dialog = new MyModalDialog(this, "Test Modal Dialog");
btn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
dialog.setVisible(true);
String text = dialog.getInput();
if(text == null) return;
JButton btn = (JButton)e.getSource();
btn.setText(text);
}
});
getContentPane().add(btn);
setSize(250,200);
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 {
public Main() {
setTitle("옵션 팬 예제");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c = getContentPane();
setSize(500,200);
c.add(new MyPanel(), BorderLayout.NORTH);
setVisible(true);
}
class MyPanel extends Panel {
private JButton inputBtn = new JButton("Input Name");
private JTextField tf = new JTextField(10);
private JButton confirmBtn = new JButton("Confirm");
private JButton messageBtn = new JButton("Message");
public MyPanel() {
setBackground(Color.LIGHT_GRAY);
add(inputBtn);
add(confirmBtn);
add(messageBtn);
add(tf);
inputBtn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String name = JOptionPane.showInputDialog("이름을 입력하세요.");
if(name != null)
tf.setText(name);
}
});
confirmBtn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
int result = JOptionPane.showConfirmDialog(null, "계속할 것입니까?", "Confirm", JOptionPane.YES_NO_OPTION);
if(result == JOptionPane.CLOSED_OPTION)
tf.setText("Just Closed without Selection");
else if(result == JOptionPane.YES_OPTION)
tf.setText("Yes");
else
tf.setText("No");
}
});
messageBtn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(null, "조심하세요", "Message", JOptionPane.ERROR_MESSAGE);
}
});
}
}
public static void main(String[] args) {
new Main();
}
}
*/
/*
import javax.swing.*;
import javax.swing.filechooser.*;
import java.awt.event.*;
import java.awt.*;
public class Main extends JFrame {
private JLabel imageLabel = new JLabel();
public Main() {
setTitle("Menu와 JFileChooser 활용 예제");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c = getContentPane();
c.add(imageLabel);
createMenu();
setSize(350,200);
setVisible(true);
}
private void createMenu() {
JMenuBar mb = new JMenuBar();
JMenu fileMenu = new JMenu("File");
JMenuItem openItem = new JMenuItem("Open");
openItem.addActionListener(new OpenActionListener());
fileMenu.add(openItem);
mb.add(fileMenu);
setJMenuBar(mb);
}
class OpenActionListener implements ActionListener {
private JFileChooser chooser ;
public OpenActionListener() {
chooser = new JFileChooser();
}
@Override
public void actionPerformed(ActionEvent e) {
FileNameExtensionFilter filter = new FileNameExtensionFilter("JPG & GIF Images", "jpg", "gif");
chooser.setFileFilter(filter);
int ret = chooser.showOpenDialog(null);
if(ret != JFileChooser.APPROVE_OPTION) {
JOptionPane.showMessageDialog(null, "파일을 선택하지 않았습니다", "경고", JOptionPane.WARNING_MESSAGE);
return ;
}
String filePath = chooser.getSelectedFile().getPath();
imageLabel.setIcon(new ImageIcon(filePath));
pack();
}
}
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 label = new JLabel("Hello");
public Main() {
setTitle("JColorChooser 예제");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c = getContentPane();
label.setHorizontalAlignment(SwingConstants.CENTER);
label.setFont(new Font("Ravie", Font.ITALIC, 30));
c.add(label, BorderLayout.CENTER);
createMenu();
setSize(250,200);
setVisible(true);
}
private void createMenu() {
JMenuBar mb = new JMenuBar();
JMenuItem colorMenuItem = new JMenuItem("Color");
JMenu fileMenu = new JMenu("Text");
colorMenuItem.addActionListener(new MenuActionListener());
fileMenu.add(colorMenuItem);
mb.add(fileMenu);
this.setJMenuBar(mb);
}
class MenuActionListener implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
String cmd = e.getActionCommand();
if(cmd.equals("Color")) {
Color selectedColor = JColorChooser.showDialog(null,"Color",Color.YELLOW);
if(selectedColor != null)
label.setForeground(selectedColor);
}
}
}
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();
JTabbedPane pane = createTabbedPane();
c.add(pane, BorderLayout.CENTER);
setSize(250,250);
setVisible(true);
}
private JTabbedPane createTabbedPane() {
JTabbedPane pane = new JTabbedPane();
pane.addTab("tab1", new JLabel(new ImageIcon("images/img1.jpg")));
pane.addTab("tab2", new JLabel(new ImageIcon("images/img2.jpg")));
pane.addTab("tab3", new MyPanel());
return pane;
}
class MyPanel extends JPanel {
public MyPanel() {
this.setBackground(Color.YELLOW);
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.setColor(Color.RED);
g.fillRect(10, 10, 50, 50);
g.setColor(Color.BLUE);
g.fillOval(10, 70, 50, 50);
g.setColor(Color.BLACK);
g.drawString("tab 3에 들어가는 JPanel 입니다. ", 30, 50);
}
}
public static void main(String[] args) {
new Main();
}
}
*/
/*
import javax.sound.sampled.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
public class Main extends JFrame {
private JButton btns[] = { new JButton("play"),
new JButton("stop"),
new JButton("play again")};
private Clip clip;
public Main() {
setTitle("오디오 제어");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(300,150);
Container c = getContentPane();
c.setLayout(new FlowLayout());
MyActionListener al = new MyActionListener();
for(int i=0; i<btns.length; i++) {
c.add(btns[i]);
btns[i].addActionListener(al);
}
setVisible(true);
//loadAudio("audio/애국가1절.wav");
}
private void loadAudio(String pathName) {
try {
clip = AudioSystem.getClip();
File audioFile = new File(pathName);
AudioInputStream audioStream = AudioSystem.getAudioInputStream(audioFile);
clip.open(audioStream);
}
catch (LineUnavailableException e) { e.printStackTrace(); }
catch (UnsupportedAudioFileException e) { e.printStackTrace(); }
catch (IOException e) { e.printStackTrace(); }
}
class MyActionListener implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
switch(e.getActionCommand()) {
case "play": clip.start();
break;
case "stop": clip.stop();
break;
case "play again":
clip.setFramePosition(0);
clip.start();
break;
}
}
}
public static void main(String[] args) {
new Main();
}
}
*/
/*
import javax.sound.sampled.*;
import javax.swing.*;
import java.awt.*;
import java.io.*;
public class Main extends JFrame {
private Clip clip;
private String song = "audio/애국가1절.wav";
private JLabel label = new JLabel(song);
public Main() {
setTitle("애국가 1절 연주");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c = getContentPane();
c.setLayout(new FlowLayout());
c.setBackground(Color.YELLOW);
c.add(label);
setSize(300,150);
setVisible(true);
loadAudio(song);
}
private void loadAudio(String pathName) {
try {
File audioFile = new File(pathName);
final AudioInputStream audioStream = AudioSystem.getAudioInputStream(audioFile);
clip = AudioSystem.getClip();
clip.addLineListener(new Listener() {
public void update(LineEvent e) {
if(e.getType() == LineEvent.Type.STOP) {
try {
getContentPane().setBackground(Color.ORANGE);
label.setText(song + " 연주 끝!");
audioStream.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
});
clip.open(audioStream);
clip.start();
}
catch(LineUnavailableException e) { e.printStackTrace(); }
catch(UnsupportedAudioFileException e) { e.printStackTrace(); }
catch(IOException e) { e.printStackTrace(); }
}
public static void main(String[] args) {
new Main();
}
}
*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.util.*;
class Conversion_Machine {
private String obj,res;
private void encryption() {
char [] str = obj.toCharArray();
}
}



