Java Reference
In-Depth Information
29.
return (currentNumberOfEs);
30.
}
31.
32.
public String getCurrentText(){
33.
return (currentText);
34.
}
35.
36.
public int getTotalNumberOfEs(){
37.
return (totalNumberOfEs);
38.
}
39.
40.
public int getTotalNumberOfTexts(){
41.
return (totalNumberOfTexts);
42.
}
}
43.
We do not list the test class here but it should be obvious which functions it has
to check.
4.3
The view part
We use one new Swing component to construct this GUI, described below.
4.3.1
Text fields
Text fields display a single line of text. The text can be edited by the user. The
class JTextField realizes text fields in Java. To edit a text, click inside the text
field and a cursor will appear. The text field automatically scrolls horizontally if
the text gets long. This functionality is built in. Text fields are non-transparent
and have a white background and black text by default.
public JTextField(String text);
public String getText();
public void setText(String text);
public void setForeground(Color c);
public void setBackground(Color c);
JTextField(String text) constructs a text field which displays the text .
setText(String text) replaces the text currently displayed in the text field by
text .
getText() returns the text currently displayed in the text field as a String .
setForeground(Color c) sets the text colour to c .
setBackground(Color c) sets the background colour to c .
Search WWH ::




Custom Search