javax.swing.JFrame.addMouseListener()方法的使用及代码示例

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

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

JFrame.addMouseListener介绍

暂无

代码示例

代码示例来源:origin: kevin-wayne/algs4

/**
 * Adds a {@link DrawListener} to listen to keyboard and mouse events.
 *
 * @param listener the {\tt DrawListener} argument
 */
public void addListener(DrawListener listener) {
  // ensure there is a window for listenting to events
  show();
  listeners.add(listener);
  frame.addKeyListener(this);
  frame.addMouseListener(this);
  frame.addMouseMotionListener(this);
  frame.setFocusable(true); 
}

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

MouseAdapter adapter = ...
JFrame frame = ...
frame.addMouseListener(adapter);
frame.addMouseMotionListener(adapter);

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

window.setVisible(true);
window.addMouseListener(new MouseListener() {
  @Override
  public void mouseReleased(MouseEvent e) {

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

window.setResizable(false);
window.addMouseListener(new MouseListener()

代码示例来源:origin: RaiMan/SikuliX2

box.addMouseListener(new MouseAdapter() {
 @Override
 public void mouseReleased(MouseEvent e) {

代码示例来源:origin: RaiMan/SikuliX2

frame.setAlwaysOnTop(true);
frame.addMouseListener(new MouseInputAdapter() {
 @Override
 public void mousePressed(MouseEvent e) {

代码示例来源:origin: klamonte/jexer

/**
 * Adds the specified mouse listener to receive mouse events from this
 * component. If listener l is null, no exception is thrown and no action
 * is performed.
 *
 * @param l the mouse listener
 */
public void addMouseListener(MouseListener l) {
  if (frame != null) {
    frame.addMouseListener(l);
  } else {
    component.addMouseListener(l);
  }
}

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

public void setup() {
  JFrame frame = new JFrame();
  frame.setSize(500, 500);
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.setLocation(0, 0);
  frame.setTitle("Circles");
  JPanel p = new MouseHandler();
  frame.add(p);
  frame.addMouseListener(p);
  frame.addMouseMotionListener(p);
  frame.setVisible(true);
}

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

public void setup() {
  JFrame frame = new JFrame();
  frame.setSize(500, 500);
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.setLocation(0, 0);
  frame.setTitle("Circles");
  frame.add(new MouseHandler());// your panel
  frame.addMouseListener(new MouseHandler()); // your listener, also a panel, but not the one you added to your frame
  frame.addMouseMotionListener(new MouseHandler()); // yet another listener, also not the panel you added to your frame
  frame.setVisible(true);
}

代码示例来源:origin: martin-lizner/trezor-ssh-agent

private void addAbilityToMoveWindow(final JFrame f) {
  f.addMouseListener(new MouseListener() {
    @Override
    public void mouseReleased(MouseEvent e) {

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

public static void main(String[] args) {
  final JFrame f = new JFrame("foo");
  f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  final JPanel c = new JPanel(null);
  f.setContentPane(c);
  c.setPreferredSize(new Dimension(500, 500));
  final JPanel a = new JPanel();
  a.setBounds(0, 0, 300, 300);
  a.setBackground(Color.red);
  c.add(a);
  final JPanel b = new JPanel();
  b.setBounds(200, 200, 300, 300);
  b.setBackground(Color.green);
  c.add(b);
  c.setComponentZOrder(a, 0);
  f.pack();
  f.setVisible(true);
  f.addMouseListener(new MouseAdapter() {
    @Override
    public void mouseClicked(MouseEvent e) {
      c.repaint();
    }
  });
}

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

public class TransparentFrame {
 private static final float OPAQUE = 1.0f;
 private static final float TRANSLUCENT = 0.1f;

 public static void main(String[] args) {
  final JFrame frame = new JFrame();
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.setSize(600, 400);
  frame.addMouseListener(new MouseAdapter() {
   @Override
   public void mouseEntered(MouseEvent e) {
    com.sun.awt.AWTUtilities.setWindowOpacity(frame, OPAQUE);
   }

   @Override
   public void mouseExited(MouseEvent e) {
    com.sun.awt.AWTUtilities.setWindowOpacity(frame, TRANSLUCENT);
   }
  });
  frame.setVisible(true);
 }
}

代码示例来源:origin: org.jbehave.web/jbehave-web-selenium

frame.addMouseListener(mia);
frame.addMouseMotionListener(mia);

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

JFrame t = new JFrame();
t.setSize(500, 500);
t.addMouseListener(new IH());
t.show();

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

main.setVisible(true);
main.setSize(800, 500);
main.addMouseListener(new MouseListener() {

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

frame.setLocationRelativeTo(null);
frame.addMouseListener(new MouseAdapter() {

代码示例来源:origin: com.googlecode.princeton-java-introduction/stdlib

/*************************************************************************
*  Event-based interactions.
*************************************************************************/
public void addListener(DrawListener listener) {
  // ensure there is a window for listenting to events
  show();
  listeners.add(listener);
  frame.addKeyListener(this);
  frame.addMouseListener(this);
  frame.addMouseMotionListener(this);
  frame.setFocusable(true); 
}

代码示例来源:origin: com.github.fracpete/princeton-java-stdlib

/*************************************************************************
*  Event-based interactions.
*************************************************************************/
public void addListener(DrawListener listener) {
  // ensure there is a window for listenting to events
  show();
  listeners.add(listener);
  frame.addKeyListener(this);
  frame.addMouseListener(this);
  frame.addMouseMotionListener(this);
  frame.setFocusable(true); 
}

代码示例来源:origin: brianway/algorithms-learning

/**
 * Adds a {@link DrawListener} to listen to keyboard and mouse events.
 *
 * @param listener the {\tt DrawListener} argument
 */
public void addListener(DrawListener listener) {
  // ensure there is a window for listenting to events
  show();
  listeners.add(listener);
  frame.addKeyListener(this);
  frame.addMouseListener(this);
  frame.addMouseMotionListener(this);
  frame.setFocusable(true);
}

代码示例来源:origin: edu.princeton.cs/algs4

/**
 * Adds a {@link DrawListener} to listen to keyboard and mouse events.
 *
 * @param listener the {\tt DrawListener} argument
 */
public void addListener(DrawListener listener) {
  // ensure there is a window for listenting to events
  show();
  listeners.add(listener);
  frame.addKeyListener(this);
  frame.addMouseListener(this);
  frame.addMouseMotionListener(this);
  frame.setFocusable(true); 
}

相关文章

JFrame类方法