/*import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class MD extends JDialog{
private JTextField tf = new JTextField(10);
private JButton ob = new JButton("ok");
public MD(JFrame frame, String title) {
super (frame,title);
setLayout(new FlowLayout()) ;
add(tf);
add(ob);
setSize(200,100);
ob.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
setVisible(false);
}
});
}
}
public class Main extends JFrame{
private MD diolog;
public Main() {
super("최지렁이");
JButton btn = new JButton ("최조개");
diolog = new MD (this, "최파키케팔로 사우루스");
btn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
diolog.setVisible(true);
}
});
getContentPane().add(btn);
setSize(250,250);
setVisible(true);
}
public static void main(String[] args) {
new Main();
}
}*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class MyMD extends JDialog {
private JTextField tf = new JTextField(10);
private JButton ok = new JButton ("최조렁이");
public MyMD(JFrame frame,String title) {
super (frame, title, true);
setLayout(new FlowLayout());
add (tf);
add(ok);
setSize(200,100);
ok.addActionListener(new ActionListener() {
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 MyMD dialog;
public Main() {
super("최지원숭");
JButton btn = new JButton("최조성");
dialog = new MyMD(this,"최조랑이");
btn.addActionListener(new ActionListener() {
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();
}
}



