/*import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class MyDialog extends JDialog {
private JTextField tf = new JTextField(10);
private JTextField tg = new JTextField(10);
private JButton b = new JButton("kasan");
private JLabel l = new JLabel("두수 더함");
public MyDialog(JFrame frame, String title) {
super(frame, title,true);
setLayout(new FlowLayout());
add(l);
add(tf);
add(tg);
add(b);
setSize(100, 150);
b.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
setVisible(false);
}
});
}
public int getInput() {
int x = Integer.parseInt(tf.getText()); //string-> int
int y = Integer.parseInt(tg.getText());
return x+y;
}
}
public class Main extends JFrame {
private MyDialog dialog;
public Main() {
super("dialogEx 예제 프레임");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JButton b = new JButton("kasanki");
JLabel l1 = new JLabel("x+y");
dialog = new MyDialog(this, "test Dialog");
setLayout(new FlowLayout());
b.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
dialog.setVisible(true);
String text = Integer.toString(dialog.getInput());
if(text == null) return;
l1.setText(text);
l1.repaint();
}
});
l1.setOpaque(true);
l1.setBackground(Color.green);
getContentPane().add(b);
add(l1);
setSize(350, 300);
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 btn = new JButton("Input Name");
private JButton btn1 = new JButton("Confirm");
private JButton btn2 = new JButton("Message");
private TextField tf = new TextField(10);
public Mypanel() {
setBackground(Color.LIGHT_GRAY);
add(btn);
add(btn1);
add(btn2);
add(tf);
btn.addActionListener(new ActionListener() {
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");
}
});
}
}
}