java类库详细讲解

源代码在线查看: focus_focustravkey.html

软件大小: 5593 K
上传用户: add505
关键词: java
下载地址: 免注册下载 普通下载 VIP

相关代码

				
				
				
				Setting Focus Traversal Keys for the Entire Application
				(Java Developers Almanac Example)
				
				
				
				
				
				
								    BODY CODE  {font-family: Courier, Monospace;				           font-size: 11pt}				    TABLE, BODY				          {font-family: Verdana, Arial, Helvetica, sans-serif;				           font-size: 10pt}				    PRE   {font-family: Courier, Monospace;				           font-size: 10pt}				    H3    {font-family: Verdana, Arial, Helvetica, sans-serif;				           font-size: 11pt}				    A.eglink {text-decoration: none}				    A:hover.eglink {text-decoration: underline}				    -->
				
				
				
				
				
				The Java Developers Almanac 1.4
				
				        Order this book from Amazon.
				    
				
				
				
				
				
				
				
				
				
				
				
				Home
				    >
				    List of Packages
				    >
				    java.awt
				         [77 examples]
				        
				        >
				        Focus
				             [16 examples]
				            
				
				  
				    e615.  
				    Setting Focus Traversal Keys for the Entire Application
				
				This example changes the focus traversal keys for the entire
				application.  For an example of how to change the focus traversal keys
				for a particular component, see e614 Setting Focus Traversal Keys in a Component.
				
				
				
				    // Change the forward focus traversal keys for the application
				    Set set = new HashSet(
				        KeyboardFocusManager.getCurrentKeyboardFocusManager().getDefaultFocusTraversalKeys(
				            KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS));
				    set.clear();   // Call clear() if you want to eliminate the current key set
				    set.add(KeyStroke.getKeyStroke("F2"));
				    KeyboardFocusManager.getCurrentKeyboardFocusManager().setDefaultFocusTraversalKeys(
				        KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, set);
				    
				    // Change the backward focus traversal keys for the application
				    set = new HashSet(
				        KeyboardFocusManager.getCurrentKeyboardFocusManager().getDefaultFocusTraversalKeys(
				            KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS));
				    set.clear();   // Call clear() if you want to eliminate the current key set
				    set.add(KeyStroke.getKeyStroke("F3"));
				    KeyboardFocusManager.getCurrentKeyboardFocusManager().setDefaultFocusTraversalKeys(
				        KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, set);
				    
				    // Remove all forward and backward focus traversal keys for the application
				    set.clear();
				    KeyboardFocusManager.getCurrentKeyboardFocusManager().setDefaultFocusTraversalKeys(
				        KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, set);
				    KeyboardFocusManager.getCurrentKeyboardFocusManager().setDefaultFocusTraversalKeys(
				        KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, set);
				
				
				
				
				             Related Examples
				        
				
				
				
				
				e610. 
				    Determining Which Component or Window Has the Focus
				
				
				
				e611. 
				    Preventing a Component from Gaining the Focus
				
				
				
				e612. 
				    Preventing a Window from Gaining the Focus
				
				
				
				e613. 
				    Listening to All Focus Changes Between Components in an Application
				
				
				
				e614. 
				    Setting Focus Traversal Keys in a Component
				
				
				
				e616. 
				    Moving the Focus to the Next or Previous Focusable Component
				
				
				
				e617. 
				    Modifying the Focus Traversal Order
				
				
				
				e618. 
				    Setting the Initial Focused Component in a Window
				
				
				
				e619. 
				    Finding the Next Focusable Component
				
				
				
				e620. 
				    Determining If a Focus Lost Is Temporary or Permanent
				
				
				
				e621. 
				    Determining the Opposite Component of a Focus Event
				
				
				
				e622. 
				    Validating a JTextField When Permanently Losing the Focus
				
				
				
				e623. 
				    Removing the Focus from the Application
				
				
				
				e624. 
				    Activating a Keystroke When Any Component in the Window Has Focus
				
				
				
				e625. 
				    Activating a Keystroke When Any Child Component Has Focus
				
				
				
				
				
				
				
				
				        See also: 
				
				    Colors
				  
				
				
				    Components
				  
				
				
				    Containers
				  
				
				
				    Cursors
				  
				
				
				    Drawing
				  
				
				
				    Events
				  
				
				
				    Frames
				  
				
				
				    GridBagLayout
				  
				
				
				    Images
				  
				
				
				    Shapes
				  
				
				
				    Simulating Events
				  
				
				
				    Text
				  
				
				
				    The Screen
				  
				
				
				
				
				
				
				
				
				
				© 2002 Addison-Wesley.
				
				
				
							

相关资源