Programming and Problem Solving with Java

(やまだぃちぅ) #1

(^334) | Inheritance, Polymorphism, and Scope
discussed. We will explain its meaning later in this chapter. Don’t worry—you don’t need to
learn how any of these methods work! We’re just illustrating how Java library classes are doc-
umented.
public classJTextField extendsJTextComponent
{
JTextField()
JTextField(Document doc, String text, int columns)
JTextField(int columns)
JTextField(String text)
JTextField(String text, int columns)
voidaddActionListener(ActionListener l)
protected voidconfigurePropertiesFromAction(Action a)
protectedPropertyChangeListener createActionPropertyChangeListener(Action a)
protectedDocument createDefaultModel()
protected voidfireActionPerformed()
AccessibleContext getAccessibleContext()
Action getAction()
ActionListener[] getActionListeners()
Action[] getActions()
int getColumns()
protected intgetColumnWidth()
int getHorizontalAlignment()
BoundedRangeModel getHorizontalVisibility()
Dimension getPreferredSize()
int getScrollOffset()
String getUIClassID()
booleanisValidateRoot()
protectedString paramString()
voidpostActionEvent()
voidremoveActionListener(ActionListener l)
voidscrollRectToVisible(Rectangle r)
voidsetAction(Action a)
voidsetActionCommand(String command)
voidsetColumns(int columns)
voidsetDocument(Document doc)
voidsetFont(Font f)
voidsetHorizontalAlignment(int alignment)
voidsetScrollOffset(int scrollOffset)
}
A first glance at the class is somewhat disappointing. If this class is used to create input
boxes in a window, shouldn’t it list methods to retrieve what the user inputs? None of these
methods have identifiers that indicate they input values. But wait! The class header says that
JTextFieldextendsJTextComponent. That little bit of code tells us that this definition is just
part of the story. We have to look at the documentation for JTextComponentto determine what
JTextFieldinherits from it. In fact,JTextComponentdefines 68 additional methods that are in-

Free download pdf