public class TopLevel extends Observable implements ActionListener
Modifier and Type | Field and Description |
---|---|
protected JFrame |
frame
The Swing frame representing this TopLevel object.
|
Modifier | Constructor and Description |
---|---|
protected |
TopLevel(String title,
boolean exitOnClose)
A new TopLevel with the given TITLE (which window managers
typically display on the border).
|
Modifier and Type | Method and Description |
---|---|
void |
actionPerformed(ActionEvent e) |
protected void |
add(Widget widget,
LayoutSpec layout)
Add WIDGET, placed according to LAYOUT.
|
protected void |
addButton(String label,
Consumer<String> func,
LayoutSpec layout)
Add a new button displaying LABEL, laid out according to
LAYOUT, which when clicked calls FUNC, with the button and
LABEL as its arguments.
|
protected void |
addCheckBox(String label,
boolean selected,
Consumer<String> func,
LayoutSpec layout)
Add a new check box displaying LABEL, laid out according to
LAYOUT, which when clicked calls FUNC, with the button and
LABEL as its arguments.
|
protected void |
addLabel(String text,
LayoutSpec layout)
Add a new, anonymous label that displays the text TEXT, placed
according to LAYOUT.
|
protected void |
addLabel(String text,
String id,
LayoutSpec layout)
Add a label that initially displays the text TEXT, placed
according to LAYOUT, and identified by the tag ID.
|
protected void |
addMenuButton(String label,
Consumer<String> func)
Add a new simple menu button labeled LABEL to my menus, which
when clicked, invokes FUNC, sending the button itself and LABEL
as arguments.
|
protected void |
addMenuCheckBox(String label,
boolean selected,
Consumer<String> func)
Add a check box labeled LABEL to my menus, which when clicked,
flips its state and invokes FUNC, sending the button itself and
LABEL as arguments.
|
protected void |
addMenuRadioButton(String label,
String groupName,
boolean selected,
Consumer<String> func)
Add a radio button labeled LABEL to my menus, belonging to the
group of buttons called GROUPNAME.
|
protected void |
addRadioButton(String label,
String groupName,
boolean selected,
Consumer<String> func,
LayoutSpec layout)
Add a radio button labeled LABEL, placed according to LAYOUT,
belonging to the group of buttons called GROUPNAME.
|
protected void |
addSeparator(String label)
Add a separator to the end of the menu labeled LABEL (which
must exist) in my menu bar.
|
void |
display(boolean visible)
If VISIBLE, display this TopLevel.
|
int |
getHeight()
Return my current height in pixels.
|
String |
getTextInput(String message,
String title,
String type,
String init)
Display a dialog box with message MESSAGE and title TITLE that
prompts the user for textual input, with INIT providing the
initial value of the text.
|
int |
getWidth()
Return my current width in pixels.
|
protected boolean |
isSelected(String label)
Return true iff the button named LABEL is currently selected.
|
protected void |
select(String label,
boolean val)
Set isSelected(LABEL) to VAL, if LABEL is a valid button.
|
protected void |
setEnabled(boolean enable,
String... labels)
Set the enabled status of the buttons labeled LABELS[0], ...
|
protected void |
setLabel(String id,
String text)
Set the text of the existing label with tag ID to TEXT.
|
void |
setMaximumSize(int width,
int height)
Set my maximum size to WIDTH x HEIGHT pixels.
|
void |
setMinimumSize(int width,
int height)
Set my minimum size to WIDTH x HEIGHT pixels.
|
void |
setPreferredFocus(Widget widget)
When the focus is in my window, request that WIDGET, which should
be one of my components, get the focus.
|
void |
setPreferredSize(int width,
int height)
Set my preferred size to WIDTH x HEIGHT pixels.
|
void |
showMessage(String text,
String title,
String type)
Display the dismissable message TEXT of type TYPE in
a separate dialog window with title TITLE.
|
int |
showOptions(String message,
String title,
String type,
String deflt,
String... labels)
Display a choice of optional responses, labeled LABELS[0],...,LABELS[n]
in a separate dialog box with title TITLE and message MESSAGE.
|
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
protected final JFrame frame
protected TopLevel(String title, boolean exitOnClose)
public void display(boolean visible)
public void setPreferredSize(int width, int height)
public void setMinimumSize(int width, int height)
public void setMaximumSize(int width, int height)
public int getWidth()
public int getHeight()
protected void addMenuButton(String label, Consumer<String> func)
protected void addMenuCheckBox(String label, boolean selected, Consumer<String> func)
protected void addMenuRadioButton(String label, String groupName, boolean selected, Consumer<String> func)
isSelected(java.lang.String)
); when the user clicks one, it
becomes selected and any other button in the group is deselected.
If FUNC is non-null, it denotes a function that is invoked
when the button is pressed, sending the button and LABEL as
its arguments.protected void addSeparator(String label)
protected boolean isSelected(String label)
protected void select(String label, boolean val)
protected void setEnabled(boolean enable, String... labels)
protected void addButton(String label, Consumer<String> func, LayoutSpec layout)
protected void addCheckBox(String label, boolean selected, Consumer<String> func, LayoutSpec layout)
protected void addRadioButton(String label, String groupName, boolean selected, Consumer<String> func, LayoutSpec layout)
isSelected(java.lang.String)
); when the
user clicks one, it becomes selected and any other button in the
group is deselected. If FUNC is non-null, FUNC is invoked when
pressed, sending the LABEL as argument.protected void add(Widget widget, LayoutSpec layout)
protected void addLabel(String text, String id, LayoutSpec layout)
protected void setLabel(String id, String text)
protected void addLabel(String text, LayoutSpec layout)
public void showMessage(String text, String title, String type)
public int showOptions(String message, String title, String type, String deflt, String... labels)
public String getTextInput(String message, String title, String type, String init)
public void setPreferredFocus(Widget widget)
public void actionPerformed(ActionEvent e)
actionPerformed
in interface ActionListener