JDK-4689398 : Inserting items in a Container with CardLayout does not work since Merlin
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.4.0
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: linux_redhat_7.2
  • CPU: x86
  • Submitted: 2002-05-22
  • Updated: 2003-08-15
  • Resolved: 2002-09-20
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
1.4.1_05 05Fixed
Related Reports
Relates :  
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);

class Card extends Component
	public Card (int n)
		index = n;

		addMouseListener(new MouseAdapter()
			public void mousePressed(MouseEvent e)
				CardLayout l = (CardLayout)getParent().getLayout();

	public void paint(Graphics g)
		g.drawString(String.valueOf(index), 100, 100);

	private int index;

CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: 1.4.1_05 mantis FIXED IN: 1.4.1_05 mantis INTEGRATED IN: 1.4.1_05 mantis VERIFIED IN: 1.4.1_05

SUGGESTED FIX Name: osR10079 Date: 09/24/2002 See 4546123. ======================================================================

EVALUATION We should investigate this issue for Mantis. ###@###.### 2002-05-28 Name: osR10079 Date: 09/04/2002 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). ###@###.### 2002-09-04 ======================================================================