Java Code Examples for java.awt.event.MouseEvent
The following code examples are extracted from open source projects. You can click to
vote up the examples that are useful to you.
Example 1
From project ceres, under directory /ceres-ui/src/test/java/com/bc/ceres/swing/figure/interactions/.
Source file: SelectionInteractionTest.java

private void click(Interactor sa,FigureEditor fe,int x,int y,int modifiers){ MouseEvent event; event=createEvent(fe,modifiers,x,y); sa.mousePressed(event); sa.mouseReleased(event); }
Example 2
From project des, under directory /daemon/lib/apache-log4j-1.2.16/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/.
Source file: CategoryImmediateEditor.java

public boolean shouldSelectCell(EventObject e){ boolean rv=false; if (e instanceof MouseEvent) { MouseEvent me=(MouseEvent)e; TreePath path=tree.getPathForLocation(me.getX(),me.getY()); CategoryNode node=(CategoryNode)path.getLastPathComponent(); rv=node.isLeaf(); } return rv; }
Example 3
From project codjo-data-process, under directory /codjo-data-process-common/src/main/java/net/codjo/dataprocess/common/eventsbinder/annotations/managers/.
Source file: OnMouseAnnotationManager.java

public boolean checkEvent(EventObject eventObject,String methodCalled){ boolean methodOk=false; boolean popupOk=false; boolean buttonOk=false; boolean clickCountOk=false; boolean modifiersOk=false; MouseEvent event=(MouseEvent)eventObject; if (onMouse.popupTriggered() == OnMouse.PopupType.ALL) { popupOk=true; } if (onMouse.popupTriggered() == OnMouse.PopupType.TRUE && event.isPopupTrigger()) { popupOk=true; } if (onMouse.popupTriggered() == OnMouse.PopupType.FALSE && !event.isPopupTrigger()) { popupOk=true; } if (onMouse.button() == -1 || onMouse.button() == event.getButton()) { buttonOk=true; } if (onMouse.clickCount() == -1 || onMouse.clickCount() == event.getClickCount()) { clickCountOk=true; } if (onMouse.modifiers() == -1 || onMouse.modifiers() == event.getModifiers()) { modifiersOk=true; } methodOk=checkMethodCalled(methodOk,methodCalled); return popupOk && buttonOk && clickCountOk&& modifiersOk&& methodOk; }
Example 4
From project addis, under directory /application/src/main/java/org/drugis/addis/gui/builder/.
Source file: LyndOBrienView.java

public void mouseDragged(MouseEvent e){ Point point=e.getPoint(); Point2D.Double chartXY=convertToChartCoordinates(point); if ((chartXY.x > 0 && chartXY.y > 0) || (chartXY.x < 0 && chartXY.y < 0)) { double mu=chartXY.y / chartXY.x; drawMuLine(getChart().getXYPlot(),mu); } }
Example 5
From project 3Dto2DApplet, under directory /src/java/nl/dannyarends/eventHandling/.
Source file: MouseHandler.java

public void mouseDragged(MouseEvent e){ int new_mx=e.getX(); int new_my=e.getY(); if (dragging) { if (p.getSliderinputlistener() != null) { if (!p.getSliderinputlistener().onSlide(mx,my)) p.setSliderinputlistener(null); } else { scene.getCamera().setHorRotation((int)(scene.getCamera().getRotation()[0] - (new_mx - mx))); scene.getCamera().setVertRotation((int)(scene.getCamera().getRotation()[1] + (new_my - my))); } mx=new_mx; my=new_my; scene.update(); e.consume(); } else { Object3D o=scene.rayTrace(new_mx,new_my); if (o != null) { } scene.update(); } }
Example 6
private void DisarmTerritoryHandler(MouseEvent e){ TerritoryInfo ti=findTerritory(e.getPoint()); if (ti == null && !node.getMyFamilyInfo().getConquerTerritories().contains(ti.getName())) { return; } new DisarmamentDialog(node,e.getLocationOnScreen(),ti); }
Example 7
@Override public void mouseDragged(MouseEvent e){ int x=e.getX(), y=e.getY(); at.preConcatenate(AffineTransform.getTranslateInstance(x - mouseX,y - mouseY)); mouseX=x; mouseY=y; }
Example 8
From project Android-DB-Editor, under directory /src/com/troido/dbeditor/.
Source file: TreeMouseListener.java

@Override public void mouseClicked(MouseEvent e){ if (e.getClickCount() == 2) { JTree tree=(JTree)e.getSource(); DefaultMutableTreeNode dmt=(DefaultMutableTreeNode)tree.getLastSelectedPathComponent(); Object obj=dmt.getUserObject(); if (obj instanceof Database) { File dbFile=ADBConnector.getDatabase((Database)obj); String cmdLine[]={sqlitepath,dbFile.getPath()}; try { Runtime.getRuntime().exec(cmdLine); new DBChangeListener((Database)obj,dbFile); } catch ( Exception exc) { exc.printStackTrace(); } } } }
Example 9
From project ardverk-dht, under directory /components/tools/src/main/java/org/ardverk/dht/ui/.
Source file: PainterPanel.java

public PainterPanel(DHT dht){ this.dht=dht; Contact localhost=dht.getIdentity(); KUID localhostId=localhost.getId(); painters.add(new JuicePainter(localhostId)); painters.add(new SquashPainter(localhostId)); addMouseListener(new MouseAdapter(){ @Override public void mouseClicked( MouseEvent e){ if (!painters.isEmpty()) { current=(current + 1) % painters.size(); repaint(); } } } ); }
Example 10
From project autopsy, under directory /KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/.
Source file: KeywordSearchPanel.java

private void maybeShowSettingsPopup(MouseEvent evt){ if (!active) { return; } if (evt != null && !SwingUtilities.isLeftMouseButton(evt)) { return; } settingsMenu.show(searchBoxPanel,0,searchBoxPanel.getHeight()); }
Example 11
From project BDSup2Sub, under directory /src/main/java/bdsup2sub/gui/main/.
Source file: ZoomableGraphicsPanel.java

@Override public void mouseClicked(MouseEvent event){ int s=zoomScale; if (event.getButton() == MouseEvent.BUTTON1) { if (s < 8) { s++; } } else { if (s > 1) { s--; } } if (s != zoomScale) { setZoomScale(s); } }
Example 12
From project beanmill_1, under directory /src/main/java/com/traxel/lumbermill/desk/.
Source file: MillFrameControl.java

@Override public void mouseClicked(final MouseEvent e){ if (MouseEvent.BUTTON3 == e.getButton()) { final String newTitle=getTitle(); if ((newTitle != null) && !"".equals(newTitle)) { frame.setTitle(newTitle); } } }
Example 13
public void mouseClicked(MouseEvent e){ if (currentButton != null) currentButton.setForeground(Color.DARK_GRAY); currentButton=(JButton)e.getComponent(); currentButton.setForeground(selectedColor); CardLayout cl=(CardLayout)subPanel.getLayout(); cl.show(subPanel,currentButton.getText()); subPanel.validate(); }
Example 14
From project BMach, under directory /src/jsyntaxpane/components/.
Source file: LineNumbersRuler.java

@Override public void install(final JEditorPane editor){ this.editor=editor; setFont(editor.getFont()); editor.getDocument().addDocumentListener(this); editor.addCaretListener(this); editor.addPropertyChangeListener(this); JScrollPane sp=getScrollPane(editor); sp.setRowHeaderView(this); mouseListener=new MouseAdapter(){ @Override public void mouseClicked( MouseEvent e){ GotoLineDialog.showForEditor(editor); } } ; addMouseListener(mouseListener); status=Status.INSTALLING; }
Example 15
From project Briss, under directory /src/main/java/at/laborg/briss/gui/.
Source file: MergedPanel.java

@Override public void mouseReleased(MouseEvent mE){ if (mE.isPopupTrigger()) { showPopUpMenu(mE); } clipCropsToVisibleArea(); removeToSmallCrops(); updateClusterRatios(crops); actionState=ActionState.NOTHING; cropStartPoint=null; lastDragPoint=null; curCrop=null; repaint(); }
Example 16
From project CBCJVM, under directory /cbc/CBCJVM/src/cbccore/low/simulator/.
Source file: SimulatedInput.java

private void mouseEventHandler(MouseEvent e,boolean setTo){ String et=((Button)e.getSource()).getLabel(); if (et.equals("u")) { _inputHandler.u=setTo; return; } if (et.equals("d")) { _inputHandler.d=setTo; return; } if (et.equals("l")) { _inputHandler.l=setTo; return; } if (et.equals("r")) { _inputHandler.r=setTo; return; } if (et.equals("a")) { _inputHandler.a=setTo; return; } if (et.equals("b")) { _inputHandler.b=setTo; return; } if (et.equals("bl")) { _inputHandler.bl=setTo; return; } }
Example 17
/** * Creates a new controller tied to the specified display and gui frame. * @param parent the frame for the world window * @param disp the panel that displays the grid * @param displayMap the map for occupant displays * @param res the resource bundle for message display */ public GUIController(WorldFrame<T> parent,GridPanel disp,DisplayMap displayMap,ResourceBundle res){ resources=res; display=disp; parentFrame=parent; this.displayMap=displayMap; makeControls(); occupantClasses=new TreeSet<Class>(new Comparator<Class>(){ public int compare( Class a, Class b){ return a.getName().compareTo(b.getName()); } } ); World<T> world=parentFrame.getWorld(); Grid<T> gr=world.getGrid(); for ( Location loc : gr.getOccupiedLocations()) addOccupant(gr.get(loc)); for ( String name : world.getOccupantClasses()) try { occupantClasses.add(Class.forName(name)); } catch ( Exception ex) { ex.printStackTrace(); } timer=new Timer(INITIAL_DELAY,new ActionListener(){ public void actionPerformed( ActionEvent evt){ step(); } } ); display.addMouseListener(new MouseAdapter(){ public void mousePressed( MouseEvent evt){ Grid<T> gr=parentFrame.getWorld().getGrid(); Location loc=display.locationForPoint(evt.getPoint()); if (loc != null && gr.isValid(loc) && !isRunning()) { display.setCurrentLocation(loc); locationClicked(); } } } ); stop(); }
Example 18
From project Cinch, under directory /example/com/palantir/ptoss/cinch/example/demo/.
Source file: DrawingCanvas.java

private void initializeListeners(){ addMouseListener(new MouseAdapter(){ @Override public void mousePressed( MouseEvent e){ processPoint(e); } } ); addMouseMotionListener(new MouseMotionAdapter(){ @Override public void mouseDragged( MouseEvent e){ if (model.isAllowDrag()) { processPoint(e); } } } ); }
Example 19
From project Clotho-Core, under directory /ClothoApps/CollectionViewTool/src/org/clothocad/tool/collectionview/.
Source file: GlassMessage.java

/** * Creates a new instance of SmoothAnimation */ public GlassMessage(String msg,String secondmsg,int wide,int high,Container cont,Color bkg,ActionListener al){ imageW=wide; imageH=high; container=cont; message=msg; bkgColor=bkg; actionOnClick=al; message2=secondmsg; addMouseListener(new MouseAdapter(){ @Override public void mousePressed( MouseEvent e){ if (closeCircle == null) { return; } if (closeCircle.getBounds().contains(e.getPoint())) { dumpit(); } else { if (actionOnClick != null) { actionOnClick.actionPerformed(null); } } } } ); startTimer(currentResolution); }
Example 20
From project Codeable_Objects, under directory /codeableObjects/src/com/design/.
Source file: Controller.java

public void mouseEvent(MouseEvent event){ int x=event.getX(); int y=event.getY(); switch (event.getID()) { case MouseEvent.MOUSE_PRESSED: this.mousePressed(x,y); break; case MouseEvent.MOUSE_RELEASED: break; case MouseEvent.MOUSE_CLICKED: break; case MouseEvent.MOUSE_DRAGGED: this.mouseDragged(x,y); break; case MouseEvent.MOUSE_MOVED: break; } }
Example 21
From project codjo-segmentation, under directory /codjo-segmentation-gui/src/main/java/net/codjo/segmentation/gui/editor/.
Source file: EditorMainPanelLogic.java

@Override public void mouseClicked(MouseEvent event){ Object obj=((JList)event.getSource()).getSelectedValue(); String value; if (obj instanceof FunctionHelp) { value=((FunctionHelp)obj).getFunctionName(); } else { value=obj.toString(); } if (event.getClickCount() == 2) { JTextPane expression=editorMainPanelGui.getExpressionTextPane(); try { expression.getDocument().insertString(expression.getCaretPosition(),value,defaultAttributeSet); } catch ( Exception ex) { APP.error(ex.getMessage(),ex); } } }
Example 22
From project codjo-standalone-common, under directory /src/main/java/net/codjo/gui/.
Source file: ExplorerDataWindow.java

/** * Init GUI. */ private void jbInit(){ final JTree tree=explorer.getTree(); border1=BorderFactory.createEtchedBorder(Color.white,new Color(134,134,134)); titledBorder1=new TitledBorder(border1,"Filtres d'affichage"); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); tree.putClientProperty("JTree.lineStyle","Angled"); tree.setShowsRootHandles(true); ToolTipManager.sharedInstance().registerComponent(tree); setFrameIcon(UIManager.getIcon("DataExplorer.open")); this.setPreferredSize(new Dimension(325,600)); this.getContentPane().setBackground(Color.lightGray); this.getContentPane().setLayout(borderLayout2); MouseListener ml=new java.awt.event.MouseAdapter(){ /** * Determine la table s?ectionn? par un double click. * @param evt Evenement de la souris. */ public void mousePressed( MouseEvent evt){ DefaultMutableTreeNode nodeInfo=(DefaultMutableTreeNode)tree.getLastSelectedPathComponent(); int selRow=tree.getRowForLocation(evt.getX(),evt.getY()); if (selRow != -1) { if (evt.getClickCount() == 2) { Table table=(Table)nodeInfo.getUserObject(); execute(table); } } } } ; tree.addMouseListener(ml); filterPanel.setBorder(titledBorder1); explorerPanel.setLayout(borderLayout1); JScrollPane treeView=new JScrollPane(tree); this.getContentPane().add(explorerPanel,BorderLayout.CENTER); explorerPanel.add(treeView,BorderLayout.CENTER); this.getContentPane().add(filterPanel,BorderLayout.NORTH); }
Example 23
From project CommunityCase, under directory /src/org/community/intellij/plugins/communitycase/checkout/branches/.
Source file: BranchesWidget.java

/** * The constructor * @param project the project instance * @param statusBar the status bar * @param configurations the configuration settings */ public BranchesWidget(Project project,StatusBar statusBar,BranchConfigurations configurations){ myProject=project; myStatusBar=statusBar; setBorder(WidgetBorder.INSTANCE); myConfigurations=configurations; myDefaultForeground=getForeground(); myConfigurationsListener=new MyBranchConfigurationsListener(); myConfigurations.addConfigurationListener(myConfigurationsListener); Disposer.register(myConfigurations,this); addMouseListener(new MouseAdapter(){ @Override public void mouseClicked( MouseEvent e){ showPopup(); } } ); updateLabel(); }
Example 24
public void mousedown(MouseEvent ev,Coord c,int button){ setmods(ev); lcc=mc=c; if (mousegrab == null) root.mousedown(c,button); else mousegrab.mousedown(wdgxlate(c,mousegrab),button); }
Example 25
From project datavalve, under directory /samples/swingDemo/src/main/java/org/fluttercode/datavalve/samples/swingdemo/.
Source file: Main.java

private void initClickableColumns(final ProviderTableModel<Person> model){ table.getTableHeader().addMouseListener(new MouseAdapter(){ @Override public void mouseClicked( MouseEvent e){ TableColumnModel cm=table.getColumnModel(); int ci=cm.getColumnIndexAtX(e.getX()); int idx=table.convertColumnIndexToModel(ci); switch (idx) { case 0: model.getPaginator().changeOrderKey("id"); break; case 1: model.getPaginator().changeOrderKey("name"); break; case 2: model.getPaginator().changeOrderKey("phone"); break; } model.invalidate(); table.repaint(); } } ); }
Example 26
From project dawn-common, under directory /org.dawb.hdf5/src/ncsa/hdf/view/.
Source file: DataOptionDialog.java

public void mouseDragged(MouseEvent e){ Point p0=startPosition; Point p1=e.getPoint(); int x0=Math.max(0,Math.min(p0.x,p1.x)); int y0=Math.max(0,Math.min(p0.y,p1.y)); int x1=Math.min(x,Math.max(p0.x,p1.x)); int y1=Math.min(y,Math.max(p0.y,p1.y)); int w=x1 - x0; int h=y1 - y0; selectedArea.setBounds(x0,y0,w,h); try { updateSelection(x0,y0,w,h); } catch ( Exception ex) { } repaint(); }
Example 27
From project dawn-isencia, under directory /com.isencia.passerelle.engine/src/main/java/com/isencia/passerelle/actor/gui/graph/.
Source file: ModelGraphPanel.java

public void mouseDragged(MouseEvent evt){ if ((_jgraph != null) && ((evt.getModifiers() & InputEvent.BUTTON2_MASK) != 0)) { setPosition(evt.getX(),evt.getY()); startX=evt.getX(); startY=evt.getY(); } }
Example 28
From project drools-planner, under directory /drools-planner-examples/src/main/java/org/drools/planner/examples/app/.
Source file: DroolsPlannerExamplesApp.java

private JButton createExampleButton(final String title,final String description,String iconResource,final Runnable runnable){ ImageIcon icon=iconResource == null ? null : new ImageIcon(getClass().getResource(iconResource)); JButton button=new JButton(new AbstractAction(title,icon){ public void actionPerformed( ActionEvent e){ runnable.run(); } } ); button.setHorizontalTextPosition(JButton.CENTER); button.setVerticalTextPosition(JButton.BOTTOM); button.addMouseListener(new MouseAdapter(){ public void mouseEntered( MouseEvent e){ descriptionTextArea.setText(description); } public void mouseExited( MouseEvent e){ descriptionTextArea.setText(""); } } ); return button; }
Example 29
From project droolsjbpm-integration, under directory /droolsjbpm-integration-examples/src/main/java/org/drools/examples/conway/ui/.
Source file: CellGridCanvas.java

/** * Constructs a CellGridCanvas. * @param cellGrid the GoL cellgrid */ public CellGridCanvas(final CellGrid cellGrid){ this.cellGrid=cellGrid; this.cellSize=this.liveCellImage.getWidth(this); setBackground(CellGridCanvas.GRID_COLOR); addMouseListener(new MouseAdapter(){ /** * Invoked when a mouse button has been pressed on a component. */ public void mousePressed( final MouseEvent e){ toggleCellAt(e.getX(),e.getY()); } } ); addMouseMotionListener(new MouseMotionAdapter(){ public void mouseDragged( final MouseEvent e){ final Cell cell=getCellAtPoint(e.getX(),e.getY()); if (cell != null) { cellGrid.updateCell(cell,CellState.LIVE); repaint(); } } } ); }
Example 30
From project drugis-common, under directory /common-gui/src/main/java/org/drugis/common/gui/table/.
Source file: EnhancedTableHeader.java

public EnhancedTableHeader(TableColumnModel cm,JTable table){ super(cm); this.d_table=table; addMouseListener(new MouseAdapter(){ @Override public void mouseClicked( MouseEvent e){ doMouseClicked(e); } } ); }
Example 31
From project en4j, under directory /NBPlatformApp/NoteContentViewModule/src/main/java/com/rubenlaguna/en4j/NoteContentViewModule/.
Source file: NoteContentViewTopComponent.java

/** * This method is called from within the constructor to initialize the form. WARNING: Do NOT modify this code. The content of this method is always regenerated by the Form Editor. */ private void initComponents(){ jScrollPane2=new javax.swing.JScrollPane(); jLabel1=new javax.swing.JLabel(); jLabel2=new javax.swing.JLabel(); titleTextJLabel=new javax.swing.JLabel(); sourceurlTextJLabel=new javax.swing.JLabel(); setPreferredSize(new java.awt.Dimension(500,400)); jLabel1.setFont(jLabel1.getFont().deriveFont(jLabel1.getFont().getStyle() | java.awt.Font.BOLD)); org.openide.awt.Mnemonics.setLocalizedText(jLabel1,org.openide.util.NbBundle.getMessage(NoteContentViewTopComponent.class,"NoteContentViewTopComponent.jLabel1.text")); jLabel2.setFont(jLabel2.getFont().deriveFont(jLabel2.getFont().getStyle() | java.awt.Font.BOLD)); org.openide.awt.Mnemonics.setLocalizedText(jLabel2,org.openide.util.NbBundle.getMessage(NoteContentViewTopComponent.class,"NoteContentViewTopComponent.jLabel2.text")); org.openide.awt.Mnemonics.setLocalizedText(titleTextJLabel,org.openide.util.NbBundle.getMessage(NoteContentViewTopComponent.class,"NoteContentViewTopComponent.titleTextJLabel.text")); org.openide.awt.Mnemonics.setLocalizedText(sourceurlTextJLabel,org.openide.util.NbBundle.getMessage(NoteContentViewTopComponent.class,"NoteContentViewTopComponent.sourceurlTextJLabel.text")); sourceurlTextJLabel.addMouseListener(new java.awt.event.MouseAdapter(){ public void mouseReleased( java.awt.event.MouseEvent evt){ sourceurlTextJLabelMouseReleased(evt); } } ); javax.swing.GroupLayout layout=new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jScrollPane2,javax.swing.GroupLayout.DEFAULT_SIZE,459,Short.MAX_VALUE).addGroup(layout.createSequentialGroup().addComponent(jLabel1).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(titleTextJLabel)).addGroup(layout.createSequentialGroup().addComponent(jLabel2).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(sourceurlTextJLabel))).addContainerGap())); layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jLabel1).addComponent(titleTextJLabel)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jLabel2).addComponent(sourceurlTextJLabel)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(jScrollPane2,javax.swing.GroupLayout.DEFAULT_SIZE,368,Short.MAX_VALUE).addContainerGap())); }
Example 32
From project encog-java-examples, under directory /src/main/java/org/encog/examples/ml/world/.
Source file: QLearningPanel.java

public void mouseReleased(final MouseEvent e){ final int x=((e.getX() - this.margin) / this.cellWidth); final int y=e.getY() / this.cellHeight; if (((x >= 0) && (x < this.gridY)) && ((y >= 0) && (y < this.gridY))) { final int index=(y * this.gridX) + x; this.grid[index]=!this.grid[index]; } repaint(); }
Example 33
From project encog-java-workbench, under directory /src/main/java/org/encog/workbench/editor/.
Source file: ObjectEditorFrame.java

public void mouseClicked(final MouseEvent e){ if (MouseUtil.isRightClick(e)) { TreePath path=this.tree.getPathForLocation(e.getX(),e.getY()); Object obj=path.getLastPathComponent(); TreeNode node=(DefaultMutableTreeNode)obj; TreeNode parent=node.getParent(); if (parent != null) { this.tree.setSelectionPath(path); this.popup.show(e.getComponent(),e.getX(),e.getY()); } } }