【发布时间】:2020-09-30 13:21:06
【问题描述】:
在我下面的 java 代码中,它会生成一个带有 jtextrea 的框架。这允许简单的文本处理。我想要做的就是添加“Sam”。最后是 sam 的 5 个空格。每次用户点击进入。您还可以看到我在下面添加的 gif,这正是我正在寻找的。p>
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
class text11 extends JFrame implements ActionListener {
// JFrame
static JFrame f;
// text area
static JTextArea jt;
// main class
public static void main(String[] args)
{
// create a new frame to store text field and button
f = new JFrame("textfield");
// create a label to display text
// create a object of the text class
text11 te = new text11();
// create a text area, specifying the rows and columns
jt = new JTextArea(" ", 20, 20);
JPanel p = new JPanel();
// add the text area and button to panel
p.add(jt);
f.add(p);
// set the size of frame
f.setSize(300, 300);
f.show();
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
}
}
【问题讨论】:
标签: java swing return append jtextarea