Due: 5:00pm, Friday, November 14. Value: 30 pts.
Using Swing, build an application that allows the user to manage a list of tasks to do. The window's appearance should be similar to the picture at right. To get this appearance, you can do the following.
Create a JPanel
with both a text field and
the Add button inside it. Place the JPanel
at the north
edge of the window.
Create a JList
, wrap it in a
JScrollPane
, and place it in the
window's center.
Create a JPanel
with just the Remove buton
inside it. Place this JPanel
at the south edge of
the window.
The program you write should have the following behavior when executed.
The user can enter a string in the text field at top and click the Add button. The string is added to the end of the list, and the text field becomes clear for adding another task.
The user can select an entry in the list of tasks and click Remove. The selected entry should disappear from the list of tasks.
The Remove button should be disabled whenever nothing
is selected within the list. You can accomplish this
by adding a ListSelectionListener
to the
JList
and then using the JButton
class's setEnabled
method.
You'll want to use a JList
, which we didn't see in
class. In general, you should find the Java API documentation
sufficient for learning how to use Swing classes. However, I
have also created a simple program
CSciClasses
that illustrates
the use of a JList
.