标签:大小 serial cep upper ble 添加 default version void
参考案列:https://www.cnblogs.com/blog5277/p/5920560.html
java Swing文本框:
package com.huawi;
import com.sun.deploy.util.StringUtils;
import sun.misc.BASE64Decoder;
import javax.swing.*;
import java.awt.*;
import java.io.IOException;
public class MyFrame extends JFrame {
private static final long serialVersionUID = 1L;
JLabel label1 = new JLabel("输入");
// 注意:构造参数,16表示16列,用于计算宽度显示,并不是字符个数限制
JTextField textField = new JTextField(25);
JButton button = new JButton("确定");
JLabel label2 = new JLabel("输出");
JTextField textField2 = new JTextField(20);
public MyFrame(String title) {
super(title);//调用父类JFrame的构造方法
Container contentPane = getContentPane();
contentPane.setLayout(new FlowLayout());
// 添加控件
contentPane.add(label1);
contentPane.add(textField);
contentPane.add(button);
contentPane.add(label2);
contentPane.add(textField2);
// 按钮点击处理
button.addActionListener(e -> onButtonOk());
}
// 事件处理
private void onButtonOk() {
// 消息提示框 (注意 showMessageDialog() 是静态方法 )
// JOptionPane.showMessageDialog(this, "输入了: " + textField.getText());
BASE64Decoder base64Decoder = new BASE64Decoder();
String s = "";
try {
String text = textField.getText();
s = text.toUpperCase();
} catch (Exception e) {
e.printStackTrace();
}
textField2.setText(s);
}
public static void main(String[] args) {
// JFrame指一个窗口,构造方法的参数为窗口标题
MyFrame frame = new MyFrame("Swing Demo");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// 设置窗口的其他参数,如窗口大小
frame.setSize(400, 300);
// 显示窗口
frame.setVisible(true);
}
}
标签:大小 serial cep upper ble 添加 default version void
原文地址:https://www.cnblogs.com/csh520mjy/p/15027900.html