public void show(Container parent,
                 String name)
Flips to the component that was added to this layout with the specified name, using addLayoutComponent. If no such component exists, then nothing happens.
Parameters:
parent - the name of the parent container in which to do the layout.
name - the component name.
See Also: 

解决方案 »

  1.   

    将component加入到CardLayout时用这个方法的话:
    addLayoutComponent(Component comp, Object constraints),其中,comp就是你想加入某个card的元件,而constraints则必须是一个String,用来确定这个card的名称。那你就可以按楼上所说的方法:
    show(Container parent, String name) 来显示一个命名的card,其中parent就是这个cardlayout所属于的container, 而name就是你当初加入时所用的名字。