Esempio n. 1
0
    public void keyPressed(KeyEvent evt) {
      int keyKode = evt.getKeyCode();
      if (evt.getSource().equals(btnAdd)) {
        return;
      }
      switch (keyKode) {
        case KeyEvent.VK_ENTER:
          {
            if (!lst.isVisible()) {
              Component c = findNextFocus();
              if (c != null) {
                c.requestFocus();
              }
            } else {
              lst.requestFocus();
            }
            break;
          }
        case KeyEvent.VK_UP:
          {
            if (!lst.isVisible()) {
              Component c = findPrevFocus();
              if (c != null) {
                c.requestFocus();
              }
            } else {
              lst.requestFocus();
            }
            break;
          }
        case KeyEvent.VK_DOWN:
          {
            if (!lst.isVisible()) {
              Component c = findNextFocus();
              if (c != null) {
                c.requestFocus();
              }
            } else {
              lst.requestFocus();
            }
            break;
          }

        case KeyEvent.VK_F3:
          { // Search
            //   udfFilter();

            break;
          }

        case KeyEvent.VK_ESCAPE:
          {
            // dispose();
            break;
          }
          // default ;

      }
    }
    public void actionPerformed(ActionEvent e) {
      int selIndexBefore = getSelectedIndex();
      myDefaultAction.actionPerformed(e);
      int selIndexCurrent = getSelectedIndex();
      if (selIndexBefore != selIndexCurrent) {
        return;
      }
      if (myFocusNext && selIndexCurrent == 0) {
        return;
      }

      KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
      Container container = kfm.getCurrentFocusCycleRoot();
      FocusTraversalPolicy policy = container.getFocusTraversalPolicy();
      if (policy == null) {
        policy = kfm.getDefaultFocusTraversalPolicy();
      }
      Component next =
          myFocusNext
              ? policy.getComponentAfter(container, PaletteItemsComponent.this)
              : policy.getComponentBefore(container, PaletteItemsComponent.this);
      if (next instanceof PaletteGroupComponent) {
        clearSelection();
        next.requestFocus();
        ((PaletteGroupComponent) next).scrollRectToVisible(next.getBounds());
      }
    }
Esempio n. 3
0
 public void actionPerformed(ActionEvent e) {
   KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
   Container container = kfm.getCurrentFocusCycleRoot();
   FocusTraversalPolicy policy = container.getFocusTraversalPolicy();
   if (null == policy) policy = kfm.getDefaultFocusTraversalPolicy();
   Component next =
       moveDown
           ? policy.getComponentAfter(container, PaletteGroupHeader.this)
           : policy.getComponentBefore(container, PaletteGroupHeader.this);
   if (null != next && next instanceof PaletteComponentList) {
     final PaletteComponentList list = (PaletteComponentList) next;
     if (list.getModel().getSize() != 0) {
       list.takeFocusFrom(PaletteGroupHeader.this, list == myComponentList ? 0 : -1);
       return;
     } else {
       next =
           moveDown
               ? policy.getComponentAfter(container, next)
               : policy.getComponentBefore(container, next);
     }
   }
   if (null != next && next instanceof PaletteGroupHeader) {
     next.requestFocus();
   }
 }
Esempio n. 4
0
  /**
   * Uninstalls the sheet on the owner. This method is invoked immediately after the JSheet is
   * hidden.
   */
  protected void uninstallSheet() {
    if (isInstalled) {
      Window owner = getOwner();
      if (owner != null) {
        if (isExperimentalSheet()) {
          owner.removeWindowListener(windowEventHandler);
        } else {
          // Note: We mustn't change the windows focusable state
          // because
          // this also affects the focusable state of the JSheet.
          // owner.setFocusableWindowState(true);
          owner.setEnabled(true);
          // ((JFrame) owner).setResizable(true);
          owner.removeComponentListener(ownerMovementHandler);

          if (shiftBackLocation != null) {
            owner.setLocation(shiftBackLocation);
          }
          if (oldFocusOwner != null) {
            owner.toFront();
            oldFocusOwner.requestFocus();
          }
        }
      }
      isInstalled = false;
    }
  }
Esempio n. 5
0
  // switches to a new screen, discarding the old one
  public void switchScreen(Component s) {
    if (s == null) {
      return;
    }
    if (mainComponent == s) {
      // alreay on correct component!
      s.repaint();
      return;
    }

    setVisible(false);
    removeAll();
    add(s);
    if (s instanceof GameScreen) {
      ((GameScreen) s)
          .getMappanel()
          .setPosition(Game.hero().getMap(), Game.hero().x, Game.hero().y);
    }
    invalidate();
    validate();

    setVisible(true);
    /*
     * CBG This is needed to give the focus to the contained screen.
     * RequestFocusInWindow is preferable to requestFocus.
     */

    s.requestFocus();
    mainComponent = s;
  }
 protected void focusNext(JComponent comp) {
   FocusTraversalPolicy policy = FlatWelcomeFrame.this.getFocusTraversalPolicy();
   if (policy != null) {
     Component next = policy.getComponentAfter(FlatWelcomeFrame.this, comp);
     if (next != null) {
       next.requestFocus();
     }
   }
 }
 protected void focusPrev(JComponent comp) {
   FocusTraversalPolicy policy = FlatWelcomeFrame.this.getFocusTraversalPolicy();
   if (policy != null) {
     Component prev = policy.getComponentBefore(FlatWelcomeFrame.this, comp);
     if (prev != null) {
       prev.requestFocus();
     }
   }
 }
 protected void paintEditor(Graphics g) {
   Component component = grid.getEditorComponent();
   if (component == null) {
     return;
   }
   Rectangle cellBounds = grid.getCellBounds(grid.getEditingRow(), grid.getEditingColumn());
   component.setBounds(cellBounds);
   component.validate();
   component.requestFocus();
 }
Esempio n. 9
0
 private void doSwap(int x, int y, int x1, int y1) {
   Component temp1, temp2;
   temp1 = panelArray[x][y].getComponent(0);
   temp2 = panelArray[x1][y1].getComponent(0);
   panelArray[x][y].remove(0);
   panelArray[x1][y1].remove(0);
   panelArray[x1][y1].add(temp1);
   panelArray[x][y].add(temp2);
   temp2.requestFocus();
   this.repaint();
 }
 // REMIND(aim,7/29/98): This method should be made
 // protected in the next release where
 // API changes are allowed
 //
 boolean requestMyFocusForVisibleComponent() {
   Component visibleComponent = getVisibleComponent();
   if (visibleComponent.isFocusTraversable()) {
     visibleComponent.requestFocus();
     return true;
   } else if (visibleComponent instanceof JComponent) {
     if (((JComponent) visibleComponent).requestDefaultFocus()) {
       return true;
     }
   }
   return false;
 }
Esempio n. 11
0
  /**
   * If inputComponent is non-null, the focus is requested on that, otherwise request focus on the
   * default value
   */
  public void selectInitialValue(JOptionPane op) {
    if (inputComponent != null) inputComponent.requestFocus();
    else {
      if (initialFocusComponent != null) initialFocusComponent.requestFocus();

      if (initialFocusComponent instanceof JButton) {
        JRootPane root = SwingUtilities.getRootPane(initialFocusComponent);
        if (root != null) {
          root.setDefaultButton((JButton) initialFocusComponent);
        }
      }
    }
  }
Esempio n. 12
0
 /**
  * This method navigates in the given direction giving focus to the next component in the given
  * direction.
  *
  * @param direction The direction to give focus to.
  */
 protected void navigateFocusedComp(int direction) {
   int count = toolBar.getComponentCount();
   switch (direction) {
     case EAST:
     case SOUTH:
       if (focusedCompIndex >= 0 && focusedCompIndex < count) {
         int i = focusedCompIndex + 1;
         boolean focusRequested = false;
         // Find component to focus and request focus on it.
         while (i != focusedCompIndex && !focusRequested) {
           if (i >= count) i = 0;
           Component comp = toolBar.getComponentAtIndex(i++);
           if (comp != null && comp.isFocusable() && comp.isEnabled()) {
             comp.requestFocus();
             focusRequested = true;
           }
         }
       }
       break;
     case WEST:
     case NORTH:
       if (focusedCompIndex >= 0 && focusedCompIndex < count) {
         int i = focusedCompIndex - 1;
         boolean focusRequested = false;
         // Find component to focus and request focus on it.
         while (i != focusedCompIndex && !focusRequested) {
           if (i < 0) i = count - 1;
           Component comp = toolBar.getComponentAtIndex(i--);
           if (comp != null && comp.isFocusable() && comp.isEnabled()) {
             comp.requestFocus();
             focusRequested = true;
           }
         }
       }
       break;
     default:
       break;
   }
 }
  public void paintEditor(Graphics g) {
    Component component = grid.getEditorComponent();
    if (component == null) {
      return;
    }

    int editingRow = grid.getEditingRow();
    int editingColumn = grid.getEditingColumn();
    Rectangle cellBounds = grid.getCellBounds(editingRow, editingColumn);
    component.setBounds(cellBounds);
    component.validate();
    component.requestFocus();
  }
Esempio n. 14
0
 public void pack(boolean force, BaseManager manager) {
   if (isHead()) {
     manager.pack();
     AbstractFrame abstractFrame = getFrame(manager);
     abstractFrame.repaint();
     abstractFrame.pack(force);
     if (manager != null) {
       Component focusComponent = manager.getFocusComponent();
       if (focusComponent != null) {
         focusComponent.requestFocus();
       }
     }
   }
 }
Esempio n. 15
0
 public void pack(AxisID axisID, boolean force, BaseManager manager) {
   if (isHead()) {
     manager.pack();
     AbstractFrame abstractFrame = getFrame(manager);
     abstractFrame.repaint(axisID);
     abstractFrame.pack(axisID, force);
     Component focusComponent = manager.getFocusComponent();
     // System.out.println("focusComponent=" + focusComponent);
     if (focusComponent != null) {
       focusComponent.requestFocus();
     }
     // else {
     // new Exception().printStackTrace();
     // }
   }
 }
 public void actionPerformed(ActionEvent e) {
   JTable table = (JTable) e.getSource();
   if (!table.hasFocus()) {
     CellEditor cellEditor = table.getCellEditor();
     if (cellEditor != null && !cellEditor.stopCellEditing()) {
       return;
     }
     table.requestFocus();
     return;
   }
   ListSelectionModel rsm = table.getSelectionModel();
   int anchorRow = rsm.getAnchorSelectionIndex();
   table.editCellAt(anchorRow, PropertySheetTableModel.VALUE_COLUMN);
   Component editorComp = table.getEditorComponent();
   if (editorComp != null) {
     editorComp.requestFocus();
   }
 }
 public void actionPerformed(ActionEvent e) {
   JListMutable list = (JListMutable) e.getSource();
   if (!list.hasFocus()) {
     CellEditor cellEditor = list.getListCellEditor();
     if (cellEditor != null && !cellEditor.stopCellEditing()) {
       return;
     }
     list.requestFocus();
     return;
   }
   ListSelectionModel rsm = list.getSelectionModel();
   int anchorRow = rsm.getAnchorSelectionIndex();
   list.editCellAt(anchorRow, null);
   Component editorComp = list.getEditorComponent();
   if (editorComp != null) {
     editorComp.requestFocus();
   }
 }
 public void actionPerformed(ActionEvent e) {
   JGrid grid = (JGrid) e.getSource();
   if (!grid.hasFocus()) {
     CellEditor cellEditor = grid.getCurrentCellEditor();
     if (cellEditor != null && !cellEditor.stopCellEditing()) {
       return;
     }
     grid.requestFocus();
   }
   SelectionModel selectionModel = grid.getSelectionModel();
   int anchorRow = selectionModel.getAnchorRow();
   int anchorColumn = selectionModel.getAnchorColumn();
   grid.editCellAt(anchorRow, anchorColumn, null);
   Component editorComp = grid.getEditorComponent();
   if (editorComp != null) {
     editorComp.requestFocus();
   }
 }
 public void actionPerformed(ActionEvent event) {
   JGrid grid = (JGrid) event.getSource();
   if (!grid.hasFocus()) {
     CellEditor cellEditor = grid.getCurrentCellEditor();
     if ((cellEditor != null) && !cellEditor.stopCellEditing()) {
       return;
     }
     grid.requestFocus();
   }
   SelectionModel selectionModel = grid.getSelectionModel();
   Cell selectedCell = selectionModel.getSelectedCell();
   int row = selectedCell.getRow();
   int column = selectedCell.getColumn();
   grid.editCellAt(row, column, null);
   Component editorComponent = grid.getEditorComponent();
   if (editorComponent != null) {
     editorComponent.requestFocus();
   }
 }
Esempio n. 20
0
        private void windowOpened0(final IInfoQueryCriteria parameter) {
          final I_AD_InfoColumn infoColumn = parameter.getAD_InfoColumn();
          if (infoColumn == null) {
            return; // shall not happen...
          }

          final String defaultValue = infoColumn.getDefaultValue();

          // search for first not null component
          for (int i = 0; i < parameter.getParameterCount(); i++) {
            final Component editor = getEditorComponentOrNull(parameter, i);
            if (editor == null) {
              continue;
            }

            // add general listeners on parameter components
            editor.addKeyListener(
                new KeyAdapter() {
                  @Override
                  public void keyReleased(final KeyEvent e) {
                    if (KeyEvent.VK_ENTER == e.getKeyCode()) {
                      // each field shall execute query on enter
                      executeQuery();
                    }
                  }
                });

            // we are focusing on field which as "SearchText" as default value
            if (defaultValue == null || defaultValue.indexOf(ATTR_SearchText) < 0) {
              return;
            }

            editor.requestFocus();

            final String text = parameter.getText();
            if (!Check.isEmpty(text, true)) {
              executeQueryOnInit();
            }
          }
        }
 /**
  * Overridden to request the focus on the selected component.
  *
  * @see JTabbedPane#setSelectedComponent(Component)
  */
 public void setSelectedComponent(Component component) {
   super.setSelectedComponent(component);
   if (component != null) component.requestFocus();
 }
  public SheetMessage(
      final Window owner,
      final String title,
      final String message,
      final Icon icon,
      final String[] buttons,
      final DialogWrapper.DoNotAskOption doNotAskOption,
      final String defaultButton,
      final String focusedButton) {
    final Window activeWindow =
        KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow();
    final Component recentFocusOwner =
        activeWindow == null ? null : activeWindow.getMostRecentFocusOwner();
    WeakReference<Component> beforeShowFocusOwner = new WeakReference<Component>(recentFocusOwner);

    maximizeIfNeeded(owner);

    myWindow =
        new JDialog(owner, "This should not be shown", Dialog.ModalityType.APPLICATION_MODAL);
    myWindow.getRootPane().putClientProperty("apple.awt.draggableWindowBackground", Boolean.FALSE);

    myWindow.addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowActivated(@NotNull WindowEvent e) {
            super.windowActivated(e);
          }
        });

    myParent = owner;

    myWindow.setUndecorated(true);
    myWindow.setBackground(Gray.TRANSPARENT);
    myController =
        new SheetController(
            this, title, message, icon, buttons, defaultButton, doNotAskOption, focusedButton);

    imageHeight = 0;
    registerMoveResizeHandler();
    myWindow.setFocusable(true);
    myWindow.setFocusableWindowState(true);
    if (SystemInfo.isJavaVersionAtLeast("1.7")) {
      myWindow.setSize(myController.SHEET_NC_WIDTH, 0);

      setWindowOpacity(0.0f);

      myWindow.addComponentListener(
          new ComponentAdapter() {
            @Override
            public void componentShown(@NotNull ComponentEvent e) {
              super.componentShown(e);
              setWindowOpacity(1.0f);
              myWindow.setSize(myController.SHEET_NC_WIDTH, myController.SHEET_NC_HEIGHT);
            }
          });
    } else {
      myWindow.setModal(true);
      myWindow.setSize(myController.SHEET_NC_WIDTH, myController.SHEET_NC_HEIGHT);
      setPositionRelativeToParent();
    }
    startAnimation(true);
    restoreFullScreenButton = couldBeInFullScreen();
    if (restoreFullScreenButton) {
      FullScreenUtilities.setWindowCanFullScreen(myParent, false);
    }

    LaterInvocator.enterModal(myWindow);
    myWindow.setVisible(true);
    LaterInvocator.leaveModal(myWindow);

    Component focusCandidate = beforeShowFocusOwner.get();

    if (focusCandidate == null) {
      focusCandidate =
          IdeFocusManager.getGlobalInstance()
              .getLastFocusedFor(IdeFocusManager.getGlobalInstance().getLastFocusedFrame());
    }

    // focusCandidate is null if a welcome screen is closed and ide frame is not opened.
    // this is ok. We set focus correctly on our frame activation.
    if (focusCandidate != null) {
      focusCandidate.requestFocus();
    }
  }
Esempio n. 23
0
  /**
   * Forwards key events directly to the input handler. This is slightly faster than using a
   * KeyListener because some Swing overhead is avoided.
   *
   * @since 4.3pre7
   */
  @Override
  public void processKeyEvent(KeyEvent evt, int from, boolean global) {
    if (Debug.DUMP_KEY_EVENTS) {
      Log.log(
          Log.DEBUG,
          this,
          "Key event                 : " + AbstractInputHandler.toString(evt) + " from " + from);
      Log.log(Log.DEBUG, this, view + ".isFocused()=" + view.isFocused() + '.', new Exception());
    }

    if (view.getTextArea().hasFocus() && from == View.VIEW) return;

    evt = _preprocessKeyEvent(evt);
    if (evt == null) return;

    if (Debug.DUMP_KEY_EVENTS) {
      Log.log(
          Log.DEBUG,
          this,
          "Key event after workaround: " + AbstractInputHandler.toString(evt) + " from " + from);
    }

    Component prefixFocusOwner = view.getPrefixFocusOwner();
    boolean focusOnTextArea = false;
    switch (evt.getID()) {
      case KeyEvent.KEY_TYPED:
        // if the user pressed eg C+e n n in the
        // search bar we want focus to go back there
        // after the prefix is done
        if (prefixFocusOwner != null) {
          if (prefixFocusOwner.isShowing()) {
            prefixFocusOwner.requestFocus();
            focusOnTextArea = true;
          }
        }

        if (keyEventInterceptor != null) keyEventInterceptor.keyTyped(evt);
        else if (from == View.ACTION_BAR || isPrefixActive() || view.getTextArea().hasFocus()) {
          processKeyEventKeyStrokeHandling(evt, from, "type ", global);
        }

        processKeyEventSub(focusOnTextArea);

        break;
      case KeyEvent.KEY_PRESSED:
        if (keyEventInterceptor != null) keyEventInterceptor.keyPressed(evt);
        else if (KeyEventWorkaround.isBindable(evt.getKeyCode())) {
          if (prefixFocusOwner != null) {
            if (prefixFocusOwner.isShowing()) {
              prefixFocusOwner.requestFocus();
              focusOnTextArea = true;
            }
            view.setPrefixFocusOwner(null);
          }

          processKeyEventKeyStrokeHandling(evt, from, "press", global);

          processKeyEventSub(focusOnTextArea);
        }
        break;
      case KeyEvent.KEY_RELEASED:
        if (keyEventInterceptor != null) keyEventInterceptor.keyReleased(evt);
        break;
    }
  } // }}}
    public void actionPerformed(ActionEvent e) {
      JDesktopPane dp = (JDesktopPane) e.getSource();
      String key = getName();

      if (CLOSE == key || MAXIMIZE == key || MINIMIZE == key || RESTORE == key) {
        setState(dp, key);
      } else if (ESCAPE == key) {
        if (sourceFrame == dp.getSelectedFrame() && focusOwner != null) {
          focusOwner.requestFocus();
        }
        moving = false;
        resizing = false;
        sourceFrame = null;
        focusOwner = null;
      } else if (MOVE == key || RESIZE == key) {
        sourceFrame = dp.getSelectedFrame();
        if (sourceFrame == null) {
          return;
        }
        moving = (key == MOVE) ? true : false;
        resizing = (key == RESIZE) ? true : false;

        focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
        if (!SwingUtilities.isDescendingFrom(focusOwner, sourceFrame)) {
          focusOwner = null;
        }
        sourceFrame.requestFocus();
      } else if (LEFT == key
          || RIGHT == key
          || UP == key
          || DOWN == key
          || SHRINK_RIGHT == key
          || SHRINK_LEFT == key
          || SHRINK_UP == key
          || SHRINK_DOWN == key) {
        JInternalFrame c = dp.getSelectedFrame();
        if (sourceFrame == null
            || c != sourceFrame
            || KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner()
                != sourceFrame) {
          return;
        }
        Insets minOnScreenInsets = UIManager.getInsets("Desktop.minOnScreenInsets");
        Dimension size = c.getSize();
        Dimension minSize = c.getMinimumSize();
        int dpWidth = dp.getWidth();
        int dpHeight = dp.getHeight();
        int delta;
        Point loc = c.getLocation();
        if (LEFT == key) {
          if (moving) {
            c.setLocation(
                loc.x + size.width - MOVE_RESIZE_INCREMENT < minOnScreenInsets.right
                    ? -size.width + minOnScreenInsets.right
                    : loc.x - MOVE_RESIZE_INCREMENT,
                loc.y);
          } else if (resizing) {
            c.setLocation(loc.x - MOVE_RESIZE_INCREMENT, loc.y);
            c.setSize(size.width + MOVE_RESIZE_INCREMENT, size.height);
          }
        } else if (RIGHT == key) {
          if (moving) {
            c.setLocation(
                loc.x + MOVE_RESIZE_INCREMENT > dpWidth - minOnScreenInsets.left
                    ? dpWidth - minOnScreenInsets.left
                    : loc.x + MOVE_RESIZE_INCREMENT,
                loc.y);
          } else if (resizing) {
            c.setSize(size.width + MOVE_RESIZE_INCREMENT, size.height);
          }
        } else if (UP == key) {
          if (moving) {
            c.setLocation(
                loc.x,
                loc.y + size.height - MOVE_RESIZE_INCREMENT < minOnScreenInsets.bottom
                    ? -size.height + minOnScreenInsets.bottom
                    : loc.y - MOVE_RESIZE_INCREMENT);
          } else if (resizing) {
            c.setLocation(loc.x, loc.y - MOVE_RESIZE_INCREMENT);
            c.setSize(size.width, size.height + MOVE_RESIZE_INCREMENT);
          }
        } else if (DOWN == key) {
          if (moving) {
            c.setLocation(
                loc.x,
                loc.y + MOVE_RESIZE_INCREMENT > dpHeight - minOnScreenInsets.top
                    ? dpHeight - minOnScreenInsets.top
                    : loc.y + MOVE_RESIZE_INCREMENT);
          } else if (resizing) {
            c.setSize(size.width, size.height + MOVE_RESIZE_INCREMENT);
          }
        } else if (SHRINK_LEFT == key && resizing) {
          // Make sure we don't resize less than minimum size.
          if (minSize.width < (size.width - MOVE_RESIZE_INCREMENT)) {
            delta = MOVE_RESIZE_INCREMENT;
          } else {
            delta = size.width - minSize.width;
          }

          // Ensure that we keep the internal frame on the desktop.
          if (loc.x + size.width - delta < minOnScreenInsets.left) {
            delta = loc.x + size.width - minOnScreenInsets.left;
          }
          c.setSize(size.width - delta, size.height);
        } else if (SHRINK_RIGHT == key && resizing) {
          // Make sure we don't resize less than minimum size.
          if (minSize.width < (size.width - MOVE_RESIZE_INCREMENT)) {
            delta = MOVE_RESIZE_INCREMENT;
          } else {
            delta = size.width - minSize.width;
          }

          // Ensure that we keep the internal frame on the desktop.
          if (loc.x + delta > dpWidth - minOnScreenInsets.right) {
            delta = (dpWidth - minOnScreenInsets.right) - loc.x;
          }

          c.setLocation(loc.x + delta, loc.y);
          c.setSize(size.width - delta, size.height);
        } else if (SHRINK_UP == key && resizing) {
          // Make sure we don't resize less than minimum size.
          if (minSize.height < (size.height - MOVE_RESIZE_INCREMENT)) {
            delta = MOVE_RESIZE_INCREMENT;
          } else {
            delta = size.height - minSize.height;
          }

          // Ensure that we keep the internal frame on the desktop.
          if (loc.y + size.height - delta < minOnScreenInsets.bottom) {
            delta = loc.y + size.height - minOnScreenInsets.bottom;
          }

          c.setSize(size.width, size.height - delta);
        } else if (SHRINK_DOWN == key && resizing) {
          // Make sure we don't resize less than minimum size.
          if (minSize.height < (size.height - MOVE_RESIZE_INCREMENT)) {
            delta = MOVE_RESIZE_INCREMENT;
          } else {
            delta = size.height - minSize.height;
          }

          // Ensure that we keep the internal frame on the desktop.
          if (loc.y + delta > dpHeight - minOnScreenInsets.top) {
            delta = (dpHeight - minOnScreenInsets.top) - loc.y;
          }

          c.setLocation(loc.x, loc.y + delta);
          c.setSize(size.width, size.height - delta);
        }
      } else if (NEXT_FRAME == key || PREVIOUS_FRAME == key) {
        dp.selectFrame((key == NEXT_FRAME) ? true : false);
      } else if (NAVIGATE_NEXT == key || NAVIGATE_PREVIOUS == key) {
        boolean moveForward = true;
        if (NAVIGATE_PREVIOUS == key) {
          moveForward = false;
        }
        Container cycleRoot = dp.getFocusCycleRootAncestor();

        if (cycleRoot != null) {
          FocusTraversalPolicy policy = cycleRoot.getFocusTraversalPolicy();
          if (policy != null && policy instanceof SortingFocusTraversalPolicy) {
            SortingFocusTraversalPolicy sPolicy = (SortingFocusTraversalPolicy) policy;
            boolean idc = sPolicy.getImplicitDownCycleTraversal();
            try {
              sPolicy.setImplicitDownCycleTraversal(false);
              if (moveForward) {
                KeyboardFocusManager.getCurrentKeyboardFocusManager().focusNextComponent(dp);
              } else {
                KeyboardFocusManager.getCurrentKeyboardFocusManager().focusPreviousComponent(dp);
              }
            } finally {
              sPolicy.setImplicitDownCycleTraversal(idc);
            }
          }
        }
      }
    }
 @Override
 public void run() {
   comp.requestFocus();
 }
Esempio n. 26
0
  public void keyPressed(KeyEvent evt) {
    int keyKode = evt.getKeyCode();
    switch (keyKode) {
      case KeyEvent.VK_ENTER:
        {
          if (evt.getSource().getClass().getName().equals("JTable")) {
            return;
          }
          if (!lst.isVisible()) {
            Component c = findNextFocus();
            if (c != null) c.requestFocus();
          } else {
            lst.requestFocus();
          }
          break;
        }
      case KeyEvent.VK_UP:
        {
          if (evt.getSource().getClass().getName().equals("JTable")) {
            return;
          }
          if (!lst.isVisible()) {
            Component c = findPrevFocus();
            if (c != null) c.requestFocus();
          } else {
            lst.requestFocus();
          }
          break;
        }
      case KeyEvent.VK_DOWN:
        {
          if (evt.getSource().getClass().getName().equals("JTable")) {
            return;
          }
          if (!lst.isVisible()) {
            Component c = findNextFocus();
            if (c != null) c.requestFocus();
          } else {
            lst.requestFocus();
          }
          break;
        }
      case KeyEvent.VK_INSERT:
        { //
          //                    if (getBEdit()){
          //                        if (tblItem.getRowCount()>=0){
          //                            udfInsertDetail();
          //                        }
          //                    }
          break;
        }
      case KeyEvent.VK_F2:
        { // Add
          //                    udfLookupPenerimaan();
          break;
        }
      case KeyEvent.VK_F3:
        { // Edit
          //   udfFilter();
          break;
        }
      case KeyEvent.VK_F4:
        { // Delete
          // udfDeleteItem();
          break;
        }

      case KeyEvent.VK_ESCAPE:
        {
          // Fr.dispose();
        }
        // default ;

    }
  }