List of usage examples for java.awt.event MouseEvent BUTTON1
int BUTTON1
To view the source code for java.awt.event MouseEvent BUTTON1.
Click Source Link
From source file:edmondskarp.Gui.EdmondsKarpGui.java
private void myPanelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_myPanelMouseClicked if (evt.getButton() == MouseEvent.BUTTON1) { if (MODE == ERASE) { eraseShape(evt.getPoint());/*from w w w . ja va 2s . co m*/ } else if (MODE == DRAW) { if (isSecond) { Circle circ = getSelectedCircle(evt.getPoint()); if (circ != null && circ != shapeTmp) { addArrow(circ); shapeTmp.setSelect(false); isSecond = false; update(); return; } } else { Circle circ = getSelectedCircle(evt.getPoint()); if (circ != null) { shapeTmp = circ; shapeTmp.setSelect(true); isSecond = true; update(); return; } } if (getSelectedCircle(evt.getPoint()) == null && !isSecond) { addCircle(evt.getPoint()); } else { isSecond = false; shapeTmp.setSelect(false); update(); } } } else if (evt.getButton() == MouseEvent.BUTTON3) { if (getSelectedCircle(evt.getPoint()) != null) { pointTmp.setLocation(evt.getPoint().getX(), evt.getPoint().getY()); jPopupMenu1.show(myPanel, evt.getX(), evt.getY()); } else if (getSelectedArrow(evt.getPoint()) != null) { pointTmp.setLocation(evt.getPoint().getX(), evt.getPoint().getY()); jPopupMenu2.show(myPanel, evt.getX(), evt.getY()); } } }
From source file:GUI.MainWindow.java
private void VulnTreeMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_VulnTreeMouseClicked // Do nothing Object obj = VulnTree.getLastSelectedPathComponent(); if (obj == null) // No vulns selected so no interaction required {/*from www . j av a2 s . c o m*/ return; } if (evt.getButton() == MouseEvent.BUTTON3) { // At least one vuln was selected so we need to see how many and modify the context menu if (VulnTree.getSelectionCount() == 1) { // User cannot merge because they don't have two selected MergeButton.setEnabled(false); } else { MergeButton.setEnabled(true); } VulnTreeContextMenu.show(VulnTree, evt.getX(), evt.getY()); } else if (evt.getButton() == MouseEvent.BUTTON1 && evt.getClickCount() == 2) { showNotes(); } }
From source file:corelyzer.ui.CorelyzerGLCanvas.java
public void mousePressed(final MouseEvent e) { prePos = e.getPoint();//from w w w . ja v a 2 s . co m float sp[] = { 0.0f, 0.0f }; this.convertMousePointToSceneSpace(prePos, scenePos); PAN_MODE = 0; ZOOM_MODE = 0; MANIPULATE_MODE = 0; // For mouse right-click or Ctrl-Left-Click if (e.isPopupTrigger()) { this.handleRightMouseClick(e); return; } switch (e.getButton()) { case MouseEvent.BUTTON1: if (canvasMode == CorelyzerApp.APP_MEASURE_MODE) { return; } else if (canvasMode == CorelyzerApp.APP_MARKER_MODE) { // the first check up: focused marker manipulation if (SceneGraph.focusedMarker > -1) { if (SceneGraph.hitMarker(canvasId, scenePos[0], scenePos[1])) { MANIPULATE_MODE = 1; /* * System.out.println( * "---- Left button pressed down at: " + prePos.x + * ", " + prePos.y); System.out.println( * "Converted to Scene Space: " + scenePos[0] + ", " * + sp[1]); * System.out.println("Marker manipulator hit!"); */ prescenePos[0] = scenePos[0]; prescenePos[1] = scenePos[1]; return; } } } else if (canvasMode == CorelyzerApp.APP_CLAST_MODE || canvasMode == CorelyzerApp.APP_CUT_MODE) { determineSelectedSceneComponents(scenePos, e); if (selectedTrackSection != -1) { if (!SceneGraph.getDepthOrientation()) { float t = scenePos[0]; scenePos[0] = scenePos[1]; scenePos[1] = -t; } SceneGraph.addClastPoint1(scenePos[0], scenePos[1]); this.convertScenePointToAbsolute(scenePos, sp); CorelyzerApp.getApp().getToolFrame().setClastUpperLeft(sp); } PAN_MODE = 0; return; } PAN_MODE = 1; // System.out.println("---- Left button pressed down at: " + // prePos.x + ", " + prePos.y); // System.out.println("Converted to Scene Space: " + // scenePos[0] + ", " + sp[1]); determineSelectedSceneComponents(scenePos, e); break; case MouseEvent.BUTTON2: // System.out.println("MOUSE BUTTON 2!!!???"); break; case MouseEvent.BUTTON3: // System.out.println("---- Right button clicked at: " + // prePos.x + ", " + prePos.y); // System.out.println("Converted to Scene Space: " + // scenePos[0] + ", " + sp[1]); this.handleRightMouseClick(e); break; default: // more reliable than BUTTON3 (ctrl-click) if (e.isPopupTrigger()) { this.handleRightMouseClick(e); } } }
From source file:simMPLS.ui.simulator.JVentanaHija.java
/** * Este mtodo se llama cuando se libera un botn del ratn estando en el panel de * simulacin. Si se hace sobre un elemento que estaba seleccionado, deja de * estarlo./*w w w . ja v a2s . c o m*/ * When the mouse button is released on a node * @param evt El evento que genera la llamada. * @since 1.0 */ private void ratonSoltadoEnPanelSimulacion(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_ratonSoltadoEnPanelSimulacion if (evt.getButton() == MouseEvent.BUTTON1) { if (nodoSeleccionado != null) { nodoSeleccionado.setStatus(TNode.DESELECCIONADO); nodoSeleccionado = null; this.escenario.setModified(true); } panelSimulacion.repaint(); } }
From source file:simMPLS.ui.simulator.JVentanaHija.java
/** * Este mtodo se llama cuando se presiona un botn del ratn en el panel de * simulacin. Si se hace sobre un elemento de la topologa, lo marca como * seleccionado./*from www . j a va 2 s .c om*/ * When the mouse button is pressed on a node * @since 1.0 * @param evt El evento que provoca la llamada. */ private void clicEnPanelSimulacion(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_clicEnPanelSimulacion if (evt.getButton() == MouseEvent.BUTTON1) { TTopology topo = escenario.getTopology(); TTopologyElement et = topo.obtenerElementoEnPosicion(evt.getPoint()); if (et != null) { this.setCursor(new Cursor(Cursor.HAND_CURSOR)); if (et.getElementType() == TTopologyElement.NODO) { TNode nt = (TNode) et; nodoSeleccionado = nt; if (nodoSeleccionado != null) { nodoSeleccionado.setStatus(TNode.SELECCIONADO); this.escenario.setModified(true); } } } else { this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); this.setToolTipText(null); } panelSimulacion.repaint(); } }
From source file:corelyzer.ui.CorelyzerGLCanvas.java
public void mouseReleased(final MouseEvent e) { // For mouse right-click or Ctrl-Left-Click if (e.isPopupTrigger()) { this.handleRightMouseClick(e); return;/*from www. j a v a2s .com*/ } if (e.getButton() == MouseEvent.BUTTON1) { if (canvasMode == CorelyzerApp.APP_CLAST_MODE) { this.handleClastMouseReleased(e); } else if (canvasMode == CorelyzerApp.APP_CUT_MODE) { this.handleCutMouseReleased(e); } } prePos.setLocation(0, 0); canvas.setCursor(Cursor.getDefaultCursor()); CorelyzerApp.getApp().updateGLWindows(); }
From source file:com.igormaznitsa.jhexed.swing.editor.ui.MainForm.java
@Override public void mouseClicked(final MouseEvent e) { if (this.application != null) { if (e.getButton() == MouseEvent.BUTTON1) { final HexPosition hexNumber = this.hexMapPanel.getHexPosition(e.getPoint()); this.hexMapPanel.setToolTipText( this.application.processHexAction(this.hexMapPanel, e, HexAction.CLICK, hexNumber)); }//from w w w.j a va2s . c o m } else { switch (e.getButton()) { case MouseEvent.BUTTON1: { final HexPosition hexNumber = this.hexMapPanel.getHexPosition(e.getPoint()); useCurrentToolAtPosition(hexNumber); } break; } } }
From source file:com.puzzle.gui.MainFrame.java
public void trayIconMouseClick(MouseEvent e) { if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1)//? {//from w ww . j av a 2s .com this.setExtendedState(JFrame.NORMAL);//? this.setVisible(true);// } }
From source file:nosqltools.MainForm.java
public void connect() { String user;// w w w . j av a2s . c o m String pass; String dbname; String serveradd; int port; LoginDialog dlg_login = new LoginDialog(null); dlg_login.setVisible(true); //If user chose login and not cancel option on dialog box if (dlg_login.isToLogin()) { Text_MessageBar.setText(Initializations.DBATTEMPTING); Text_MessageBar.setForeground(Color.ORANGE); user = dlg_login.getUsername(); pass = dlg_login.getPassword(); dbname = dlg_login.getDatabase(); serveradd = dlg_login.getServerAddr(); port = dlg_login.getPort(); if (dbcon.connect(user, pass, dbname, serveradd, port)) { DefaultTreeModel defTableMod = dbcon.buildDBTree(); if (defTableMod != null && dbcon.isConnectionSuccess()) { jTree1.setModel(defTableMod); Text_MessageBar.setText(Initializations.DBCONNSUCCESS); Text_MessageBar.setForeground(Color.GREEN); Menu_Collections.setEnabled(true); //load the data of collection in panel_text on double click jTree1.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent me) { if (me.getButton() == MouseEvent.BUTTON1) { if (me.getClickCount() == 2) { //get the path of the mouse click ex:[localhost,test,testData] Op_Refresh.setEnabled(true); tp = jTree1.getPathForLocation(me.getX(), me.getY()); if (tp != null) { List<String> coll_db = dbcon.getAllCollections(); int cnt = tp.getPathCount(); for (int i = 0; i < cnt; i++) { //if one of the collection matches the coll that was clicked by the user load data if (coll_db.contains(tp.getPathComponent(i).toString())) { indexOfCurrentCollection = i; sb = dbcon.getCollectionData(tp.getPathComponent(i).toString()); if (sb != null) { Panel_Text.setVisible(true); JsonNode jNode1; try { jNode1 = mapper.readTree(sb.toString()); textArea.setText(mapper.writerWithDefaultPrettyPrinter() .writeValueAsString(jNode1)); } catch (IOException ex) { Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ex); } Text_MessageBar.setText(Initializations.INITSTRING); // textArea.setText(sb.toString()); validateDataPanel_text(sb); /* if (json_util.isValid(sb.toString())) { json_util.isDataParsed(textArea.getText()); Text_MessageBar.setText(Initializations.JSONFILESUCCESS); } else { sb.setLength(0); //JOptionPane.showMessageDialog(this, Initializations.JSONINCORRECTFORMAT , Initializations.VALIDATIONERROR , JOptionPane.ERROR_MESSAGE); try { Object obj = parser.parse(sb.toString()); } catch(org.json.simple.parser.ParseException pe) { Text_MessageBar.setText(Initializations.ERRORLINE + json_util.getLineNumber(pe.getPosition(), textArea.getText()) + " - " + pe); } } */ } else { Panel_Text.setVisible(false); Text_MessageBar.setText(Initializations.SYSTEMCOLL); Text_MessageBar.setForeground(Color.RED); } } } } } } } }); } else { jTree1.setModel(null); Text_MessageBar.setText(Initializations.DBCONNFAIL); Text_MessageBar.setForeground(Color.RED); } } else { jTree1.setModel(null); Text_MessageBar.setText(Initializations.DBCONNFAIL); Text_MessageBar.setForeground(Color.RED); } } else { jTree1.setModel(null); Text_MessageBar.setText(Initializations.DBCONNFAIL); Text_MessageBar.setForeground(Color.RED); } }
From source file:com.igormaznitsa.jhexed.swing.editor.ui.MainForm.java
@Override public void mousePressed(final MouseEvent e) { final boolean ctrlPressed = (e.getModifiersEx() & MouseEvent.CTRL_DOWN_MASK) != 0; if (this.application == null) { if (!ctrlPressed && e.isPopupTrigger()) { final HexPosition hexNumber = this.hexMapPanel.getHexPosition(e.getPoint()); onPopup(e.getPoint(), hexNumber); } else {/*from ww w.ja v a2 s . c o m*/ switch (e.getButton()) { case MouseEvent.BUTTON1: { if (selectedToolType != null && this.selectedLayer != null) { addedUndoStep(new HexFieldLayer[] { this.selectedLayer }); final HexPosition hexNumber = this.hexMapPanel.getHexPosition(e.getPoint()); useCurrentToolAtPosition(hexNumber); } } break; case MouseEvent.BUTTON3: { if (ctrlPressed) { this.dragging = true; this.hexMapPanelDesktop.initDrag(e.getPoint()); } } break; } } } else if (!ctrlPressed && e.isPopupTrigger() && this.application.allowPopupTrigger()) { this.application.processHexAction(this.hexMapPanel, e, HexAction.POPUP_TRIGGER, this.hexMapPanel.getHexPosition(e.getPoint())); } else if (e.getButton() == MouseEvent.BUTTON3) { this.dragging = true; this.hexMapPanelDesktop.initDrag(e.getPoint()); } }