javax.swing.JScrollPane.getActionMap()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(4.6k)|赞(0)|评价(0)|浏览(116)

本文整理了Java中javax.swing.JScrollPane.getActionMap()方法的一些代码示例,展示了JScrollPane.getActionMap()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JScrollPane.getActionMap()方法的具体详情如下:
包路径:javax.swing.JScrollPane
类名称:JScrollPane
方法名:getActionMap

JScrollPane.getActionMap介绍

暂无

代码示例

代码示例来源:origin: apache/pdfbox

private JScrollPane getScrollPane()
{
  JScrollPane scrollPane = new JScrollPane();
  scrollPane.setBorder(new LineBorder(Color.LIGHT_GRAY));
  Action blankAction = new AbstractAction()
  {
    @Override
    public void actionPerformed(ActionEvent actionEvent)
    {
    }
  };
  scrollPane.getActionMap().put("unitScrollDown", blankAction);
  scrollPane.getActionMap().put("unitScrollLeft", blankAction);
  scrollPane.getActionMap().put("unitScrollRight", blankAction);
  scrollPane.getActionMap().put("unitScrollUp", blankAction);
  JScrollBar verticalScrollBar = scrollPane.createVerticalScrollBar();
  verticalScrollBar.setUnitIncrement(HexView.CHAR_HEIGHT);
  verticalScrollBar.setBlockIncrement(HexView.CHAR_HEIGHT * 20);
  verticalScrollBar.setValues(0, 1, 0, HexView.CHAR_HEIGHT * (model.totalLine()+1));
  scrollPane.setVerticalScrollBar(verticalScrollBar);
  return scrollPane;
}

代码示例来源:origin: hltfbk/Excitement-Open-Platform

@SuppressWarnings("serial")
private JScrollPane createNewImagePane() {
  ImagePaintingComponent imagePaintingComponent = new ImagePaintingComponent();
  JScrollPane newImageScrollPane = 
      new JScrollPane(imagePaintingComponent, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
  mapImagePanesToImagePaintingComponents.put(newImageScrollPane, imagePaintingComponent);
  newImageScrollPane.addMouseWheelListener(actionsPerformer);
  newImageScrollPane.addKeyListener(actionsPerformer);
  
   /* add a new actions for zoomIn and zoomOut key strokes to the panel's action map */
  newImageScrollPane.getActionMap().put(COMMAND_ZOOM_IN, new AbstractAction() {
    public void actionPerformed(ActionEvent e) {
        actionsPerformer.zoomIn();
      }
    });
  newImageScrollPane.getActionMap().put(COMMAND_ZOOM_OUT, new AbstractAction() {
    public void actionPerformed(ActionEvent e) {
      actionsPerformer.zoomOut();
    }
  });
  // listen to +/-/=/Ctrl+/Ctrl-/Ctrl= keystrokes
  newImageScrollPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_PLUS, InputEvent.CTRL_MASK), COMMAND_ZOOM_IN);
  newImageScrollPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_EQUALS, InputEvent.CTRL_MASK), COMMAND_ZOOM_IN);
  newImageScrollPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, InputEvent.CTRL_MASK), COMMAND_ZOOM_OUT);
  newImageScrollPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(Character.valueOf('-'), 0), COMMAND_ZOOM_OUT);
  newImageScrollPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(Character.valueOf('+'), 0), COMMAND_ZOOM_IN);
  newImageScrollPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(Character.valueOf('='), 0), COMMAND_ZOOM_IN);
  
  return newImageScrollPane;
}

代码示例来源:origin: org.icepdf.os/icepdf-viewer

public DocumentViewControllerImpl(final SwingController viewerController) {
  this.viewerController = viewerController;
  documentViewScrollPane = new JScrollPane();
  documentViewScrollPane.getViewport().setBackground(AbstractDocumentView.BACKGROUND_COLOUR);
  // set scroll bar speeds
  documentViewScrollPane.getVerticalScrollBar().setUnitIncrement(20);
  documentViewScrollPane.getHorizontalScrollBar().setUnitIncrement(20);
  // add a delete key functionality for annotation edits.
  Action deleteAnnotation = new AbstractAction() {
    public void actionPerformed(ActionEvent e) {
      if (documentViewModel != null) {
        deleteCurrentAnnotation();
        viewerController.reflectUndoCommands();
      }
    }
  };
  InputMap inputMap = documentViewScrollPane.getInputMap(
      JComponent.WHEN_IN_FOCUSED_WINDOW);
  inputMap.put(KeyStroke.getKeyStroke("DELETE"),
      "removeSelectedAnnotation");
  documentViewScrollPane.getActionMap().put("removeSelectedAnnotation",
      deleteAnnotation);
}

代码示例来源:origin: MegaMek/megamek

scrollpane.getActionMap().put("unitScrollRight", DoNothing);
scrollpane.getActionMap().put("unitScrollDown", DoNothing);
scrollpane.getActionMap().put("unitScrollLeft", DoNothing);
scrollpane.getActionMap().put("unitScrollUp", DoNothing);

代码示例来源:origin: chatty/chatty

west.getActionMap().put("pageUp", new ScrollAction("pageUp", west.getVerticalScrollBar()));
westScrollInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, 0), "pageDown");
west.getActionMap().put("pageDown", new ScrollAction("pageDown", west.getVerticalScrollBar()));
west.getVerticalScrollBar().setUnitIncrement(40);

相关文章

JScrollPane类方法