Results 1 to 5 of 5

Thread: KeyboardFocusManager class of java

  1. #1
    Join Date
    Jan 2010
    Posts
    99

    KeyboardFocusManager class of java

    Hello friend,

    I just started to learn the advanced java class concepts. In which the KeyboardFocusManager class sounds very complicated to use. I am unable to get the use of 'KeyboardFocusManager class' of advanced java programming. I wonder if you provide something about the KeyboardFocusManager class along with proper example. I would greatly appreciate your any help over this java class.

  2. #2
    Join Date
    Jan 2008
    Posts
    1,521

    Re: KeyboardFocusManager class of java

    The KeyboardFocusManager is both a centralized location for client code to query for the focus owner and initiate focus changes, and an event dispatcher for all FocusEvents, WindowEvents related to focus, and KeyEvents. Some browsers partition applets in different code bases into separate contexts, and establish walls between these contexts. In such a scenario, there will be one KeyboardFocusManager per context.

  3. #3
    Join Date
    Feb 2008
    Posts
    1,852

    Re: KeyboardFocusManager class of java

    Hi,

    I suggest you to refer following example of KeyboardFocusManager class of java:
    Code:
    import java.awt.KeyboardFocusManager;
    import javax.swing.KeyStroke;
    
    poublic class KeyboardFocusManagerDM {
      public static void main(String[] ardfgs) {
        JFrame aWindow = new JFrame("This is a Border Layout");
        aWindow.setBounds(40, 40, 300, 300);
        aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    
        JPanel pov = new JPanel();
    
        pov.add(new JTextField(10));
        pov.add(new JTextField(10));
        pov.add(new JTextField(10));
        pov.add(new JTextField(10));
        pov.add(new JTextField(10));
        pov.add(new JTextField(10));
        Set<AWTKeyStroke> set = pov.getFocusTraversalKeys(KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS);
        set = new HashSet(set);
        KeyStroke upov = KeyStroke.getKeyStroke("A");
        set.add(upov);
        System.out.povrintln(set);
       pov.setFocusTraversalKeys(KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS, set);
    
        aWindow.add(pov);
    
        aWindow.setVisible(true);
      }
    }

  4. #4
    Join Date
    Jan 2008
    Posts
    1,521

    Re: KeyboardFocusManager class of java

    Hello friend,

    Please review below given some methods of KeyboardFocusManager class:
    • setGlobalCurrentFocusCycleRoot(Container newFocusCycleRT)
    • upFocusCycle(Component Comp)
    • setGlobalPermanentFocusOwner(Component comp)
    • setGlobalActiveWindow(Window actWindow)
    • redispatchEvent(Component comp, AWTEvent evnt)

  5. #5
    Join Date
    May 2008
    Posts
    2,297

    Re: KeyboardFocusManager class of java

    Following example will demonstrate you the use of KeyboardFocusManager class:
    Code:
    import java.awt.KeyboardFocusManager;
    import javax.swing.JFrame;
    import javax.swing.JTextField;
    
    public class UsingFocuDemo
     {
      public static void main(String[] anl) {
        JFrame frame006 = new JFrame();
        frame006.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        JTextField textField1 = new JTextField("A TextField");
        KeyboardFocusManager focusManager1 =     KeyboardFocusManager.getCurrentKeyboardFocusManager();
        focusManager.addPropertyChangeListener(new PropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent e) {
            String prop1 = e.getPropertyName();
            System.out.println(prop1);
    
          }   }
    
        frame006.add(textField1, "North");
        frame006.add(new JTextField(), "South");
        frame006.setSize(400, 200);
        frame006.setVisible(true);
      }
    
    }

Similar Threads

  1. Converting java class to java bean class
    By Ucchal in forum Software Development
    Replies: 6
    Last Post: 09-08-2010, 10:24 AM
  2. JCheckBoxMenuItem class of java
    By Ram Bharose in forum Software Development
    Replies: 5
    Last Post: 18-02-2010, 12:11 PM
  3. JDesktopPane class of java
    By Sonam Goenka in forum Software Development
    Replies: 5
    Last Post: 18-02-2010, 08:14 AM
  4. What is TransferSupport Class in Java?
    By DANIEL 602 in forum Software Development
    Replies: 4
    Last Post: 13-02-2010, 06:54 AM
  5. Java Programming Language Basics: Reflection Basics and Class Class
    By mayuri_gunjan in forum Guides & Tutorials
    Replies: 6
    Last Post: 29-08-2005, 12:04 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,581,167.54257 seconds with 17 queries