Personal items (WC.exe) (java) (graphic user interface)

A, Github project address: https: //github.com/Leungdc/ENhomework

Two, PSP:

PSP2.1

Personal Software Process Stages

Estimated time consuming (minutes)

The actual time-consuming (minutes)

·Planning

·plan

40

60

· Estimate

• Estimate how much time this task requires

30

30

·Development

· Development

1500

1860

· Analysis

· demand analysis 

30

70

· Design Spec

Generate design documents

30

30

· Design Review

· Design Review 

20

15

· Coding Standard

· Code Specification

60

40

· Design

· Specific design

20

30

· Coding

· Specific coding

1440

1800

· Code Review

· Code Review

30

120

· Test

· Test (self-test, modify the code, submit modifications)

20

80

·Reporting

·report

60

60

· Test Report

· testing report

60

40

· Size Measurement

· Computing workload

20

20

· Postmortem & Process Improvement Plan

· Hindsight, and propose process improvement plan

30

30

total

 

1700

2000

 

Third, the problem-solving ideas

Architecture: wc.exe program based graphical interface implementation.

Main form (WC.exe): Run Program Start → pop button click input → → → user program instruction form the window in the body text field execution

Vice Form (available file): Enter the main form text field "-x" → → open a form, vice user clicks a button scanning system in all .c files → Select file → Click the Start button → program execution

Specific Forms chart   

               

 

The question: What is this form? 

A: JFrame.

Question two: text fields below with what components?   

答:JTextArea。

Question three: Why not JTextFiled and use JTextArea   

A: JTextField only one line in the text field.                   

Question 4: How to add scroll bars to JTextArea?

答:把JTextArea添加到JScrollPane中,当文本域中的文本宽或高超出文本域时,会自动显现上下滚动条或左右滚动条。

问题五:怎么接受到用户的输入,并将输出显示在文本域中呢?

答:JTextArea中的.getText方法和.setText方法可以分别得到和设置文本域中的内容,返回类型为String

 

四、设计过程实现

                 //由于在具体的实现中副窗体中的代码大多是主窗体代码的复用,所以下面只讨论主窗体的代码组织

                     

 

 

在WCview类中有一个主类以及十三个方法,按照功能可以分为基本方法和指令方法,按照其使用的独立性可以分为独立方法和非独立方法。

非独立方法:WCview();initialize();Readfile();方法,其中,

        WCview方法调用initialize方法,对设计的窗体进行初始化操作,如设置窗体的大小,窗体中按钮的事件监听器等;

        而Readfile()方法则是对“开始”按钮的事件反应,当用户点击“开始”按钮时,就会自动调用Readfile()方法;该方法内容包括如下几点:

  1、textArea.getArea获取文本域中的指令。

  2、对于非法的指令,在文本域中设置报错信息(textArea.setTextArea)反映给用户。

  3、对于合法的指令,读取文本域中用户输入的文件路径,File f  =  new file(路径);创建文件对象,并使用switch方法对指令进行判断,如“-c”;,

独立方法:如wActionPerformed();refresh()方法等,根据程序的需要,设计了独立的代码,供其他类或方法使用。

 

按照功能分为的基本方法和指令方法

基本方法:1.readtoString方法;根据所所选文件的编码方式,返回字符串数据

                  2.print方法,递归查找全盘,或者所选根目录下符合要求的.c文件

                  3.getdirectory方法,递归查找全盘的.c文件

                  4.refresh方法,刷新一些重要的全局变量

指令方法:1.-cActionPerformed():  -c指令的实现①正则表达式匹配String内容。②对匹配内容计数,.setText方法输出到文本域中。

                  2.-wActionPerformed():  -w指令的实现①正则表达式匹配String内容。②对匹配内容计数,.setText方法输出到文本域中。

                  3.-aActionPerformed():  -a指令的实现①正则表达式匹配String内容。②对匹配内容计数,.setText方法输出到文本域中。

                  4.-lActionPerformed():  -l指令的实现①.setText输出文件内容到文本域。②.getlineCount对行数计数,.setText方法输出行数。

                  5.-sActionPerformed();     

                                 -s(+路径):递归处理全盘或者所加路径下所有的.c文件。

                                 -s-c/w/l/a:    ①用print方法读取目录下的所有.c文件  ②用Readfile读取文件内容  ③ 按需求用.setText方法输出到文本域中。

                 6.-xActionPerformed();

                                   ①自动打开-x操作的窗体

                                   ②用户点击“扫描”按钮后扫描全盘下的.c文件,并输出到textArea

                                   ③用户选择要操作的目录,点击“开始”按钮输出相关信息。

             

 

Guess you like

Origin www.cnblogs.com/dcLeung/p/11588412.html