第一部分:理论知识学习部分

总复习纲要

1. Java语言特点与开发环境配置(第1章、第2章)

2. Java基本程序结构(第3章)

3. Java面向对象程序结构(第4章、第5章、第6章)

4. 类、类间关系、类图

5. Java JDK预定义类/接口及其API(String-第3章、 Arrays-第3章、Files-第3章62页、LocalDate-第4章、 Object-第5章、对象包装器-第5章、Comparator-第6章、 异常类-第7章、ArrayList-第5+8章、第9章、第10-12章、 第14章)     

— Java异常处理编程模型   

—  Java GUI编程模型

6. Java并发程序设计(第14章)

7. Java应用程序部署(第13章) 

 

第二部分:实验部分——实验十八  总复习

实验时间 2018-12-30

1、实验目的与要求

(1) 综合掌握java基本程序结构;

(2) 综合掌握java面向对象程序设计特点;

(3) 综合掌握java GUI 程序设计结构;

(4) 综合掌握java多线程编程模型;

(5) 综合编程练习。

2、实验内容和步骤

任务1:填写课程课后调查问卷,网址:https://www.wjx.cn/jq/33108969.aspx。

任务2:综合编程练习

练习1:设计一个用户信息采集程序,要求如下:

(1)  用户信息输入界面如下图所示:

201771010130 王志成《面向对象程序设计(java)》第十八周学习总结

(1)用户点击提交按钮时,用户输入信息显示控制台界面;

(2)用户点击重置按钮后,清空用户已输入信息;

(3)点击窗口关闭,程序退出

package jiemian;

import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextArea;

public class aaa {

    public static void main(String[] args) {
         EventQueue.invokeLater(() -> {
             JFrame frame = new FrameTest();
             frame.setTitle("WZC");
             frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
             frame.setVisible(true);
          });
       }
    }
    class FrameTest extends JFrame {
         
         private JPanel panel;
         private JRadioButton JRadioButton1,JRadioButton2;
         private ButtonGroup ButtonGroup;
         private JLabel JLabel;
         private JTextArea fieldname,fieldadress;
         private JCheckBox Read,dance,sing;
         private JComboBox<String> JComboBox;
         private JButton Button1,Button2;
         public FrameTest() {
              setSize(700,500);
              panel=new JPanel();
              panel.setLayout(null);
              ButtonGroup=new ButtonGroup();
              JRadioButton1=new JRadioButton("男",false);   JRadioButton1.setBounds(130,330, 80, 50);
              JRadioButton2=new JRadioButton("女",false); JRadioButton2.setBounds(130,300, 80,50);
              ButtonGroup.add(JRadioButton1);
              ButtonGroup.add(JRadioButton2);
              addJLabel("性别:",100,300);
              addJLabel("姓名:",100,50);
              addJLabel("地址:",90,150);
              addJLabel("资格:",400,50);
              addJLabel("喜好:",400,150);
              
              fieldname=new JTextArea(1,1);fieldname.setBounds(150,70, 120, 30);fieldname.setLineWrap(true);
              fieldadress=new JTextArea(5,3);fieldadress.setBounds(150,160, 130, 100);fieldadress.setLineWrap(true);
              Read=new JCheckBox("读书");Read.setBounds(450,160,100,30);
              dance=new JCheckBox("跳舞");dance.setBounds(450,180,100,30);
              sing=new JCheckBox("唱歌");sing.setBounds(450,200,100,30);
              JComboBox=new JComboBox<>();
              JComboBox.addItem("研究生");
              JComboBox.addItem("本科生");
              JComboBox.addItem("专科生");
              JComboBox.setBounds(500,65, 100, 20);
              Button1 = new JButton("提交");Button1.setBounds(200, 400, 100, 35);
              Button2 = new JButton("重置");Button2.setBounds(400, 400, 100, 35);
              Button1.addActionListener(new Action1());
              Button2.addActionListener(new Action2());
              
              panel.add(Button2);
              panel.add(Button1);
              panel.add(JComboBox);
              panel.add(Read);
              panel.add(dance);
              panel.add(sing);
              panel.add(fieldname);
              panel.add(fieldadress);
              panel.add(JRadioButton1);
              panel.add(JRadioButton2);
              add(panel);
     }
     
 
     public void addJLabel(String n,int a,int b) {
         JLabel = new JLabel(n);
         JLabel.setBounds(a,b,100,50);
         panel.add(JLabel);
     }
 
     private class Action1 implements ActionListener {
         public void actionPerformed(ActionEvent event) {        
             System.out.println("name:"+fieldname.getText()+"\n"+"address:"+fieldadress.getText());
             System.out.println("Qualification:"+JComboBox.getSelectedItem());
             System.out.println("Hobby:");
             if(Read.isSelected()==true)System.out.print(Read.getText());
             if(dance.isSelected()==true)System.out.print(dance.getText());
             if(sing.isSelected()==true)System.out.print(sing.getText());
             System.out.println("\n"+"sex:");
             if(JRadioButton1.isSelected()==true)System.out.println(JRadioButton1.getText());
             if(JRadioButton2.isSelected()==true)System.out.println(JRadioButton2.getText());
             System.out.println("\n");
         }
     } 
         private class Action2 implements ActionListener {
             public void actionPerformed(ActionEvent event) {        
                 fieldname.setText(null);
                 fieldadress.setText(null);
                 Read.setSelected(false);
                 dance.setSelected(false);
                 sing.setSelected(false);
                 ButtonGroup.clearSelection();
                 JComboBox.setSelectedIndex(0);
             }
         }   
 
}
View Code

相关文章:

  • 2021-09-06
  • 2022-02-14
  • 2021-05-19
  • 2021-07-10
  • 2021-07-10
  • 2021-09-11
  • 2021-12-10
  • 2021-11-07
猜你喜欢
  • 2022-02-18
  • 2022-02-28
  • 2021-10-16
  • 2021-08-23
  • 2021-08-27
  • 2022-01-15
  • 2021-09-07
相关资源
相似解决方案