Now that you’ve seen how to create internal frames and played around with them a bit, let’s tackle a slightly larger problem. We want to build an application that can pop up internal frames that you can honestly use. This starter application is a web-site manager that shows us a list of HTML pages at a site and, for any of those pages, allows us to pop up the page in a separate frame and edit it. We’ll keep the main list of HTML pages in one “site” frame that contains a simple list box.
Once you have a site built up with a couple of pages, you can click
on any entry in the list, and if the file exists, we’ll create
a new “page” frame and load the file into a
JTextArea object for you to edit. You can modify
the text and then save the file using the File menu in the page
As a bonus, we’ll put those cut, copy, and paste icons to use
as well. You can manipulate text in any of the open page frames. The
icons work as
Action objects by looking at the
selected text and insertion point of the active frame. (We’ll
look at the
Action class below.) If the active
frame is a site frame, nothing happens.
You could certainly add a lot of features to this application and make it a real working program, but we don’t want to get mired down in details just yet. (If you want to get really fancy, you could look at some of the editor kits discussed in Chapter 24, and build yourself a real HTML editor.) Figure 2.9 shows the finished application with a couple of frames open. ...