|
Quick Lists
|
|
Bug ID:
|
4689398
|
|
Votes
|
8
|
|
Synopsis
|
Inserting items in a Container with CardLayout does not work since Merlin
|
|
Category
|
java:classes_awt
|
|
Reported Against
|
1.4
|
|
Release Fixed
|
1.4.1_05
|
|
State
|
10-Fix Delivered,
Verified,
bug
|
|
Priority:
|
3-Medium
|
|
Related Bugs
|
4546123
|
|
Submit Date
|
22-MAY-2002
|
|
Description
|
The CardLayout class in Merlin has been rewritten and is now incompatiable with all previous versions of CardLayout. Instead of using a Hashtable to map the names of the components a Vector of private class Card is used. The CardLayout assumes that the Cards in this Vector are added in the same order as the components in the Container being layed out. This is an incorrect assumption because components can be inserted into a Container and do not always have to be added at the end of the list of components. The following example demonstrates this by inserting components into a Frame with CardLayout. The Components are added in reverse order. When you click on the card it will advance to the next card. On all previous versions of Java next advanced to the next card in the Frame's child list. In Merlin it now advvances to the next Card based on the order they were added. To reproduce, run this program under versions before Merlin and notice the ordering when you click on the Frame and then do the same under Merlin:
import java.awt.*;
import java.awt.event.*;
public class CardLayoutOrdering
{
public static void main (String args[])
{
Frame f = new Frame();
f.setLayout(new CardLayout());
for (int i = 1; i <= 10; i++)
{
f.add(new Card(i), String.valueOf(i), 0);
}
f.setSize(500,500);
f.setVisible(true);
}
}
class Card extends Component
{
public Card (int n)
{
index = n;
addMouseListener(new MouseAdapter()
{
public void mousePressed(MouseEvent e)
{
CardLayout l = (CardLayout)getParent().getLayout();
l.next(getParent());
}
});
}
public void paint(Graphics g)
{
g.drawString(String.valueOf(index), 100, 100);
}
private int index;
}
|
|
Work Around
|
N/A
|
|
Evaluation
|
We should investigate this issue for Mantis.
xxxxx@xxxxx 2002-05-28
This is regression from fix for 4362381 (Once the remove button had press, next
item from the list should show.) In this fix i've tried to accumulate in
CardLayout all information for its functionality including order of cards.
Unfortunately, our usage of CardLayout doesn't provide this information when
user adds card by Container.add(Component, Object, int). Thus to fix this
problem we have to refix original bug (4362381).
xxxxx@xxxxx 2002-09-04
======================================================================
|
|
Comments
|
Submitted On 03-JUL-2002
gzsombi
workaround: get the CardLayout.class from the old, good
jdk1.3, and put it into the rt.jar ... :-)
it's an ugly hack, but it works ...
(like
http://developer.java.sun.com/developer/bugParade/bugs/45461
23.html )
PLEASE NOTE: JDK6 is formerly known as Project Mustang
|
|
|
 |