Java Code Examples for javax.swing.event.MouseInputAdapter

The following examples show how to use javax.swing.event.MouseInputAdapter. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: SikuliX1   Source File: EditorPane.java    License: MIT License 6 votes vote down vote up
EditorPane() {
  showThumbs = !PreferencesUser.get().getPrefMorePlainText();
  addMouseListener(new MouseInputAdapter() {
    @Override
    public void mouseClicked(MouseEvent e) {
      if (e.getButton() == MouseEvent.BUTTON3) {
        new Thread(new Runnable() {
          @Override
          public void run() {
            handlePopup();
          }
        }).start();
      }
      super.mouseClicked(e);
    }
  });
  scrollPane = new JScrollPane(this);
  editorPaneID = new Date().getTime();
  editorPane = this;
  log(lvl, "created %d", editorPaneID);
}
 
Example 2
Source Project: snap-desktop   Source File: DiagramCanvas.java    License: GNU General Public License v3.0 6 votes vote down vote up
public DiagramCanvas() {
    setName("diagram");
    diagramChangeHandler = new DiagramChangeHandler();
    addComponentListener(new ComponentAdapter() {
        /**
         * Invoked when the component's size changes.
         */
        @Override
        public void componentResized(ComponentEvent e) {
            if (diagram != null) {
                diagram.invalidate();
            }
        }
    });
    MouseInputAdapter mouseHandler = new IndicatorHandler();
    addMouseListener(mouseHandler);
    addMouseMotionListener(mouseHandler);
    setPreferredSize(new Dimension(320, 200));
}
 
Example 3
Source Project: PIPE   Source File: TransitionView.java    License: MIT License 6 votes vote down vote up
/**
 * Constructor
 *
 * @param model             underlying transition model
 * @param controller        Petri net controller of the Petri net the transition is housed in
 * @param parent            parent of the view
 * @param transitionHandler mouse listener actions for the transition when in edit mode
 * @param animationHandler  mouse listener actions for the transition when in animation mode
 */
public TransitionView(Transition model, PetriNetController controller, Container parent,
                      MouseInputAdapter transitionHandler, MouseListener animationHandler) {
    super(model.getId(), model, controller, controller.getTransitionController(model), parent,
            new Rectangle2D.Double(-model.getWidth()/2, -model.getHeight()/2, model.getWidth(), model.getHeight()));
    unrotated = new Rectangle2D.Double(-model.getWidth()/2, -model.getHeight()/2, model.getWidth(), model.getHeight());
    setChangeListener();

    highlighted = false;

    rotate(model.getAngle());
    //TODO: DEBUG WHY CANT CALL THIS IN CONSTRUCTOR
    //        changeToolTipText();

    setMouseListener(transitionHandler, animationHandler);

}
 
Example 4
Source Project: xdm   Source File: SettingsPage.java    License: GNU General Public License v2.0 5 votes vote down vote up
public SettingsPage() {
	setOpaque(false);
	setLayout(null);
	bgColor = new Color(0, 0, 0, Config.getInstance().isNoTransparency() ? 255 : 200);
	MouseInputAdapter ma = new MouseInputAdapter() {
	};

	addMouseListener(ma);
	addMouseMotionListener(ma);

	jsp = new JScrollPane();
	jsp.setOpaque(false);
	jsp.setBorder(null);
	jsp.getViewport().setOpaque(false);

	DarkScrollBar scrollBar = new DarkScrollBar(JScrollBar.VERTICAL);
	jsp.setVerticalScrollBar(scrollBar);
	jsp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
	jsp.getVerticalScrollBar().setUnitIncrement(getScaledInt(10));
	jsp.getVerticalScrollBar().setBlockIncrement(getScaledInt(25));

	add(jsp);

	registerMouseListener();

	init();

	pageStack = new ArrayList<JPanel>();
}
 
Example 5
Source Project: xdm   Source File: Page.java    License: GNU General Public License v2.0 5 votes vote down vote up
public Page(String title, int width, XDMFrame parent) {
	setOpaque(false);
	setLayout(null);
	this.title = title;
	this.width = width;
	this.parent = parent;
	bgColor = new Color(0, 0, 0, Config.getInstance().isNoTransparency()?255:200);
	MouseInputAdapter ma = new MouseInputAdapter() {
	};

	addMouseListener(ma);
	addMouseMotionListener(ma);

	jsp = new JScrollPane();
	jsp.setOpaque(false);
	jsp.setBorder(null);
	jsp.getViewport().setOpaque(false);

	DarkScrollBar scrollBar = new DarkScrollBar(JScrollBar.VERTICAL);
	jsp.setVerticalScrollBar(scrollBar);
	jsp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
	jsp.getVerticalScrollBar().setUnitIncrement(getScaledInt(10));
	jsp.getVerticalScrollBar().setBlockIncrement(getScaledInt(25));

	add(jsp);

	registerMouseListener();

	init();

}
 
Example 6
Source Project: xdm   Source File: MessageBox.java    License: GNU General Public License v2.0 5 votes vote down vote up
private MessageBox() {
	setLayout(null);
	MouseInputAdapter ma = new MouseInputAdapter() {
	};
	addMouseListener(ma);
	addMouseMotionListener(ma);
	init();
}
 
Example 7
Source Project: easyCV   Source File: ImageViewer.java    License: Apache License 2.0 5 votes vote down vote up
private void initMenu() {
	//菜单栏
	JMenuBar bar = new JMenuBar();
	//主菜单
	JMenu menu=new JMenu("打开");
	menu.addMouseListener(new MouseInputAdapter() {
		@Override
		public void mouseClicked(MouseEvent e) {
			showDialog();
		}
	});
	bar.add(menu);
	setJMenuBar(bar);
}
 
Example 8
Source Project: easyCV   Source File: ImageViewer.java    License: Apache License 2.0 5 votes vote down vote up
private Component getNamePwdPandel() {
	JPanel panel = new JPanel();
	panel.setLayout(new FlowLayout(FlowLayout.LEFT));
	JLabel jlabel = new JLabel("输入网络视频源URL");
	JTextField srcText = new JTextField(30);
	JButton button=new JButton("播放");
	button.addMouseListener(new MouseInputAdapter() {
		@Override
		public void mouseClicked(MouseEvent e) {
			String src=srcText.getText();
			if(src!=null&&src.length()>0&&!"".equals(src.trim())) {
				dialog.setVisible(false);
				setVisible(true);
				grabber.setUrl(src);
				try {
					grabber.grabBuffer();
				} catch (IOException e1) {
					
				}
						
			}
		}
	});
	panel.add(jlabel);
	panel.add(srcText);
	panel.add(button);
	return panel;
}
 
Example 9
@Override
public MouseInputAdapter createListener(String... parameters) {
  switch(parameters.length) {
    case 3:
      return new AnnotationMouseListener(parameters[1]);
    case 5:
      return new AnnotationMouseListener(parameters[1], parameters[2],
              parameters[3]);
    default:
      return null;
  }
}
 
Example 10
@Override
public MouseInputAdapter createListener(String... parameters) {
  switch(parameters.length) {
    case 1:
      return new HeaderMouseListener(parameters[0]);
    case 2:
      return new HeaderMouseListener(parameters[0], parameters[1]);
    default:
      return null;
  }
}
 
Example 11
Source Project: PIPE   Source File: AnnotationView.java    License: MIT License 5 votes vote down vote up
/**
 * Constructor
 * @param annotation underlying annotation model
 * @param controller Petri net controller for the Petri net the annotation belongs to
 * @param parent parent container of this view
 * @param handler how the annotation will handle mouse events
 */
public AnnotationView(Annotation annotation, PetriNetController controller, Container parent, MouseInputAdapter handler) {
    super(annotation, controller, parent);
    addChangeListener(annotation);
    setDragPoints();
    setMouseHandler(handler);
    updateBounds();
}
 
Example 12
Source Project: PIPE   Source File: AnnotationView.java    License: MIT License 5 votes vote down vote up
/**
 * Registers the handler to this view
 * @param handler how the annotation will handle mouse events
 */
private void setMouseHandler(MouseInputAdapter handler) {
    addMouseListener(handler);
    addMouseMotionListener(handler);
    noteText.addMouseListener(handler);
    noteText.addMouseMotionListener(handler);
}
 
Example 13
Source Project: PIPE   Source File: ArcView.java    License: MIT License 5 votes vote down vote up
public ArcView(Arc<S, T> model, PetriNetController controller, Container parent,
               MouseInputAdapter arcHandler,
               PipeApplicationModel applicationModel) {
    super(model.getId(), model, controller, parent);
    arcPath = new ArcPath(this, controller, applicationModel);

    updatePath();
    updateBounds();
    registerModelListeners();
    setMouseListener(arcHandler);
}
 
Example 14
Source Project: PIPE   Source File: TransitionView.java    License: MIT License 5 votes vote down vote up
/**
 * Register the mouse listeners to this view
 *
 * @param transitionHandler mouse listener actions for the transition when in edit mode
 * @param animationHandler  mouse listener actions for the transition when in animation mode
 */
private void setMouseListener(MouseInputAdapter transitionHandler, MouseListener animationHandler) {
    addMouseListener(transitionHandler);
    addMouseMotionListener(transitionHandler);
    addMouseWheelListener(transitionHandler);
    addMouseListener(animationHandler);
}
 
Example 15
Source Project: PIPE   Source File: NormalArcView.java    License: MIT License 5 votes vote down vote up
/**
 * Constructor
 * @param model underlying normal arc
 * @param controller Petri ent controller for the Petri net that houses the arc
 * @param parent view parent
 * @param handler mouse event handler
 * @param applicationModel PIPE main appliaction model
 */
public NormalArcView(Arc<S, T> model, PetriNetController controller, Container parent, MouseInputAdapter handler,
                     PipeApplicationModel applicationModel) {
    super(model, controller, parent, handler, applicationModel);
    addConnectableListener();
    addSourceTargetConnectableListener();
    for (TextLabel label : weightLabel) {
        getParent().add(label);
    }
    for (ArcPoint arcPoint : model.getArcPoints()) {
        arcPoint.addPropertyChangeListener(weightListener);
    }
}
 
Example 16
Source Project: PIPE   Source File: PlaceView.java    License: MIT License 5 votes vote down vote up
/**
 * Constructor
 * @param model underlying model
 * @param parent parent of the view
 * @param controller Petri net controller of the Petri net the model is housed in
 * @param placeHandler mouse input handler for describing how this view responds to mouse events
 */
public PlaceView(Place model, Container parent, PetriNetController controller, MouseInputAdapter placeHandler) {
    super(model.getId(), model, controller, controller.getPlaceController(model), parent, new Ellipse2D.Double(-model.getWidth()/2, -model.getHeight()/2, model.getWidth(), model.getHeight()));
    setChangeListener();
    setMouseListener(placeHandler);

    Rectangle bounds = shape.getBounds();
    Rectangle newBounds = new Rectangle((int)(model.getCentre().getX() + bounds.getX()), (int)(model.getCentre().getY() + bounds.getY()), (int) bounds.getWidth() + getComponentDrawOffset(), (int)bounds.getHeight() + getComponentDrawOffset());
    setBounds(newBounds);
}
 
Example 17
Source Project: osp   Source File: DataToolPropsTable.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Constructor.
 *
 * @param table the datatable
 */
public DataToolPropsTable(DataToolTable table) {
  dataTable = table;
  propsModel = new PropsTableModel();
  addMouseMotionListener(new MouseInputAdapter() {
    public void mouseMoved(MouseEvent e) {
      int col = columnAtPoint(e.getPoint());
      int labelCol = convertColumnIndexToView(0);
      int xCol = (labelCol==0) ? 1 : 0;
      int row = rowAtPoint(e.getPoint());
      if(col==labelCol || col==xCol || row==axisRow) {
        setToolTipText(null);
      }
      else {
       if(row==markerRow) {
         setToolTipText(ToolsRes.getString("DataToolPropsTable.Markers.Tooltip")); //$NON-NLS-1$
       } 
       else if(row==lineRow) {
         setToolTipText(ToolsRes.getString("DataToolPropsTable.Lines.Tooltip"));   //$NON-NLS-1$
       }
       else if(row==styleRow) {
         setToolTipText(ToolsRes.getString("DataToolPropsTable.Style.Tooltip"));   //$NON-NLS-1$
       }
      }
    }
  });
  init();
}
 
Example 18
protected MouseInputAdapter createBorderListener(final JInternalFrame w) {
    return new AquaBorderListener();
}
 
Example 19
protected MouseInputAdapter createBorderListener(final JInternalFrame w) {
    return new AquaBorderListener();
}
 
Example 20
Source Project: qupla   Source File: GameOfLifeEntity.java    License: Apache License 2.0 4 votes vote down vote up
public GameOfLifeEntity()
{
  super(0);

  final Dispatcher dispatcher = Dispatcher.getInstance();
  golGen = dispatcher.getEnvironment("GolGen", null);
  golHash = dispatcher.getEnvironment("GolHash", null);
  golIds = dispatcher.getEnvironment("GolIds", null);
  golSend = dispatcher.getEnvironment("GolSend", null);
  golView = dispatcher.getEnvironment("GolView", null);
  join(golView);

  gridImage = new BufferedImage(GRID_SIZE, GRID_SIZE, BufferedImage.TYPE_3BYTE_BGR);

  gridView = new JPanel();
  gridView.setPreferredSize(new Dimension(200, 200));
  gridView.setVisible(true);
  final MouseInputAdapter mouseAdapter = getMouseInputAdapter();
  gridView.addMouseListener(mouseAdapter);
  gridView.addMouseMotionListener(mouseAdapter);

  final JLabel label = new JLabel();
  label.setText("GoL ID:");

  entry = new JTextField();
  addChangeListener();

  final JPanel idPanel = new JPanel();
  idPanel.setLayout(new BoxLayout(idPanel, BoxLayout.X_AXIS));
  idPanel.add(label);
  idPanel.add(entry);

  frame = new JFrame("Game of Life");
  frame.addWindowListener(ViewEntity.windowAdapter);
  frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  frame.setLayout(new BorderLayout());
  frame.add(idPanel, BorderLayout.PAGE_START);
  frame.add(gridView, BorderLayout.CENTER);
  frame.addComponentListener(new ComponentAdapter()
  {
    public void componentResized(ComponentEvent evt)
    {
      drawGridImage();
    }
  });
  frame.setVisible(true);
  frame.setSize(400, 400);
}
 
Example 21
Source Project: jdk8u60   Source File: AquaInternalFrameUI.java    License: GNU General Public License v2.0 4 votes vote down vote up
protected MouseInputAdapter createBorderListener(final JInternalFrame w) {
    return new AquaBorderListener();
}
 
Example 22
protected MouseInputAdapter createBorderListener(final JInternalFrame w) {
    return new AquaBorderListener();
}
 
Example 23
@Override
public MouseInputAdapter createListener(String... parameters) {
  return new TextMouseListener(parameters[0]);
}
 
Example 24
protected MouseInputAdapter createBorderListener(final JInternalFrame w) {
    return new AquaBorderListener();
}
 
Example 25
@Override
protected MouseInputAdapter createBorderListener(final JInternalFrame w) {
    return new AquaBorderListener();
}
 
Example 26
protected MouseInputAdapter createBorderListener(final JInternalFrame w) {
    return new AquaBorderListener();
}
 
Example 27
Source Project: hottub   Source File: AquaInternalFrameUI.java    License: GNU General Public License v2.0 4 votes vote down vote up
protected MouseInputAdapter createBorderListener(final JInternalFrame w) {
    return new AquaBorderListener();
}
 
Example 28
protected MouseInputAdapter createBorderListener(final JInternalFrame w) {
    return new AquaBorderListener();
}
 
Example 29
protected MouseInputAdapter createBorderListener(final JInternalFrame w) {
    return new AquaBorderListener();
}
 
Example 30
protected MouseInputAdapter createBorderListener(final JInternalFrame w) {
    return new AquaBorderListener();
}