admin 管理员组文章数量: 1087131
5.1单行文本框
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.SimpleDateFormat;
import java.util.Date;public class Method{JTextField textField = new JTextField(20);//单行文本框,设置初始字符为20.public Method(String name) {JFrame frame = new JFrame(name);JButton button = new JButton("按钮");JPanel root = new JPanel();frame.add(root);textField.setText("开始:");root.add(textField);root.add(button);button.addActionListener(e -> {String str = textField.getText();//记得在这里面输出,否则只能输出”开始:"System.out.println(str);});frame.setVisible(true);frame.setSize(400,300);}}
本文标签: 51单行文本框
版权声明:本文标题:5.1单行文本框 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.roclinux.cn/b/1686651347a20501.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论