@@ -48,37 +48,22 @@ public class FileSelectorJFrame extends JFrame implements FileSelectorView, Acti
48
48
/**
49
49
* The "OK" button for loading the file.
50
50
*/
51
- private JButton ok ;
51
+ private final JButton ok ;
52
52
53
53
/**
54
54
* The cancel button.
55
55
*/
56
- private JButton cancel ;
57
-
58
- /**
59
- * The information label.
60
- */
61
- private JLabel info ;
62
-
63
- /**
64
- * The contents label.
65
- */
66
- private JLabel contents ;
56
+ private final JButton cancel ;
67
57
68
58
/**
69
59
* The text field for giving the name of the file that we want to open.
70
60
*/
71
- private JTextField input ;
61
+ private final JTextField input ;
72
62
73
63
/**
74
64
* A text area that will keep the contents of the file opened.
75
65
*/
76
- private JTextArea area ;
77
-
78
- /**
79
- * The panel that will hold our widgets.
80
- */
81
- private JPanel panel ;
66
+ private final JTextArea area ;
82
67
83
68
/**
84
69
* The Presenter component that the frame will interact with.
@@ -102,7 +87,7 @@ public FileSelectorJFrame() {
102
87
/*
103
88
* Add the panel.
104
89
*/
105
- this . panel = new JPanel ();
90
+ var panel = new JPanel ();
106
91
panel .setLayout (null );
107
92
this .add (panel );
108
93
panel .setBounds (0 , 0 , 500 , 200 );
@@ -111,48 +96,48 @@ public FileSelectorJFrame() {
111
96
/*
112
97
* Add the info label.
113
98
*/
114
- this . info = new JLabel ("File Name :" );
115
- this . panel .add (info );
99
+ var info = new JLabel ("File Name :" );
100
+ panel .add (info );
116
101
info .setBounds (30 , 10 , 100 , 30 );
117
102
118
103
/*
119
104
* Add the contents label.
120
105
*/
121
- this . contents = new JLabel ("File contents :" );
122
- this . panel .add (contents );
123
- this . contents .setBounds (30 , 100 , 120 , 30 );
106
+ var contents = new JLabel ("File contents :" );
107
+ panel .add (contents );
108
+ contents .setBounds (30 , 100 , 120 , 30 );
124
109
125
110
/*
126
111
* Add the text field.
127
112
*/
128
113
this .input = new JTextField (100 );
129
- this . panel .add (input );
114
+ panel .add (input );
130
115
this .input .setBounds (150 , 15 , 200 , 20 );
131
116
132
117
/*
133
118
* Add the text area.
134
119
*/
135
120
this .area = new JTextArea (100 , 100 );
136
- JScrollPane pane = new JScrollPane (area );
121
+ var pane = new JScrollPane (area );
137
122
pane .setHorizontalScrollBarPolicy (JScrollPane .HORIZONTAL_SCROLLBAR_AS_NEEDED );
138
123
pane .setVerticalScrollBarPolicy (JScrollPane .VERTICAL_SCROLLBAR_AS_NEEDED );
139
- this . panel .add (pane );
124
+ panel .add (pane );
140
125
this .area .setEditable (false );
141
126
pane .setBounds (150 , 100 , 250 , 80 );
142
127
143
128
/*
144
129
* Add the OK button.
145
130
*/
146
131
this .ok = new JButton ("OK" );
147
- this . panel .add (ok );
132
+ panel .add (ok );
148
133
this .ok .setBounds (250 , 50 , 100 , 25 );
149
134
this .ok .addActionListener (this );
150
135
151
136
/*
152
137
* Add the cancel button.
153
138
*/
154
139
this .cancel = new JButton ("Cancel" );
155
- this . panel .add (this .cancel );
140
+ panel .add (this .cancel );
156
141
this .cancel .setBounds (380 , 50 , 100 , 25 );
157
142
this .cancel .addActionListener (this );
158
143
0 commit comments