import javax.swing.*;

public class InputDialogExample {

public static void main(String[] args) { JFrame frame = new JFrame('InputDialog Example'); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

  String name = JOptionPane.showInputDialog(frame, 'What is your name?');
  String age = JOptionPane.showInputDialog(frame, 'What is your age?');
  String phone = JOptionPane.showInputDialog(frame, 'What is your phone number?');
  String email = JOptionPane.showInputDialog(frame, 'What is your email?');

  JOptionPane.showMessageDialog(frame, 'Name: ' + name + '\nAge: ' + age + '\nPhone: ' + phone + '\nEmail: ' + email);

  System.exit(0);

} }

Java Swing 弹窗输入框示例:获取用户姓名、年龄、电话和邮箱

原文地址: https://www.cveoy.top/t/topic/ok83 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录