jdk/src/share/classes/javax/swing/LayoutFocusTraversalPolicy.java
changeset 25568 b906a74c6882
parent 23697 e556a715949f
equal deleted inserted replaced
25567:93f3ca259c48 25568:b906a74c6882
    96     public Component getComponentAfter(Container aContainer,
    96     public Component getComponentAfter(Container aContainer,
    97                                        Component aComponent) {
    97                                        Component aComponent) {
    98         if (aContainer == null || aComponent == null) {
    98         if (aContainer == null || aComponent == null) {
    99             throw new IllegalArgumentException("aContainer and aComponent cannot be null");
    99             throw new IllegalArgumentException("aContainer and aComponent cannot be null");
   100         }
   100         }
   101         Comparator comparator = getComparator();
   101         Comparator<? super Component> comparator = getComparator();
   102         if (comparator instanceof LayoutComparator) {
   102         if (comparator instanceof LayoutComparator) {
   103             ((LayoutComparator)comparator).
   103             ((LayoutComparator)comparator).
   104                 setComponentOrientation(aContainer.
   104                 setComponentOrientation(aContainer.
   105                                         getComponentOrientation());
   105                                         getComponentOrientation());
   106         }
   106         }
   132     public Component getComponentBefore(Container aContainer,
   132     public Component getComponentBefore(Container aContainer,
   133                                         Component aComponent) {
   133                                         Component aComponent) {
   134         if (aContainer == null || aComponent == null) {
   134         if (aContainer == null || aComponent == null) {
   135             throw new IllegalArgumentException("aContainer and aComponent cannot be null");
   135             throw new IllegalArgumentException("aContainer and aComponent cannot be null");
   136         }
   136         }
   137         Comparator comparator = getComparator();
   137         Comparator<? super Component> comparator = getComparator();
   138         if (comparator instanceof LayoutComparator) {
   138         if (comparator instanceof LayoutComparator) {
   139             ((LayoutComparator)comparator).
   139             ((LayoutComparator)comparator).
   140                 setComponentOrientation(aContainer.
   140                 setComponentOrientation(aContainer.
   141                                         getComponentOrientation());
   141                                         getComponentOrientation());
   142         }
   142         }
   156      */
   156      */
   157     public Component getFirstComponent(Container aContainer) {
   157     public Component getFirstComponent(Container aContainer) {
   158         if (aContainer == null) {
   158         if (aContainer == null) {
   159             throw new IllegalArgumentException("aContainer cannot be null");
   159             throw new IllegalArgumentException("aContainer cannot be null");
   160         }
   160         }
   161         Comparator comparator = getComparator();
   161         Comparator<? super Component> comparator = getComparator();
   162         if (comparator instanceof LayoutComparator) {
   162         if (comparator instanceof LayoutComparator) {
   163             ((LayoutComparator)comparator).
   163             ((LayoutComparator)comparator).
   164                 setComponentOrientation(aContainer.
   164                 setComponentOrientation(aContainer.
   165                                         getComponentOrientation());
   165                                         getComponentOrientation());
   166         }
   166         }
   180      */
   180      */
   181     public Component getLastComponent(Container aContainer) {
   181     public Component getLastComponent(Container aContainer) {
   182         if (aContainer == null) {
   182         if (aContainer == null) {
   183             throw new IllegalArgumentException("aContainer cannot be null");
   183             throw new IllegalArgumentException("aContainer cannot be null");
   184         }
   184         }
   185         Comparator comparator = getComparator();
   185         Comparator<? super Component> comparator = getComparator();
   186         if (comparator instanceof LayoutComparator) {
   186         if (comparator instanceof LayoutComparator) {
   187             ((LayoutComparator)comparator).
   187             ((LayoutComparator)comparator).
   188                 setComponentOrientation(aContainer.
   188                 setComponentOrientation(aContainer.
   189                                         getComponentOrientation());
   189                                         getComponentOrientation());
   190         }
   190         }
   231         } else if (SunToolkit.isInstanceOf(aComponent, "javax.swing.JTable")) {
   231         } else if (SunToolkit.isInstanceOf(aComponent, "javax.swing.JTable")) {
   232             // JTable only has ancestor focus bindings, we thus force it
   232             // JTable only has ancestor focus bindings, we thus force it
   233             // to be focusable by returning true here.
   233             // to be focusable by returning true here.
   234             return true;
   234             return true;
   235         } else if (SunToolkit.isInstanceOf(aComponent, "javax.swing.JComboBox")) {
   235         } else if (SunToolkit.isInstanceOf(aComponent, "javax.swing.JComboBox")) {
   236             JComboBox box = (JComboBox)aComponent;
   236             JComboBox<?> box = (JComboBox)aComponent;
   237             return box.getUI().isFocusTraversable(box);
   237             return box.getUI().isFocusTraversable(box);
   238         } else if (aComponent instanceof JComponent) {
   238         } else if (aComponent instanceof JComponent) {
   239             JComponent jComponent = (JComponent)aComponent;
   239             JComponent jComponent = (JComponent)aComponent;
   240             InputMap inputMap = jComponent.getInputMap(JComponent.WHEN_FOCUSED,
   240             InputMap inputMap = jComponent.getInputMap(JComponent.WHEN_FOCUSED,
   241                                                        false);
   241                                                        false);
   254 
   254 
   255     private void writeObject(ObjectOutputStream out) throws IOException {
   255     private void writeObject(ObjectOutputStream out) throws IOException {
   256         out.writeObject(getComparator());
   256         out.writeObject(getComparator());
   257         out.writeBoolean(getImplicitDownCycleTraversal());
   257         out.writeBoolean(getImplicitDownCycleTraversal());
   258     }
   258     }
       
   259     @SuppressWarnings("unchecked") // Cast to (Comparator<? super Component>)
   259     private void readObject(ObjectInputStream in)
   260     private void readObject(ObjectInputStream in)
   260         throws IOException, ClassNotFoundException
   261         throws IOException, ClassNotFoundException
   261     {
   262     {
   262         setComparator((Comparator)in.readObject());
   263         setComparator((Comparator<? super Component>)in.readObject());
   263         setImplicitDownCycleTraversal(in.readBoolean());
   264         setImplicitDownCycleTraversal(in.readBoolean());
   264     }
   265     }
   265 }
   266 }
   266 
   267 
   267 // Create our own subclass and change accept to public so that we can call
   268 // Create our own subclass and change accept to public so that we can call