javax.swing.JPanel.addMouseMotionListener()方法的使用及代码示例

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

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

JPanel.addMouseMotionListener介绍

暂无

代码示例

代码示例来源:origin: hsz/idea-gitignore

northPanel.addMouseMotionListener(this);
tabbedPanel.addChangeListener(this);

代码示例来源:origin: bobbylight/RSyntaxTextArea

panel.addMouseMotionListener(adapter);

代码示例来源:origin: fossasia/neurolab-desktop

this.trackPanel.addMouseMotionListener(new MouseMotionListener()

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

@Override
public void addMouseMotionListener(MouseMotionListener mouseMotionListener) {
  internal.addMouseMotionListener(mouseMotionListener);
}

代码示例来源:origin: stackoverflow.com

public void handleDrag(JPanel panel){
  final JPanel p = panel;
    panel.addMouseMotionListener(new MouseMotionAdapter() {

      @Override
      public void mouseDragged(MouseEvent me) {
        me.translatePoint(me.getComponent().getLocation().x, me.getComponent().getLocation().y);
        p.setLocation(me.getX(), me.getY());
      }

    });
}

代码示例来源:origin: stackoverflow.com

public static void main( String[] args ) {
 EventQueue.invokeLater( new Runnable() {
  @Override
  public void run() {
   JFrame frame = new JFrame( "TestFrame" );
   JPanel content = new JPanel( new BorderLayout() );
   final JLabel mousePosition = new JLabel( "Unknown" );
   content.add( mousePosition, BorderLayout.NORTH );
   content.addMouseMotionListener( new MouseMotionAdapter() {
    @Override
    public void mouseMoved( MouseEvent e ) {
     mousePosition.setText( "X: " + e.getX() + " Y: " + e.getY() );
    }
   } );
   frame.setContentPane( content );
   frame.setDefaultCloseOperation( WindowConstants.EXIT_ON_CLOSE );
   frame.pack();
   frame.setVisible( true );
  }
 } );
}

代码示例来源:origin: stackoverflow.com

public static void main ( String[] args )
{
  JFrame frame = new JFrame ();
  frame.setUndecorated ( true );

  JPanel panel = new JPanel ();
  panel.setBackground ( Color.BLACK );
  WindowMoveAdapter wma = new WindowMoveAdapter ();
  panel.addMouseListener ( wma );
  panel.addMouseMotionListener ( wma );
  frame.getContentPane ().add ( panel );

  Area shape = createShape ();
  AWTUtilities.setWindowShape ( frame, shape );
  frame.setSize ( shape.getBounds ().getSize () );
  frame.setLocationRelativeTo ( null );

  frame.setDefaultCloseOperation ( JFrame.EXIT_ON_CLOSE );
  frame.setVisible ( true );
}

代码示例来源:origin: com.thesett/debug_ui_tools_swing

/** {@inheritDoc} */
public JComponent createGripPanel(MotionDelta motionDelta, boolean vertical)
{
  JPanel vbar = new JPanel();
  vbar.setBackground(toolingColorScheme.getToolingBackground());
  GripComponentMouseMover resizer =
    new GripComponentMouseMover(vbar, motionDelta, vertical ? VERTICAL_RESIZE_CURSOR : HORIZONTAL_RESIZE_CURSOR,
      GRIP_CURSOR);
  vbar.addMouseMotionListener(resizer);
  vbar.addMouseListener(resizer);
  return vbar;
}

代码示例来源:origin: akquinet/jbosscc-as7-examples

/**
 * Implements method for the <tt>MouseListener</tt> interface to initiate
 * shape dragging.
 *
 * @param evt
 *            The associated mouse event.
 **/
public void mousePressed(MouseEvent evt) {
  Component c = m_panel.getComponentAt(evt.getPoint());
  if (c instanceof ShapeComponent) {
    m_selectedComponent = (ShapeComponent) c;
    m_panel.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
    m_panel.addMouseMotionListener(this);
    m_selectedComponent.repaint();
  }
}

代码示例来源:origin: nroduit/Weasis

public ImageViewerPlugin(ImageViewerEventManager<E> eventManager, GridBagLayoutModel layoutModel, String uid,
  String pluginName, Icon icon, String tooltips) {
  super(uid, pluginName, icon, tooltips);
  if (eventManager == null) {
    throw new IllegalArgumentException("EventManager cannot be null"); //$NON-NLS-1$
  }
  this.eventManager = eventManager;
  view2ds = new ArrayList<>();
  components = new ArrayList<>();
  grid = new JPanel();
  // For having a black background with any Look and Feel
  grid.setUI(new PanelUI() {
  });
  grid.setBackground(Color.BLACK);
  grid.setFocusCycleRoot(true);
  grid.setLayout(new GridBagLayout());
  add(grid, BorderLayout.CENTER);
  setLayoutModel(layoutModel);
  this.mouseHandler = new MouseHandler();
  grid.addMouseListener(mouseHandler);
  grid.addMouseMotionListener(mouseHandler);
}

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

private void setUpResizePanels(JPanel root) {
  JLabel rightArrow = componentsFactory.getIconLabel("app/default-mp.png", 16); //todo
  JPanel rightPanel = componentsFactory.getTransparentPanel(new BorderLayout());
  rightPanel.setBackground(AppThemeColor.FRAME);
  rightPanel.add(rightArrow, BorderLayout.CENTER);
  rightPanel.addMouseListener(new ArrowMouseListener(rightPanel, new Cursor(Cursor.E_RESIZE_CURSOR)));
  rightPanel.addMouseMotionListener(new ResizeByWidthMouseMotionListener());
  JLabel downArrow = componentsFactory.getIconLabel("app/expand-mp.png", 16); //todo
  JPanel downPanel = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.CENTER));
  downPanel.setBorder(BorderFactory.createEmptyBorder(-10, 0, 0, 0));
  downPanel.setBackground(AppThemeColor.FRAME);
  downPanel.add(downArrow);
  downPanel.addMouseListener(new ArrowMouseListener(downPanel, new Cursor(Cursor.N_RESIZE_CURSOR)));
  downPanel.addMouseMotionListener(new ResizeByHeightMouseMotionListener());
  root.add(rightPanel, BorderLayout.LINE_END);
  root.add(downPanel, BorderLayout.PAGE_END);
}

代码示例来源:origin: stackoverflow.com

public void handleDrag(final JPanel panel){
  panel.addMouseListener(new MouseAdapter() {
    @Override
    public void mousePressed(MouseEvent me) {
       x = me.getX();
       y = me.getY();
    }
  });
  panel.addMouseMotionListener(new MouseMotionAdapter() {
    @Override
    public void mouseDragged(MouseEvent me) {
      me.translatePoint(me.getComponent().getLocation().x-x, me.getComponent().getLocation().y-y);
      panel.setLocation(me.getX(), me.getY());
    }
  });
}

代码示例来源:origin: com.metsci.glimpse/glimpse-docking

public SplitPane( boolean arrangeVertically, double splitFrac, int gapSize )
{
  super( null );
  this.arrangeVertically = arrangeVertically;
  this.gapSize = gapSize;
  this.childA = null;
  this.childB = null;
  this.splitFrac = splitFrac;
  this.divider = new JPanel( );
  divider.setOpaque( false );
  divider.setCursor( getPredefinedCursor( arrangeVertically ? S_RESIZE_CURSOR : E_RESIZE_CURSOR ) );
  add( divider );
  SplitLayout layout = new SplitLayout( );
  setLayout( layout );
  MouseAdapter mouseAdapter = createMouseAdapter( layout );
  divider.addMouseListener( mouseAdapter );
  divider.addMouseMotionListener( mouseAdapter );
  this.listeners = new LinkedHashSet<>( );
}

代码示例来源:origin: com.github.tornaia/aott-desktop-client-core

private void initGestures(JPanel jPanel, Chart<? extends Styler, ? extends Series> chart) {
    ToolTips toolTips = chart.getToolTips();
    if (toolTips != null) {
      MouseMotionListener mml = toolTips.getMouseMotionListener();
      if (mml != null) {
        jPanel.addMouseMotionListener(mml);
        jPanel.addMouseListener(new MouseAdapter() {
          @Override
          public void mouseExited(MouseEvent e) {
            toolTips.getMouseMotionListener().mouseMoved(e);
          }
        });
      }
    }
  }
}

代码示例来源:origin: com.github.tornaia/aott-desktop-client-core

private void initGestures(JPanel jPanel, Chart<? extends Styler, ? extends Series> chart) {
    ToolTips toolTips = chart.getToolTips();
    if (toolTips != null) {
      MouseMotionListener mml = toolTips.getMouseMotionListener();
      if (mml != null) {
        jPanel.addMouseMotionListener(mml);
        jPanel.addMouseListener(new MouseAdapter() {
          @Override
          public void mouseExited(MouseEvent e) {
            toolTips.getMouseMotionListener().mouseMoved(e);
          }
        });
      }
    }
  }
}

代码示例来源:origin: com.github.tornaia/aott-desktop-client-core

private void initGestures(JPanel jPanel, Chart<? extends Styler, ? extends Series> chart) {
    ToolTips toolTips = chart.getToolTips();
    if (toolTips != null) {
      MouseMotionListener mml = toolTips.getMouseMotionListener();
      if (mml != null) {
        jPanel.addMouseMotionListener(mml);
        jPanel.addMouseListener(new MouseAdapter() {
          @Override
          public void mouseExited(MouseEvent e) {
            toolTips.getMouseMotionListener().mouseMoved(e);
          }
        });
      }
    }
  }
}

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

public ZoomPane(boolean enableScrolling) {
  super();
  mouseListeners = new LinkedList<MouseListener>();
  mouseMotionListeners = new LinkedList<MouseMotionListener>();
  scale = 1;
  inheritListeners();
  setLayout(new BorderLayout());
  internal.addMouseListener(this);
  internal.addMouseMotionListener(this);
  port = new GrabbableViewport();
  port.setView(internal);
  if (enableScrolling) {
    scrollPane = new JScrollPane();
    scrollPane.setViewport(port);
    scrollPane.setDoubleBuffered(true);
    scrollPane.getVerticalScrollBar().setUnitIncrement(30);
    add(scrollPane, BorderLayout.CENTER);
  } else {
    add(internal, BorderLayout.CENTER);
  }
  root = this;
}

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

private JPanel setUpMoveListeners(JPanel panel) {
  panel.addMouseMotionListener(new DraggedFrameMotionListener());
  panel.addMouseListener(new DraggedFrameMouseListener());
  if (this.enableMouseOverBorder) {
    panel.addMouseListener(new MouseAdapter() {
      @Override
      public void mouseEntered(MouseEvent e) {
        panel.setCursor(new Cursor(Cursor.MOVE_CURSOR));
        getRootPane().setBorder(BorderFactory.createLineBorder(AppThemeColor.TEXT_MESSAGE, 1));
      }
      @Override
      public void mouseExited(MouseEvent e) {
        panel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        if (!AbstractMovableComponentFrame.this.getBounds().contains(e.getPoint())) {
          getRootPane().setBorder(BorderFactory.createLineBorder(AppThemeColor.BORDER, 1));
        }
      }
    });
  }
  return panel;
}

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

/**
 * When Toolbar is floatable, ToolbarBump is added as Grip as first toolbar component
 * modified by Michael Wever, to use l&f's grip/bump. */
void addGrip () {
  if (floatable) {
    /** Uses L&F's grip **/
    String lAndF = UIManager.getLookAndFeel().getName();
    //XXX should use getID() note getName() - Tim
    JPanel dragarea = lAndF.equals("Windows") ? isXPTheme() ?
                (JPanel)new ToolbarXP() : 
                (JPanel) new ToolbarGrip() :
                UIManager.getLookAndFeel().getID().equals("Aqua")
                ? (JPanel) new ToolbarAqua() :
                (JPanel)new ToolbarBump(); //NOI18N
    if (mouseListener == null)
      mouseListener = new ToolbarMouseListener ();
    dragarea.addMouseListener (mouseListener);
    dragarea.addMouseMotionListener (mouseListener);
    dragarea.setName ("grip");
    add (dragarea);
  }
}

代码示例来源:origin: org.softsmithy.lib/lib-core

/**
  * Sets the state manager.
  * @param manager the state manager
  */
protected void setStateManager(StateManager manager){
 if (stateManager != null){
  glassPane.removeMouseListener(stateManager);
  glassPane.removeMouseMotionListener(stateManager);
  removeFocusListener(stateManager);
  stateManager.unconfigureCustomizer();
 }
 stateManager = manager;
 glassPane.addMouseListener(stateManager);
 glassPane.addMouseMotionListener(stateManager);
 addFocusListener(stateManager);
 stateManager.configureCustomizer();
}

相关文章

JPanel类方法