哪位帮帮忙啊要对的啊

来源:百度知道 编辑:UC知道 时间:2024/06/01 18:57:38
本区可以使用getSelectedText()方法获取该文本区通过拖动鼠标选中的文本。编写应用程序,有一个标题为“挑单词”的窗口,窗口的布局为BorderLayout布局。窗口中添加两个文本区和一个程序组件,要求文本区分别添加到窗口的东部区域和西部区域;按钮添加到窗口的南部区域,当单击按钮时,程序将东部区域的文本区中鼠标选中的内容尾加到西部区域的文本区中。

//会将右边(东部)选中文本复制到左边(西部)文本框
//又帮楼主改了下,现在是BorderLayout了。

import java.awt.*;
import java.awt.event.*;
import java.awt.Component;

public class SelectWord extends Frame {
Button b = new Button("AddText");
double heigth, weigth;
double x, y;
TextField tf1 = new TextField(null, 10);
TextField tf2 = new TextField(null, 10);
public SelectWord() {
super("挑单词");

setLayout(new BorderLayout());

this.add(tf1,BorderLayout.WEST);
this.add(tf2,BorderLayout.EAST);

this.add(b,BorderLayout.SOUTH);
pack();
setVisible(true);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
b.addActionListener(new ButtonListener());
}

class ButtonListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
i