Example usage for javax.swing JPanel setFocusTraversalPolicyProvider

List of usage examples for javax.swing JPanel setFocusTraversalPolicyProvider

Introduction

In this page you can find the example usage for javax.swing JPanel setFocusTraversalPolicyProvider.

Prototype

public final void setFocusTraversalPolicyProvider(boolean provider) 

Source Link

Document

Sets whether this container will be used to provide focus traversal policy.

Usage

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);
}