import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
public class Border extends JFrame implements ActionListener{
JTextArea jTextArea;
JTextField jTextField;
Border(){
super(" ");
jTextField = new JTextField(12);
add(jTextField,BorderLayout.NORTH);
jTextField.addActionListener(this);
jTextArea = new JTextArea();
add(new JScrollPane(jTextArea),BorderLayout.CENTER);
setBounds(200, 200, 300, 400);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] args) {
Border border = new Border();
}
public void actionPerformed(ActionEvent e){
String string = jTextField.getText();
int n = JOptionPane.showConfirmDialog(this," "," ",
JOptionPane.YES_NO_OPTION );
if(n==JOptionPane.YES_OPTION) {
jTextArea.append("
"+string);
jTextField.setText("");
}
else if(n==JOptionPane.NO_OPTION) {
jTextField.setText(null);
}
}
}