List of usage examples for javax.swing JPanel setFocusTraversalPolicyProvider
public final void setFocusTraversalPolicyProvider(boolean provider)
From source file:FocusCycleSample.java
public static void main(String args[]) { JFrame frame = new JFrame("Focus Cycle Sample"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new GridLayout(3, 3)); for (int i = 0; i < 3; i++) { JButton button = new JButton("" + i); frame.add(button);/* ww w. j av a2 s. co m*/ } JPanel panel = new JPanel(); panel.setFocusCycleRoot(true); panel.setFocusTraversalPolicyProvider(true); panel.setLayout(new GridLayout(1, 3)); for (int i = 0; i < 3; i++) { JButton button = new JButton("" + (i + 3)); panel.add(button); } frame.add(panel); for (int i = 0; i < 3; i++) { JButton button = new JButton("" + (i + 6)); frame.add(button); } frame.setSize(300, 200); frame.setVisible(true); }
From source file:MainClass.java
public static void main(String args[]) { JFrame frame = new JFrame("Focus Cycle Sample"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new GridLayout(3, 3)); for (int i = 0; i < 3; i++) { JButton button = new JButton("" + i); frame.add(button);// w w w. j ava 2 s . c o m } JPanel panel = new JPanel(); panel.setFocusCycleRoot(true); panel.setFocusTraversalPolicyProvider(true); panel.setLayout(new GridLayout(1, 3)); for (int i = 0; i < 3; i++) { JButton button = new JButton("" + (i + 3)); panel.add(button); } frame.add(panel); for (int i = 0; i < 3; i++) { JButton button = new JButton("" + (i + 6)); frame.add(button); } frame.setSize(300, 200); frame.setVisible(true); }