-
Bug
-
Resolution: Unresolved
-
P4
-
None
-
1.2.0
-
generic
-
generic
Name: dbT83986 Date: 04/23/99
/*
Can not use requestDefaultFocus with CardLayout JPanel to set a focus. And if I call pn2.requestDefaultFocus() to replace the last line, it will be ok.Or when I show the "hhn1" panel(replace clMain.show(pn, "hhn2"); with clMain.show(pn, "hhn1")); it will be also ok.
*/
import javax.swing.*;
import java.awt.*;
public class JTest extends JApplet
{
JPanel pn, pn1, pn2;
JTextField jtfOne, jtfTwo;
public void init()
{
CardLayout clMain = new CardLayout();
pn = new JPanel();
getContentPane().add(pn);
pn.setLayout(clMain);
setSize(426,266);
pn1 = new JPanel();
pn2 = new JPanel();
jtfOne = new JTextField();
jtfOne.setColumns(10);
pn1.add(jtfOne);
jtfTwo = new JTextField();
jtfTwo.setColumns(20);
pn2.add(jtfTwo);
pn.add(pn1, "hhn1");
pn.add(pn2, "hhn2");
clMain.show(pn, "hhn2");
pn.requestDefaultFocus();
}
}
(Review ID: 56999)
======================================================================