JPanel: getFocusTraversalKeys(int id) : JPanel « javax.swing « Java by API






JPanel: getFocusTraversalKeys(int id)

  

import java.awt.AWTKeyStroke;
import java.awt.KeyboardFocusManager;
import java.util.Set;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.KeyStroke;

public class Main {
  public static void main(String[] args) {
    JFrame aWindow = new JFrame("This is a Border Layout");
    aWindow.setBounds(30, 30, 300, 300);
    aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JPanel p = new JPanel();

    p.add(new JTextField(10));
    p.add(new JTextField(10));
    p.add(new JTextField(10));
    p.add(new JTextField(10));
    p.add(new JTextField(10));
    p.add(new JTextField(10));

    Set<AWTKeyStroke> set = p.getFocusTraversalKeys(KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS);
    //set = new HashSet(set);
    KeyStroke up = KeyStroke.getKeyStroke("A");
    set.add(up);
    System.out.println(set);
    p.setFocusTraversalKeys(KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS, set);
    aWindow.add(p);
    aWindow.setVisible(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: isFocusCycleRoot()
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