编写一个图形界面的Application程序,包括两个文本框和一个按钮。
1个回答
2009-06-20
展开全部
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JTextArea;
public class Test {
public static void main(String args[]) {
JFrame frame = new JFrame();
frame.setLayout(new FlowLayout(FlowLayout.LEFT));
final JTextArea textArea1 = new JTextArea(20, 30);
final JTextArea textArea2 = new JTextArea(20, 30);
JButton button = new JButton("=>");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
textArea2.setText(textArea1.getText());
}
});
frame.add(textArea1);
frame.add(button);
frame.add(textArea2);
frame.pack();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JTextArea;
public class Test {
public static void main(String args[]) {
JFrame frame = new JFrame();
frame.setLayout(new FlowLayout(FlowLayout.LEFT));
final JTextArea textArea1 = new JTextArea(20, 30);
final JTextArea textArea2 = new JTextArea(20, 30);
JButton button = new JButton("=>");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
textArea2.setText(textArea1.getText());
}
});
frame.add(textArea1);
frame.add(button);
frame.add(textArea2);
frame.pack();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询