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

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

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

JScrollPane.addMouseWheelListener介绍

暂无

代码示例

代码示例来源:origin: jawi/ols

/**
 * {@inheritDoc}
 */
@Override
public synchronized void addMouseWheelListener( final MouseWheelListener aListener )
{
 lazyInitListeners();
 this.originalListeners.add( aListener );
 super.addMouseWheelListener( aListener );
}

代码示例来源:origin: omegat-org/omegat

@Override
  public void run() {
    TitledTablePanel panel = generateTableDisplay(title, headers, data);
    panel.scrollPane.addMouseWheelListener(mouseWheelListener);
    tablesPanel.add(panel);
  }
});

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

/**
 * Install a MouseWheelCurrentPageListener as a MouseWheelListener
 */
public static Object install(JScrollPane scrollpane,
               CurrentPageChanger currentPageChanger) {
  MouseWheelCurrentPageListener listener = null;
  if (scrollpane != null && currentPageChanger != null) {
    listener =
        new MouseWheelCurrentPageListener(scrollpane, currentPageChanger);
    scrollpane.addMouseWheelListener(listener);
  }
  return listener;
}

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

public void installTool() {
  documentScrollPane.setWheelScrollingEnabled(false);
  documentScrollPane.addMouseWheelListener(this);
}

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

/**
 * Install a MouseWheelListenerPageChanger as a MouseWheelListener
 *
 * @param c SwingController that can change pages
 * @param s JScrollPane that has a vertical JScrollBar, and where events come from
 */
public static Object install(SwingController c, JScrollPane s,
               AbstractDocumentView documentView) {
  MouseWheelListenerPageChanger listener = null;
  if (c != null && s != null) {
    listener = new MouseWheelListenerPageChanger(c, s, documentView);
    s.addMouseWheelListener(listener);
  }
  return listener;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-team-commons

public static void issue163946Hack(final JScrollPane scrollPane) {
  MouseWheelListener listener = new MouseWheelListener() {
    @Override
    public void mouseWheelMoved(MouseWheelEvent e) {
      if (scrollPane.getVerticalScrollBar().isShowing()) {
        if (e.getSource() != scrollPane) {
          e.setSource(scrollPane);
          scrollPane.dispatchEvent(e);
        }
      } else {
        scrollPane.getParent().dispatchEvent(e);
      }
    }
  };
  scrollPane.addMouseWheelListener(listener);
  scrollPane.getViewport().getView().addMouseWheelListener(listener);
}

代码示例来源:origin: Exslims/MercuryTrade

public JScrollPane getVerticalContainer(JPanel container) {
  JScrollPane scrollPane = new JScrollPane(container);
  scrollPane.setBorder(null);
  scrollPane.setBackground(AppThemeColor.FRAME);
  scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
  scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
  scrollPane.addMouseWheelListener(e -> MercuryStoreUI.scrollToEndSubject.onNext(false));
  container.getParent().setBackground(AppThemeColor.TRANSPARENT);
  JScrollBar vBar = scrollPane.getVerticalScrollBar();
  vBar.setBackground(AppThemeColor.SLIDE_BG);
  vBar.setUI(new MercuryScrollBarUI());
  vBar.setPreferredSize(new Dimension(15, Integer.MAX_VALUE));
  vBar.setUnitIncrement(3);
  vBar.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
  return scrollPane;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-lib-profiler-ui

private void initComponents() {
  setBorder(BorderFactory.createEmptyBorder());
  extendedTableScrollPane = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
                       JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
  extendedTableViewport = new CustomExtendedTableViewport(extendedTable);
  extendedTableScrollPane.setViewport(extendedTableViewport);
  extendedTableScrollPane.addMouseWheelListener(extendedTable);
  // Enable vertical scrollbar only if needed
  JScrollBar vScrollbar = extendedTableScrollPane.getVerticalScrollBar();
  vScrollbar.getModel().addChangeListener(new ChangeListener() {
    public void stateChanged(ChangeEvent e) {
      updateVerticalScrollbar();
    }
  });
  add(extendedTableScrollPane, BorderLayout.CENTER);
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-lib-profiler-ui

public FlatProfilePanel(CPUResUserActionsHandler actionsHandler, CPUSelectionHandler selectionHandler, Boolean sampling) {
  super(actionsHandler, sampling);
  this.selectionHandler = selectionHandler;
  setDefaultSorting();
  minNamesColumnWidth = getFontMetrics(getFont()).charWidth('W') * 30; // NOI18N
  cornerPopup = new JPopupMenu();
  jScrollPane = createScrollPaneVerticalScrollBarAlways();
  jScrollPane.setCorner(JScrollPane.UPPER_RIGHT_CORNER, createHeaderPopupCornerButton(cornerPopup));
  jScrollPane.setBorder(BorderFactory.createEmptyBorder());
  jScrollPane.setViewportBorder(BorderFactory.createEmptyBorder());
  jScrollPane.addMouseWheelListener(new MouseWheelListener() {
      public void mouseWheelMoved(MouseWheelEvent e) {
        if (resTable != null) {
          resTable.mouseWheelMoved(e);
        }
      }
    });
  initFilterPanel();
}

代码示例来源:origin: org.jflux/org.jflux.swing.services

/** Creates new form ServiceManagerPanel */
public ServiceManagerPanel() {
  initComponents();
  pnlDependencyList.setLayout(
      new BoxLayout(pnlDependencyList, BoxLayout.Y_AXIS));
  myServiceChangeListener = new ServiceChangeListener();
  myDepChangeListeners=new ArrayList<DepChangeListener>();
  myPropertiesVisible = true;
  tblProperties.setTableHeader(null);
  lblType.setOpaque(false);
  jScrollPane2.setOpaque(false);
  jScrollPane2.getViewport().setOpaque(false);
  jScrollPane2.addMouseWheelListener(new InnerScrollPaneWheelListener());
}

代码示例来源:origin: org.rwshop/org.rwshop.swing.common

/** Creates new form ServiceManagerPanel */
public ServiceManagerPanel() {
  initComponents();
  pnlDependencyList.setLayout(
      new BoxLayout(pnlDependencyList, BoxLayout.Y_AXIS));
  myServiceChangeListener = new ServiceChangeListener();
  myServiceChangeListeners=new ArrayList<ServiceChangeListener>();
  myPropertiesVisible = true;
  tblProperties.setTableHeader(null);
  lblType.setOpaque(false);
  jScrollPane2.setOpaque(false);
  jScrollPane2.getViewport().setOpaque(false);
  jScrollPane2.addMouseWheelListener(new InnerScrollPaneWheelListener());
}

代码示例来源:origin: org.jflux/org.jflux.swing.services

/** Creates new form DependencyPanel */
public ManagerDependencyPanel() {
  initComponents();
  lblFilter.setOpaque(false);
  jScrollPane1.setOpaque(false);
  jScrollPane1.getViewport().setOpaque(false);
  jScrollPane1.addMouseWheelListener(new InnerScrollPaneWheelListener());
  lblType.setOpaque(false);
  jScrollPane2.setOpaque(false);
  jScrollPane2.getViewport().setOpaque(false);
  jScrollPane2.addMouseWheelListener(new InnerScrollPaneWheelListener());
  updateDisplay(null);
  changeColor(null, null);
}

代码示例来源:origin: org.rwshop/org.rwshop.swing.common

/** Creates new form DependencyPanel */
public DependencyPanel() {
  initComponents();
  lblFilter.setOpaque(false);
  jScrollPane1.setOpaque(false);
  jScrollPane1.getViewport().setOpaque(false);
  jScrollPane1.addMouseWheelListener(new InnerScrollPaneWheelListener());
  lblType.setOpaque(false);
  jScrollPane2.setOpaque(false);
  jScrollPane2.getViewport().setOpaque(false);
  jScrollPane2.addMouseWheelListener(new InnerScrollPaneWheelListener());
  updateDisplay(null);
  changeColor(null);
}

代码示例来源:origin: org.rwshop/org.rwshop.swing.common

/** Creates new form DependencyPanel */
public ManagerDependencyPanel() {
  initComponents();
  lblFilter.setOpaque(false);
  jScrollPane1.setOpaque(false);
  jScrollPane1.getViewport().setOpaque(false);
  jScrollPane1.addMouseWheelListener(new InnerScrollPaneWheelListener());
  lblType.setOpaque(false);
  jScrollPane2.setOpaque(false);
  jScrollPane2.getViewport().setOpaque(false);
  jScrollPane2.addMouseWheelListener(new InnerScrollPaneWheelListener());
  updateDisplay(null);
  changeColor(null);
}

代码示例来源:origin: org.jflux/org.jflux.swing.services

/** Creates new form DependencyPanel */
public DependencyPanel() {
  initComponents();
  lblFilter.setOpaque(false);
  jScrollPane1.setOpaque(false);
  jScrollPane1.getViewport().setOpaque(false);
  jScrollPane1.addMouseWheelListener(new InnerScrollPaneWheelListener());
  lblType.setOpaque(false);
  jScrollPane2.setOpaque(false);
  jScrollPane2.getViewport().setOpaque(false);
  jScrollPane2.addMouseWheelListener(new InnerScrollPaneWheelListener());
  updateDisplay(null);
  changeColor(null);
}

代码示例来源:origin: org.jflux/org.jflux.swing.services

/** Creates new form ManagedServicePanel */
public ManagedServicePanel() {
  initComponents();
  pnlDependencyList.setLayout(
      new BoxLayout(pnlDependencyList, BoxLayout.Y_AXIS));
  myServiceChangeListener = new ServiceChangeListener();
  myPropertiesVisible = true;
  tblProperties.setTableHeader(null);
  lblType.setOpaque(false);
  jScrollPane2.setOpaque(false);
  jScrollPane2.getViewport().setOpaque(false);
  jScrollPane2.addMouseWheelListener(new InnerScrollPaneWheelListener());
}

代码示例来源:origin: org.rwshop/org.rwshop.swing.common

/** Creates new form ManagedServicePanel */
public ManagedServicePanel() {
  initComponents();
  pnlDependencyList.setLayout(
      new BoxLayout(pnlDependencyList, BoxLayout.Y_AXIS));
  myServiceChangeListener = new ServiceChangeListener();
  myPropertiesVisible = true;
  tblProperties.setTableHeader(null);
  lblType.setOpaque(false);
  jScrollPane2.setOpaque(false);
  jScrollPane2.getViewport().setOpaque(false);
  jScrollPane2.addMouseWheelListener(new InnerScrollPaneWheelListener());
}

代码示例来源:origin: Exslims/MercuryTrade

scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
scrollPane.addMouseWheelListener(new MouseAdapter() {
  @Override
  public void mouseWheelMoved(MouseWheelEvent e) {

代码示例来源:origin: com.synaptix/SynaptixSwing

private void initComponents() {
  createComponents();
  scrollPane
      .setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
  scrollPane
      .setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
  MyAdjustmentListener adjustmentListener = new MyAdjustmentListener();
  scrollPane.getHorizontalScrollBar().addAdjustmentListener(
      adjustmentListener);
  scrollPane.getVerticalScrollBar().addAdjustmentListener(
      adjustmentListener);
  MyMouseAdapter mouseAdapter = new MyMouseAdapter();
  scrollPane.addMouseMotionListener(mouseAdapter);
  scrollPane.addMouseWheelListener(mouseAdapter);
  scrollPane.addMouseListener(mouseAdapter);
  Toolkit.getDefaultToolkit().addAWTEventListener(
      new MyAWTEventListener(),
      AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_MOTION_EVENT_MASK
          | AWTEvent.MOUSE_WHEEL_EVENT_MASK);
  verifyScrollBars();
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/toniclf

protected void installListeners(JScrollPane c) 
{
vsbChangeListener = createVSBChangeListener();
  vsbPropertyChangeListener = createVSBPropertyChangeListener();
hsbChangeListener = createHSBChangeListener();
  hsbPropertyChangeListener = createHSBPropertyChangeListener();
viewportChangeListener = createViewportChangeListener();
spPropertyChangeListener = createPropertyChangeListener();
JViewport viewport = scrollpane.getViewport();
JScrollBar vsb = scrollpane.getVerticalScrollBar();
JScrollBar hsb = scrollpane.getHorizontalScrollBar();
if (viewport != null) {
  viewport.addChangeListener(viewportChangeListener);
}
if (vsb != null) {
  vsb.getModel().addChangeListener(vsbChangeListener);
    vsb.addPropertyChangeListener(vsbPropertyChangeListener);
}
if (hsb != null) {
  hsb.getModel().addChangeListener(hsbChangeListener);
    hsb.addPropertyChangeListener(hsbPropertyChangeListener);
}
scrollpane.addPropertyChangeListener(spPropertyChangeListener);
mouseScrollListener = createMouseWheelListener();
scrollpane.addMouseWheelListener(mouseScrollListener);
}

相关文章

JScrollPane类方法