Package java.awt

Examples of java.awt.FocusTraversalPolicy


                  // we have an issue with performance. This is an unlikely case, so we'll avoid this processing in this case
                  if (!(component instanceof CompoundGraphic && ((JComponent)component).getComponentCount() > 10)) {
                      Container root = component.getFocusCycleRootAncestor();
 
                      if (root != null) {
                          FocusTraversalPolicy policy = root.getFocusTraversalPolicy();
                          Component previousFocus = policy.getComponentBefore(root, component);
                          Component nextFocus = policy.getComponentAfter(root, previousFocus == null ? component : previousFocus);
                          if (nextFocus != null) {
                              nextFocus.requestFocusInWindow();
                          }
                      }
                  }
View Full Code Here


        {
            comp = rootAncestor;
            rootAncestor = comp.getFocusCycleRootAncestor();
        }
        if (rootAncestor != null) {
            FocusTraversalPolicy policy =
                rootAncestor.getFocusTraversalPolicy();
            Component toFocus = policy.getComponentAfter(rootAncestor, comp);
            final Component startingPoint = currentFocusOwner;
           
            while(toFocus!=null && set.contains(toFocus)==false) {
              set.add(toFocus);
                toFocus = policy.getComponentAfter(rootAncestor, toFocus);
            }
           
            toFocus = policy.getComponentBefore(rootAncestor, comp);
           
            while(toFocus!=null && set.contains(toFocus)==false) {
              set.add(toFocus);
                toFocus = policy.getComponentBefore(rootAncestor, toFocus);
            }
        }
    return set;
  }
View Full Code Here

                        // CraigM:15/10/2008 - If we are a grid field in an array field
                        if (focusedComponent.getParent() instanceof GridField && ArrayFieldCellHelper.getArrayField(focusedComponent.getParent()) != null) {

                          // We should have a FocusTraversalPolicy somewhere on a gridfield (setup in GridFieldCellEditor)
                          FocusTraversalPolicy traversal = null;
                          Component componentWithTraveralPolicy = focusedComponent;
                          while (componentWithTraveralPolicy != null && traversal == null) {
                            componentWithTraveralPolicy = componentWithTraveralPolicy.getParent();
                            if (componentWithTraveralPolicy instanceof Container) {
                              traversal = ((Container)componentWithTraveralPolicy).getFocusTraversalPolicy();
                            }
                          }

                          // If this is null, it means we didn't find the FocusTraversalPolicy manager.
                          if (traversal != null && componentWithTraveralPolicy instanceof Container) {
                            if (!e.isShiftDown()) {
                              Component comp = traversal.getComponentAfter((Container)componentWithTraveralPolicy, focusedComponent);
 
                              // If we can transfer the focus inside the GridField, do it
                              if (comp != null && comp != traversal.getFirstComponent((Container)componentWithTraveralPolicy)) {
                                comp.requestFocus();
                                e.consume();
                              }
                            }
                            else {
                              Component comp = traversal.getComponentBefore((Container)componentWithTraveralPolicy, focusedComponent);
                             
                              // If we can transfer the focus inside the GridField, do it
                              if (comp != null && comp != traversal.getLastComponent((Container)componentWithTraveralPolicy)) {
                                comp.requestFocus();
                                e.consume();
                              }
                            }
                          }
View Full Code Here

                        // CraigM:15/10/2008 - If we are a grid field in an array field
                        if (focusedComponent.getParent() instanceof GridField && ArrayFieldCellHelper.getArrayField(focusedComponent.getParent()) != null) {

                          // We should have a FocusTraversalPolicy somewhere on a gridfield (setup in GridFieldCellEditor)
                          FocusTraversalPolicy traversal = null;
                          Component componentWithTraveralPolicy = focusedComponent;
                          while (componentWithTraveralPolicy != null && traversal == null) {
                            componentWithTraveralPolicy = componentWithTraveralPolicy.getParent();
                            if (componentWithTraveralPolicy instanceof Container) {
                              traversal = ((Container)componentWithTraveralPolicy).getFocusTraversalPolicy();
                            }
                          }

                          // If this is null, it means we didn't find the FocusTraversalPolicy manager.
                          if (traversal != null && componentWithTraveralPolicy instanceof Container) {
                            if (!e.isShiftDown()) {
                              Component comp = traversal.getComponentAfter((Container)componentWithTraveralPolicy, focusedComponent);
 
                              // If we can transfer the focus inside the GridField, do it
                              if (comp != null && comp != traversal.getFirstComponent((Container)componentWithTraveralPolicy)) {
                                comp.requestFocus();
                                e.consume();
                              }
                            }
                            else {
                              Component comp = traversal.getComponentBefore((Container)componentWithTraveralPolicy, focusedComponent);
                             
                              // If we can transfer the focus inside the GridField, do it
                              if (comp != null && comp != traversal.getLastComponent((Container)componentWithTraveralPolicy)) {
                                comp.requestFocus();
                                e.consume();
                              }
                            }
                          }
View Full Code Here

                  // we have an issue with performance. This is an unlikely case, so we'll avoid this processing in this case
                  if (!(component instanceof CompoundGraphic && ((JComponent)component).getComponentCount() > 10)) {
                      Container root = component.getFocusCycleRootAncestor();
 
                      if (root != null) {
                          FocusTraversalPolicy policy = root.getFocusTraversalPolicy();
                          Component previousFocus = policy.getComponentBefore(root, component);
                          Component nextFocus = policy.getComponentAfter(root, previousFocus == null ? component : previousFocus);
                          if (nextFocus != null) {
                              nextFocus.requestFocusInWindow();
                          }
                      }
                  }
View Full Code Here

          else if (root instanceof JWindow) {
            root = ((JWindow)root).getContentPane();
          }
        }
        if (root != null) {
          FocusTraversalPolicy policy = root.getFocusTraversalPolicy();
         
          // CraigM:01/09/2008 - Switch off the special ArrayField focus handling as it causes an endless loop
          if (policy instanceof ForteLayoutFocusTraversalPolicy) {
            ((ForteLayoutFocusTraversalPolicy)policy).setSwingDisplayerIgnoreArrayField(true);
          }
         
          // DK:30/09/2008:With some of the forms lastComponent is null and component after the last one
          //is the first one and we do not need to continue to avoid endless loop.
          Component firstComponent = policy.getFirstComponent(container);
          Component lastComponent = policy.getLastComponent(container);
        Component child = firstComponent;
          while (child != null) {
            // TF:28/10/2008:There are some situation where getComponentAfter returns the same component, so prevent infinite looping
            if (result.contains(child)) {
              break;
            }
            result.add(child);
          if (child == lastComponent) {
              break;
            }
            child = policy.getComponentAfter(root, child);

            if (child == firstComponent) {
              break;
            }
          }
View Full Code Here

                  // we have an issue with performance. This is an unlikely case, so we'll avoid this processing in this case
                  if (!(component instanceof CompoundGraphic && ((JComponent)component).getComponentCount() > 10)) {
                      Container root = component.getFocusCycleRootAncestor();
 
                      if (root != null) {
                          FocusTraversalPolicy policy = root.getFocusTraversalPolicy();
                          Component previousFocus = policy.getComponentBefore(root, component);
                          Component nextFocus = policy.getComponentAfter(root, previousFocus == null ? component : previousFocus);
                          if (nextFocus != null) {
                              nextFocus.requestFocusInWindow();
                          }
                      }
                  }
View Full Code Here

  public boolean requestFocusInWindow() {
    // If we are in an ArrayField
    if (ArrayFieldCellHelper.getArrayField(this) != null) {

      // We should have a FocusTraversalPolicy (setup in GridFieldCellEditor)
          FocusTraversalPolicy traversal = this.getFocusTraversalPolicy();

      if (ForteKeyboardFocusManager.getTraversalReason() == Constants.FC_KEYPREV) {
        return traversal.getLastComponent(this).requestFocusInWindow();
      }
      else {
        return traversal.getFirstComponent(this).requestFocusInWindow();
      }
    }
    else {
      return super.requestFocusInWindow();
    }
View Full Code Here

        final JComponent panel1 = new JPanel();
        final JComponent panel2 = new JPanel();
        final JComponent panel3 = new JPanel();
        final JComponent panel4 = new JPanel(); // this component is to be returned
                                                // by our FocusTraversalPolicy()
        FocusTraversalPolicy policy = new FocusTraversalPolicy() {
            @Override
            public Component getComponentAfter(final Container a0, final Component a1) {
                return null;
            }
View Full Code Here

            if (log.isLoggable(PlatformLogger.FINE)) {
                log.fine("### Asking FTP " + provider + " for component after " + aComponent);
            }

            // FTP knows how to find component after the given. We don't.
            FocusTraversalPolicy policy = provider.getFocusTraversalPolicy();
            Component afterComp = policy.getComponentAfter(provider, aComponent);

            // Null result means that we overstepped the limit of the FTP's cycle.
            // In that case we must quit the cycle, otherwise return the component found.
            if (afterComp != null) {
                if (log.isLoggable(PlatformLogger.FINE)) log.fine("### FTP returned " + afterComp);
View Full Code Here

TOP

Related Classes of java.awt.FocusTraversalPolicy

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.