EE408 Lab 5: Organization Widgets (Tabbed Panes and Dialogs)
3%
Due: 5
PM, Friday October 17.
The objective of this lab exercise is to learn to use JTabbedPane and JDialog by modifying GUI2.java,
which was given as part of Assignment 2.
Task Description
Add two buttons, "Add Font" and "Remove Font" at the bottom of the GUI2
frame, which, respectively, can be used to add and remove a font to and
from the tabbed pane.
When these buttons are clicked, a modal dialog
should pop up. The popup dialog should have the corresponding title. It
should contain a text field in the middle so that a user can type in a
font name. The dialog should also have two buttons, OK and Cancel, at
bottom. When OK is pressed, the font should be added/removed to and
from the tabbed pane, respectively. Of course, a font should not be
added if it already appears in the tabbed pane.
You may want to consult this
tutorial section about JTabbedPane and this
section about JDialog.
Demonstrate to me once you are done with these exercises so
that I can
grade.
Have a good weekend.
Bonus Task (1%)
Keep the tabs in the tabbed pane sorted in alphabetic order of tab
titles.
Hints. Two strings can be compared by the compareTo()/compareToIgnoreCase()
method in the java.lang.String
class. Tab titles can be accessed by calling getTitleAt() on a tabbed pane, and getTabCount() can be used to obtain
the total number of tabs.