• 政治课就行吧行吧行是


    关注 码龄 粉丝数 原力等级 -- 被采纳 被点赞 采纳率 2301_79725908 2024-06-02 09:49 采纳率: 50% 浏览 4 首页/ 编程语言 / 政治课就行吧行吧行是 java 实验14 个人信息编辑窗口一、实验内容设计一个窗口程序,用来输入学生个人信息,窗口界面如下图所示。要求如下:(1)窗口的布局方式为流式布局;(2)性别采用单选按钮来选择“男”“女”之一;(3)专业采用下拉列表方式来选择,其选项为“软件工程”“计算机科学与技术”“会计学”“财政学”;(4)入学年度采用下拉列表方式来选择,其选项为2016~2030的整数;(5)选修课程采用列表框方式来选择,其选项为“计算机导论”“数据结构”“高等数学”“大学英语”“会计学基础”“财政金融”;(6)单击“确定”按钮,在其下方的文本区中输出所输入的内容。 收起 写回答 好问题 0 提建议 追加酬金 关注问题 微信扫一扫 点击复制链接 分享 邀请回答 编辑 收藏 删除 结题 收藏 举报 追加酬金 (90%的用户在追加酬金后获得了解决方案) 当前问题酬金 ¥ 0 (可追加 ¥500) ¥ 15¥ 20¥ 50¥ 100¥ 200 支付方式 扫码支付 二维码出错 点击刷新 支付金额 15 元 提供问题酬金的用户不参与问题酬金结算和分配 支付即为同意 《付费问题酬金结算规则》 结题 再想想 删除 再等等

    1条回答 默认 最新

    • 阿里嘎多学长 2024-06-02 10:02
      关注

      以下内容由CHATGPT及阿里嘎多学长共同生成、有用望采纳:


      根据你提供的需求,下面是一个简单的Java Swing程序示例,用于创建一个个人信息编辑窗口。这个示例程序将满足你的基本需求,但请注意,这只是一个基础的实现,可能需要根据你的具体需求进行调整。

      import javax.swing.*;
      import java.awt.*;
      import java.awt.event.ActionEvent;
      import java.awt.event.ActionListener;
      
      public class PersonalInfoEditor extends JFrame {
          private JTextField nameField;
          private JRadioButton maleRadioButton;
          private JRadioButton femaleRadioButton;
          private JComboBox majorComboBox;
          private JComboBox yearComboBox;
          private JList courseList;
          private JButton confirmButton;
          private JTextArea resultTextArea;
      
          public PersonalInfoEditor() {
              super("个人信息编辑窗口");
              initializeUI();
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              setSize(400, 600);
              setLocationRelativeTo(null);
          }
      
          private void initializeUI() {
              setLayout(new FlowLayout());
      
              // Name input
              JLabel nameLabel = new JLabel("姓名:");
              nameField = new JTextField(20);
              add(nameLabel);
              add(nameField);
      
              // Gender selection
              JLabel genderLabel = new JLabel("性别:");
              maleRadioButton = new JRadioButton("男");
              femaleRadioButton = new JRadioButton("女");
              ButtonGroup genderGroup = new ButtonGroup();
              genderGroup.add(maleRadioButton);
              genderGroup.add(femaleRadioButton);
              add(genderLabel);
              add(maleRadioButton);
              add(femaleRadioButton);
      
              // Major selection
              JLabel majorLabel = new JLabel("专业:");
              String[] majors = {"软件工程", "计算机科学与技术", "会计学", "财政学"};
              majorComboBox = new JComboBox<>(majors);
              add(majorLabel);
              add(majorComboBox);
      
              // Year selection
              JLabel yearLabel = new JLabel("入学年度:");
              String[] years = new String[2030 - 2016 + 1];
              for (int i = 0; i < years.length; i++) {
                  years[i] = String.valueOf(2016 + i);
              }
              yearComboBox = new JComboBox<>(years);
              add(yearLabel);
              add(yearComboBox);
      
              // Course selection
              JLabel courseLabel = new JLabel("选修课程:");
              String[] courses = {"计算机导论", "数据结构", "高等数学", "大学英语", "会计学基础", "财政金融"};
              courseList = new JList<>(courses);
              add(courseLabel);
              add(new JScrollPane(courseList));
      
              // Confirm button
              confirmButton = new JButton("确定");
              confirmButton.addActionListener(new ActionListener() {
                  @Override
                  public void actionPerformed(ActionEvent e) {
                      outputInfo();
                  }
              });
              add(confirmButton);
      
              // Result text area
              resultTextArea = new JTextArea(10, 40);
              resultTextArea.setEditable(false);
              add(new JScrollPane(resultTextArea));
          }
      
          private void outputInfo() {
              String gender = maleRadioButton.isSelected() ? "男" : "女";
              String major = (String) majorComboBox.getSelectedItem();
              String year = (String) yearComboBox.getSelectedItem();
              String courses = String.join(", ", courseList.getSelectedValuesList());
              resultTextArea.setText("姓名: " + nameField.getText() + "\n" +
                                      "性别: " + gender + "\n" +
                                      "专业: " + major + "\n" +
                                      "入学年度: " + year + "\n" +
                                      "选修课程: " + courses);
          }
      
          public static void main(String[] args) {
              SwingUtilities.invokeLater(new Runnable() {
                  @Override
                  public void run() {
                      new PersonalInfoEditor().setVisible(true);
                  }
              });
          }
      }
      

      这段代码创建了一个名为PersonalInfoEditor的类,它继承自JFrame,代表一个窗口。窗口中包含了姓名输入框、性别单选按钮、专业和入学年度的下拉列表、选修课程的列表框以及一个确定按钮。当点击确定按钮时,会调用outputInfo方法,将输入的信息输出到文本区域。

      至于参考资料,你可以查看Java Swing的官方教程,它提供了详细的组件使用说明和示例代码:

      请根据你的实际开发环境和需求调整上述代码。如果你需要进一步的帮助或有其他问题,随时可以提问。

      展开全部

      评论 编辑记录
      编辑
      预览

      报告相同问题?

    • 相关阅读:
      如何读取resources目录下的文件路径(九种方式)
      故障分析:网络闪断引发的ServiceStack.Redis死锁问题
      ProcessDB实时/时序数据库——ODBC之连接数据库
      fiddler安卓模拟器与ios手机抓包
      神经网络 深度神经网络,双隐层神经网络结构
      智能车串级pid的使用
      招募 AIGC 训练营助教 @上海
      (免费分享)基于springboot医药进销存系统
      APSIM模型】作物模型应用案例
      jupyter lab常用插件集合
    • 原文地址:https://ask.csdn.net/questions/8112834