Java Reference
In-Depth Information
result of the analysis (the text in upper case and the number of 'E's in it) is then
acquired from the text analysis model by calling the appropriate
get
-methods of
the
TextAnalysisModel
. The results are displayed and the text in the text field is
erased, i.e. replaced by the empty string.
We now list the two classes defining the view.
File:
its/TextAnalysisGUI/TextAnalysisFrame.java
1.
package
its.TextAnalysisGUI;
2.
3.
import
its.SimpleFrame.SimpleFrame;
import
java.awt.*;
4.
import
javax.swing.JButton;
5.
6.
7.
public class
TextAnalysisFrame
extends
SimpleFrame
{
8.
public
TextAnalysisFrame()
9.
{
10.
11.
this
.setSize(300,150);
12.
TextAnalysisPanel taPanel =
new
TextAnalysisPanel();
13.
this
.getContentPane().add(taPanel,BorderLayout.CENTER);
14.
JButton analyseButton =
new
JButton("Analyse");
15.
analyseButton.setBackground(Color.blue);
16.
analyseButton.setForeground(Color.yellow);
17.
this
.getContentPane().add(analyseButton,BorderLayout.SOUTH);
18.
19.
TextAnalysisListener taList =
new
TextAnalysisListener(taPanel);
20.
21.
analyseButton.addActionListener(taList);
22.
}
23.
24.
}
File:
its/TextAnalysisGUI/TextAnalysisPanel.java
package
its.TextAnalysisGUI;
1.
2.
3.
import
java.awt.Color;
import
java.awt.GridLayout;
4.
import
javax.swing.JLabel;
5.
import
javax.swing.JPanel;
6.
import
javax.swing.JTextField;
7.
Search WWH ::
Custom Search