> I am working on a small in-house application.  In this
> program, I'd like to be able to have multiple images open at
> the same time and keep track of each image in the background.
> Whenever an image is clicked, it becomes the active one and
> whenever an image is closed, its entry is removed from the
> image list. A user should be able to retrieve the list of opened
> images at anytime.
>
> I wonder if Java2D provides any class that can do similar
> job so that I don't have to reinvent the wheel.  I'd also love
> to hear your ideas on how to implement such functionality.

Hmm, I could image something like a JList that holds internally JLabels that
are pointing to the images.
You would need only a list selection listener to do the additional stuff.

Note that adding new elements to a JList can become quite slow (due to the
refreshing of the screen), so the startup should do the following:
    create as many JLabels as possible, add them into the JList in one rush,
do the repaint

Then adding one image only one by one should not affect the performance too
much.

The following code should do the trick (some short pieces are missing):
JLabel[] labels = new JLabel[max_size];    // can be dynamically expanded if
required
for (int i=....) {
    labels[i] = new JLabel(new ImageIcon("iconname....");
}
JList list = new JList(labels);

voila, now you need the listSelectionListener and your done.


Karsten

--
Karsten Trott
Technical Lead, Intuitive Design Interface , Get2Chip.com, Inc.
Staff R&D Engineer
Phone: +49-89-5908-2333
Fax:   +49-89-5908-1328

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to