javax.swing.event.MouseInputAdapter Java Examples

The following examples show how to use javax.swing.event.MouseInputAdapter. 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 File: DiagramCanvas.java    From snap-desktop with 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 #2
Source File: TransitionView.java    From PIPE with 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 #3
Source File: EditorPane.java    From SikuliX1 with 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 #4
Source File: DataToolPropsTable.java    From osp with 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 #5
Source File: AnnotationView.java    From PIPE with 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 #6
Source File: AnnotationView.java    From PIPE with 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 #7
Source File: ArcView.java    From PIPE with 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 #8
Source File: LuceneDataStoreSearchGUI.java    From gate-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
@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 #9
Source File: LuceneDataStoreSearchGUI.java    From gate-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
@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
Source File: TransitionView.java    From PIPE with 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 #11
Source File: NormalArcView.java    From PIPE with 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 #12
Source File: ImageViewer.java    From easyCV with 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 #13
Source File: ImageViewer.java    From easyCV with 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 #14
Source File: PlaceView.java    From PIPE with 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 #15
Source File: MessageBox.java    From xdm with 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 #16
Source File: Page.java    From xdm with 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 #17
Source File: SettingsPage.java    From xdm with 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 #18
Source File: ArcView.java    From PIPE with MIT License 4 votes vote down vote up
/**
 * Register the mouse handler to this view
 * @param arcHandler handler to determine what the arc does on mouse events
 */
public final void setMouseListener(MouseInputAdapter arcHandler) {
    addMouseListener(arcHandler);
    addMouseWheelListener(arcHandler);
    addMouseMotionListener(arcHandler);
}
 
Example #19
Source File: PetriNetTab.java    From PIPE with MIT License 4 votes vote down vote up
/**
 *
 * @param handler specifies how the canvas should behave to mouse events
 */
public void setMouseHandler(MouseInputAdapter handler) {
    addMouseListener(handler);
    addMouseMotionListener(handler);
    addMouseWheelListener(handler);
}
 
Example #20
Source File: AquaInternalFrameUI.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
protected MouseInputAdapter createBorderListener(final JInternalFrame w) {
    return new AquaBorderListener();
}
 
Example #21
Source File: AquaInternalFrameUI.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
protected MouseInputAdapter createBorderListener(final JInternalFrame w) {
    return new AquaBorderListener();
}
 
Example #22
Source File: AquaInternalFrameUI.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
protected MouseInputAdapter createBorderListener(final JInternalFrame w) {
    return new AquaBorderListener();
}
 
Example #23
Source File: MTransferableLabel.java    From javamelody with Apache License 2.0 4 votes vote down vote up
private void init() {
	setTransferHandler(new FileTransfer());
	final MouseInputAdapter mouseHandler = new MouseHandler();
	addMouseMotionListener(mouseHandler);
	addMouseListener(mouseHandler);
}
 
Example #24
Source File: AquaInternalFrameUI.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
protected MouseInputAdapter createBorderListener(final JInternalFrame w) {
    return new AquaBorderListener();
}
 
Example #25
Source File: AquaInternalFrameUI.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
protected MouseInputAdapter createBorderListener(final JInternalFrame w) {
    return new AquaBorderListener();
}
 
Example #26
Source File: GameOfLifeEntity.java    From qupla with 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 #27
Source File: AquaInternalFrameUI.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
protected MouseInputAdapter createBorderListener(final JInternalFrame w) {
    return new AquaBorderListener();
}
 
Example #28
Source File: AquaInternalFrameUI.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
protected MouseInputAdapter createBorderListener(final JInternalFrame w) {
    return new AquaBorderListener();
}
 
Example #29
Source File: LuceneDataStoreSearchGUI.java    From gate-core with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public MouseInputAdapter createListener(String... parameters) {
  return new TextMouseListener(parameters[0]);
}
 
Example #30
Source File: AquaInternalFrameUI.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
protected MouseInputAdapter createBorderListener(final JInternalFrame w) {
    return new AquaBorderListener();
}