JPanel: isFocusCycleRoot() : JPanel « javax.swing « Java by API






JPanel: isFocusCycleRoot()

  

import java.awt.Container;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class Main {
  public static void main(String args[]) {
    JFrame frame = new JFrame("Focus Cycle Sample");

    Container contentPane = frame.getContentPane();
    contentPane.setLayout(new GridLayout(3,3));
    for (int i = 0; i < 8; i++) {
      JButton button = new JButton("" + i);
      contentPane.add(button);
    }

    JPanel panel = new FocusCycleConstrainedJPanel();
    panel.setLayout(new GridLayout(1, 3));
    for (int i = 0; i < 3; i++) {
      JButton button = new JButton("" + (i + 3));
      panel.add(button);
    }
    contentPane.add(panel);

    frame.setSize(300, 200);
    frame.setVisible(true);
  }
}

class FocusCycleConstrainedJPanel extends JPanel {
  public boolean isFocusCycleRoot() {
    return true;
  }
}

   
    
  








Related examples in the same category

1.JPanel: addAncestorListener(AncestorListener lis)
2.JPanel: addContainerListener(ContainerListener l)
3.JPanel: addMouseListener(MouseListener mous)
4.JPanel: addMouseMotionListener(MouseMotionListener lis)
5.JPanel: addKeyListener(KeyListener l)
6.JPanel: getFocusTraversalKeys(int id)
7.JPanel: paintComponent(Graphics g)
8.JPanel: repaint()
9.JPanel: setBackground(Color c)
10.JPanel: setBorder(Border border)
11.JPanel: setComponentPopupMenu(JPopupMenu popup)
12.JPanel: setFocusCycleRoot(boolean value)
13.JPanel: setFocusTraversalPolicyProvider(boolean value)
14.JPanel: setLayout(null)
15.JPanel: setOpaque(boolean isOpaque)
16.JPanel: setPreferredSize(Dimension preferredSize)
17.JPanel: setToolTipText(String htmlString)
18.extends JPanel