Restricting the Focus Cycle : Focus « Swing Event « Java Tutorial

Java Tutorial
1. Language
2. Data Type
3. Operators
4. Statement Control
5. Class Definition
6. Development
7. Reflection
8. Regular Expressions
9. Collections
10. Thread
11. File
12. Generics
13. I18N
14. Swing
15. Swing Event
16. 2D Graphics
17. SWT
18. SWT 2D Graphics
19. Network
20. Database
21. Hibernate
22. JPA
23. JSP
24. JSTL
25. Servlet
26. Web Services SOA
27. EJB3
28. Spring
29. PDF
30. Email
31. J2ME
32. J2EE Application
33. XML
34. Design Pattern
35. Log
36. Security
37. Apache Common
38. Ant
39. JUnit
Java
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Tutorial » Swing Event » Focus 
15. 15. 5. Restricting the Focus Cycle
Restricting the Focus Cycle
import java.awt.GridLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class FocusCycleSample {
  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);
    }
    JPanel panel = new JPanel();
    panel.setFocusCycleRoot(true);
    panel.setFocusTraversalPolicyProvider(true);
    panel.setLayout(new GridLayout(13));
    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(300200);
    frame.setVisible(true);
  }
}
15. 15. Focus
15. 15. 1. No Focus Button
15. 15. 2. Focus auto-settingFocus auto-setting
15. 15. 3. Focus Traversal: requestFocusInWindowFocus Traversal: requestFocusInWindow
15. 15. 4. Moving focus to the next component: focusNextComponent()Moving focus to the next component: focusNextComponent()
15. 15. 5. Restricting the Focus CycleRestricting the Focus Cycle
15. 15. 6. Request Focus inside a windowRequest Focus inside a window
15. 15. 7. Predefined Focus Traversal Policies
15. 15. 8. Reversing Focus TraversalReversing Focus Traversal
15. 15. 9. KeyboardFocusManagerKeyboardFocusManager
15. 15. 10. Use KeyboardFocusManagerUse KeyboardFocusManager
15. 15. 11. Use FocusTraversalPolicy
15. 15. 12. Finding the Next Focusable Component
15. 15. 13. Find the previous focusable component
15. 15. 14. Determining If a Focus Lost Is Temporary or Permanent
15. 15. 15. Null is returned if none of the components in this application has the focus
15. 15. 16. Null is returned if none of the windows in this application has the focus
15. 15. 17. Changes the focus traversal keys for the entire application.
15. 15. 18. Change the backward focus traversal keys for the application
15. 15. 19. Change the forward focus traversal keys for a component
15. 15. 20. JComponent.setFocusTraversalKeys(int arg0, Set arg1)
15. 15. 21. KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS
15. 15. 22. Setting Focus Traversal Keys for the Entire Application
15. 15. 23. KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS
15. 15. 24. KeyboardFocusManager.getCurrentKeyboardFocusManager().getDefaultFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS)
15. 15. 25. KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner()
15. 15. 26. Determining the Opposite Component of a Focus Event
15. 15. 27. Listening to All Key Events Before Delivery to Focused Component
15. 15. 28. Removing the Focus from the Application
15. 15. 29. Use isFocusOwner to determine whether a particular component has the focus
15. 15. 30. JComponent.WHEN_IN_FOCUSED_WINDOW
15. 15. 31. Make sure that my Text field has the focus when a JFrame is created
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.