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:Clavis.Windows.WShedule.java
public synchronized void refreshTable(int val) { DefaultTableModel modelo = (DefaultTableModel) jTable1.getModel(); if (modelo.getRowCount() > 0) { int tam = modelo.getRowCount(); for (int h = 0; h < tam; h++) { modelo.removeRow(0);/*from ww w.ja v a 2 s . c om*/ } } java.util.List<Keys.Request> requisicoes = new java.util.ArrayList<>(); if (DataBase.DataBase.testConnection(url)) { DataBase.DataBase db = new DataBase.DataBase(url); requisicoes = Clavis.RequestList .simplifyRequests(db.getRequestsByMaterialByDateInterval(mat, inicio, fim)); db.close(); } lista = new java.util.ArrayList<>(); andamento = 0; switch (val) { case 0: estado = lingua.translate("Todos"); for (Keys.Request req : requisicoes) { String[] multipla = req.getActivity().split(":::"); String saux; if (multipla.length > 1) { saux = multipla[0]; Components.PopUpMenu pop = new Components.PopUpMenu(multipla, lingua); pop.create(); jTable1.addMouseListener(new MouseAdapter() { int x = andamento; int y = 3; @Override public void mousePressed(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { int row = jTable1.rowAtPoint(e.getPoint()); int col = jTable1.columnAtPoint(e.getPoint()); if ((row == x) && (col == y)) { pop.show(e.getComponent(), e.getX(), e.getY()); } } } @Override public void mouseReleased(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { if (pop.isShowing()) { pop.setVisible(false); } } } }); } else { saux = req.getActivity(); } if (saux.equals("")) { saux = lingua.translate("Sem descrio"); } if (mat.getMaterialTypeID() == 1) { Object[] ob = { req.getPerson().getName(), req.getTimeBegin().toString(0) + " - " + req.getTimeEnd().toString(0), req.getBeginDate().toString(), saux, req.getSubject().getName() }; modelo.addRow(ob); } else { Object[] ob = { req.getPerson().getName(), req.getBeginDate().toString(), req.getEndDate().toString(), saux }; modelo.addRow(ob); } lista.add(req); andamento++; } break; case 1: estado = lingua.translate("terminado"); for (Keys.Request req : requisicoes) { if (req.isTerminated()) { String[] multipla = req.getActivity().split(":::"); String saux; if (multipla.length > 1) { saux = multipla[0]; Components.PopUpMenu pop = new Components.PopUpMenu(multipla, lingua); pop.create(); jTable1.addMouseListener(new MouseAdapter() { int x = andamento; int y = 3; @Override public void mousePressed(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { int row = jTable1.rowAtPoint(e.getPoint()); int col = jTable1.columnAtPoint(e.getPoint()); if ((row == x) && (col == y)) { pop.show(e.getComponent(), e.getX(), e.getY()); } } } @Override public void mouseReleased(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { if (pop.isShowing()) { pop.setVisible(false); } } } }); } else { saux = req.getActivity(); } if (saux.equals("")) { saux = lingua.translate("Sem descrio"); } if (mat.getMaterialTypeID() == 1) { Object[] ob = { req.getPerson().getName(), req.getTimeBegin().toString(0) + " - " + req.getTimeEnd().toString(0), req.getBeginDate().toString(), saux, req.getSubject().getName() }; modelo.addRow(ob); } else { Object[] ob = { req.getPerson().getName(), req.getBeginDate().toString(), req.getEndDate().toString(), saux }; modelo.addRow(ob); } lista.add(req); andamento++; } } break; case 2: estado = lingua.translate("no realizado"); for (Keys.Request req : requisicoes) { if ((!req.isActive()) && ((req.getEndDate().isBigger(new TimeDate.Date()) > 0) || ((req.getEndDate().isBigger(new TimeDate.Date()) == 0) && (req.getTimeEnd().compareTime(new TimeDate.Time()) > 0)))) { String[] multipla = req.getActivity().split(":::"); String saux; if (multipla.length > 1) { saux = multipla[0]; Components.PopUpMenu pop = new Components.PopUpMenu(multipla, lingua); pop.create(); jTable1.addMouseListener(new MouseAdapter() { int x = andamento; int y = 3; @Override public void mousePressed(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { int row = jTable1.rowAtPoint(e.getPoint()); int col = jTable1.columnAtPoint(e.getPoint()); if ((row == x) && (col == y)) { pop.show(e.getComponent(), e.getX(), e.getY()); } } } @Override public void mouseReleased(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { if (pop.isShowing()) { pop.setVisible(false); } } } }); } else { saux = req.getActivity(); } if (saux.equals("")) { saux = lingua.translate("Sem descrio"); } if (mat.getMaterialTypeID() == 1) { Object[] ob = { req.getPerson().getName(), req.getTimeBegin().toString(0) + " - " + req.getTimeEnd().toString(0), req.getBeginDate().toString(), saux, req.getSubject().getName() }; modelo.addRow(ob); } else { Object[] ob = { req.getPerson().getName(), req.getBeginDate().toString(), req.getEndDate().toString(), saux }; modelo.addRow(ob); } lista.add(req); andamento++; } } break; case 3: estado = lingua.translate("por realizar"); for (Keys.Request req : requisicoes) { if ((!req.isActive()) && (!req.isTerminated()) && ((req.getEndDate().isBigger(new TimeDate.Date()) < 0) || ((req.getEndDate().isBigger(new TimeDate.Date()) == 0) && (req.getTimeEnd().compareTime(new TimeDate.Time()) < 0)))) { String[] multipla = req.getActivity().split(":::"); String saux; if (multipla.length > 1) { saux = multipla[0]; Components.PopUpMenu pop = new Components.PopUpMenu(multipla, lingua); pop.create(); jTable1.addMouseListener(new MouseAdapter() { int x = andamento; int y = 3; @Override public void mousePressed(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { int row = jTable1.rowAtPoint(e.getPoint()); int col = jTable1.columnAtPoint(e.getPoint()); if ((row == x) && (col == y)) { pop.show(e.getComponent(), e.getX(), e.getY()); } } } @Override public void mouseReleased(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { if (pop.isShowing()) { pop.setVisible(false); } } } }); } else { saux = req.getActivity(); } if (saux.equals("")) { saux = lingua.translate("Sem descrio"); } if (mat.getMaterialTypeID() == 1) { Object[] ob = { req.getPerson().getName(), req.getTimeBegin().toString(0) + " - " + req.getTimeEnd().toString(0), req.getBeginDate().toString(), saux, req.getSubject().getName() }; modelo.addRow(ob); } else { Object[] ob = { req.getPerson().getName(), req.getBeginDate().toString(), req.getEndDate().toString(), saux }; modelo.addRow(ob); } lista.add(req); andamento++; } } break; } valores = new String[lista.size()][4]; for (int i = 0; i < lista.size(); i++) { String[] multipla = lista.get(i).getActivity().split(":::"); String saux = multipla[0]; if (saux.equals("")) { saux = lingua.translate("Sem descrio"); } if (mat.getMaterialTypeID() == 1) { valores[i][0] = lista.get(i).getPerson().getName(); valores[i][1] = lista.get(i).getTimeBegin().toString(0) + " - " + lista.get(i).getTimeEnd().toString(0); valores[i][2] = lista.get(i).getBeginDate().toString(); valores[i][3] = saux + " - " + lista.get(i).getSubject().getName(); } else { valores[i][0] = lista.get(i).getPerson().getName(); valores[i][1] = lista.get(i).getBeginDate().toString(); valores[i][2] = lista.get(i).getEndDate().toString(); valores[i][3] = saux; } } }
From source file:GUI.MainWindow.java
private void VulnReferencesListMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_VulnReferencesListMouseClicked int clicked = evt.getButton(); if (clicked == MouseEvent.BUTTON1 && evt.getClickCount() == 2) { // A double click. Lets see if there is already a link or if we are creating a new one Object obj = VulnReferencesList.getSelectedValue(); if (obj == null) { // We should simply show the 'add reference' prompy } else if (obj instanceof Reference) { // User probably wants to edit the existing reference Reference ref = (Reference) obj; addReference(VulnTree, VulnReferencesList, ref); }//from w w w . j a va 2s .co m } else if (clicked == MouseEvent.BUTTON3) { // A right click. Show the context menu //int selected = VulnReferencesList.getSelectedIndex(); List l = VulnReferencesList.getSelectedValuesList(); int selected = l.size(); System.out.println("selected: " + selected); // None are selected enable insert and disable all the rest InsertReference.setEnabled(true); EditReferenceOption.setEnabled(false); LaunchInBrowser.setEnabled(false); DeleteReferenceOption.setEnabled(false); if (selected == 1) { // One was selected to enable the right options InsertReference.setEnabled(true); EditReferenceOption.setEnabled(true); LaunchInBrowser.setEnabled(true); DeleteReferenceOption.setEnabled(true); } else if (selected >= 2) { // One was selected to enable the right options InsertReference.setEnabled(true); EditReferenceOption.setEnabled(false); LaunchInBrowser.setEnabled(true); DeleteReferenceOption.setEnabled(true); } VulnReferencesContextMenu.show((Component) evt.getSource(), evt.getX(), evt.getY()); } }
From source file:gda.plots.SimplePlot.java
/** * Part of the implementation of MouseListener - overrides the super class (ChartPanel) implementation so that the * mouse can be used to select a rectangle as well as for zooming. * /* w w w . jav a 2 s . c om*/ * @param e * the mouse event which caused the call */ @Override public void mousePressed(MouseEvent e) { // Unless a rectangle is being dragged we just // want to call the super class method (which // deals with zooming) if (rd == null) { super.mousePressed(e); if (magnifyingImage || magnifyingData) { if (e.getButton() == MouseEvent.BUTTON1) { magnifyRectangle = null; magnifyXPoint = e.getX(); magnifyYPoint = e.getY(); } if (!e.isPopupTrigger()) { Graphics2D g2 = (Graphics2D) getGraphics(); g2.setXORMode(dragColour); if (magnifyRectangle != null) { g2.fill(magnifyRectangle); } g2.dispose(); } } } else { rd.mousePressed(e); } }
From source file:gda.plots.SimplePlot.java
/** * Part of the implementation of MouseListener. Overrides the super class (ChartPanel) implementation so that the * mouse can be used to select a rectangle as well as for zooming. * //from www . j a va 2s. c o m * @see #mousePressed(java.awt.event.MouseEvent) * @see #mouseDragged(java.awt.event.MouseEvent) * @param e * the mouse event which caused the call */ @Override public void mouseReleased(MouseEvent e) { // Unless a rectangle is being dragged we just // want to call the super class method (which // deals with zooming) if (rd == null) { super.mouseReleased(e); if (magnifyingImage || magnifyingData) { // If the button released is BUTTON1 then the rectangle for // magnification will have been resized. if (e.getButton() == MouseEvent.BUTTON1) { magnifyWidth = e.getX() - magnifyXPoint; magnifyHeight = e.getY() - magnifyYPoint; magnifyRectangleIsNew = true; } // If the button released is BUTTON2 then the rectangle will // have been being dragged around. Need to redraw in XOR mode // one // last time to remove rectangle from plot. else if (e.getButton() == MouseEvent.BUTTON2) { Graphics2D g2 = (Graphics2D) getGraphics(); g2.setXORMode(dragColour); if (magnifyRectangle != null) { g2.fill(magnifyRectangle); } g2.dispose(); } recalculateMagnifyRectangle(e); magnifier.update(magnifyRectangle); } } else { rd.mouseReleased(e); } }
From source file:simMPLS.ui.simulator.JVentanaHija.java
/** Este mtodo se llama automticamente cuando soltamos el botn del raton a la * rrastrar o al hacer clic. Si el ratn estaba sobre un elemento de la topology, se marca ste como no seleccionado.//from w w w . ja v a 2s. c om * @since 1.0 * @param evt El evento que hace que se dispare este mtodo. */ private void clicSoltadoEnPanelDisenio(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_clicSoltadoEnPanelDisenio if (evt.getButton() == MouseEvent.BUTTON1) { if (nodoSeleccionado != null) { nodoSeleccionado.setStatus(TNode.DESELECCIONADO); nodoSeleccionado = null; this.escenario.setModified(true); } panelDisenio.repaint(); } }
From source file:simMPLS.ui.simulator.JVentanaHija.java
/** Este mtodo se llama automticamente cuando se hace un clic con el botn * izquierdo sobre la pantalla de diseo. * @since 1.0//w w w . j av a 2 s .c o m * @param evt Evento que hace que se dispare este mtodo. */ private void clicEnPanelDisenio(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_clicEnPanelDisenio if (evt.getButton() == MouseEvent.BUTTON1) { TTopology topo = escenario.getTopology(); nodoSeleccionado = topo.obtenerNodoEnPosicion(evt.getPoint()); if (nodoSeleccionado != null) { nodoSeleccionado.setStatus(TNode.SELECCIONADO); this.escenario.setModified(true); } panelDisenio.repaint(); } }
From source file:org.yccheok.jstock.gui.MainFrame.java
private void createSystemTrayIcon() { if (SystemTray.isSupported()) { SystemTray tray = SystemTray.getSystemTray(); final Image image; if (Utils.isWindows7() || Utils.isWindows8()) { image = new javax.swing.ImageIcon(getClass().getResource("/images/128x128/chart.png")).getImage(); } else {/* ww w. ja v a2 s .c om*/ image = new javax.swing.ImageIcon(getClass().getResource("/images/16x16/chart.png")).getImage(); } MouseListener mouseListener = new MouseListener() { @Override public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { MainFrame.this.setVisible(true); MainFrame.this.setState(Frame.NORMAL); } } @Override public void mouseEntered(MouseEvent e) { } @Override public void mouseExited(MouseEvent e) { } @Override public void mousePressed(MouseEvent e) { } @Override public void mouseReleased(MouseEvent e) { } }; ActionListener exitListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { MainFrame.this.setVisible(false); MainFrame.this.dispose(); } }; PopupMenu popup = new PopupMenu(); MenuItem defaultItem = new MenuItem( java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/gui").getString("MainFrame_Exit")); defaultItem.addActionListener(exitListener); popup.add(defaultItem); trayIcon = new TrayIcon(image, GUIBundle.getString("MainFrame_Application_Title"), popup); ActionListener actionListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { } }; trayIcon.setImageAutoSize(true); trayIcon.addActionListener(actionListener); trayIcon.addMouseListener(mouseListener); try { tray.add(trayIcon); } catch (AWTException e) { trayIcon = null; JOptionPane.showMessageDialog(MainFrame.this, java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/messages") .getString("warning_message_trayicon_could_not_be_added"), java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/messages").getString( "warning_title_trayicon_could_not_be_added"), JOptionPane.WARNING_MESSAGE); } } else { // System Tray is not supported trayIcon = null; JOptionPane.showMessageDialog(MainFrame.this, java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/messages") .getString("warning_message_system_tray_is_not_supported"), java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/messages") .getString("warning_title_system_tray_is_not_supported"), JOptionPane.WARNING_MESSAGE); } }
From source file:org.yccheok.jstock.gui.JStock.java
private void createSystemTrayIcon() { if (SystemTray.isSupported()) { SystemTray tray = SystemTray.getSystemTray(); final Image image = new javax.swing.ImageIcon(getClass().getResource("/images/128x128/chart.png")) .getImage();//w ww. j a v a 2 s . c o m MouseListener mouseListener = new MouseListener() { @Override public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { JStock.this.setVisible(true); JStock.this.setState(Frame.NORMAL); } } @Override public void mouseEntered(MouseEvent e) { } @Override public void mouseExited(MouseEvent e) { } @Override public void mousePressed(MouseEvent e) { } @Override public void mouseReleased(MouseEvent e) { } }; ActionListener exitListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JStock.this.setVisible(false); JStock.this.dispose(); } }; PopupMenu popup = new PopupMenu(); MenuItem defaultItem = new MenuItem( java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/gui").getString("MainFrame_Exit")); defaultItem.addActionListener(exitListener); popup.add(defaultItem); trayIcon = new TrayIcon(image, GUIBundle.getString("MainFrame_Application_Title"), popup); ActionListener actionListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { } }; trayIcon.setImageAutoSize(true); trayIcon.addActionListener(actionListener); trayIcon.addMouseListener(mouseListener); try { tray.add(trayIcon); } catch (AWTException e) { trayIcon = null; JOptionPane.showMessageDialog(JStock.this, java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/messages") .getString("warning_message_trayicon_could_not_be_added"), java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/messages").getString( "warning_title_trayicon_could_not_be_added"), JOptionPane.WARNING_MESSAGE); } } else { // System Tray is not supported trayIcon = null; JOptionPane.showMessageDialog(JStock.this, java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/messages") .getString("warning_message_system_tray_is_not_supported"), java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/messages") .getString("warning_title_system_tray_is_not_supported"), JOptionPane.WARNING_MESSAGE); } }
From source file:GUI.MainWindow.java
private void handleAffectedHosts(MouseEvent evt) { Object obj = this.VulnTree.getLastSelectedPathComponent(); if (obj == null) { return;/*w w w. j a v a 2 s.c o m*/ } int row = VulnAffectedHostsTable.getSelectedRow(); if (row == -1) // No vulns selected { // Setup the context menu as required EditHostname.setEnabled(false); DeleteHost.setEnabled(false); } else { // A vuln is selected // Setup the context menu as required EditHostname.setEnabled(true); DeleteHost.setEnabled(true); } if (evt.getButton() == MouseEvent.BUTTON1 && evt.getClickCount() == 2) { // this was a double click on the try showNotesForSpecificHost(); } else if (evt.getButton() == MouseEvent.BUTTON3) { VulnAffectedHostsContextMenu.show(VulnAffectedHostsTable, evt.getX(), evt.getY()); } }
From source file:lu.fisch.unimozer.Diagram.java
@Override public void mousePressed(MouseEvent e) { if (isEnabled() && e.getButton() == MouseEvent.BUTTON1) { if (mode == MODE_EXTENDS) { // get the clicked point mousePoint = e.getPoint();// w w w.j a v a 2 s.com mousePressed = true; // get clicked class extendsFrom = getMouseClass(mousePoint); extendsDragPoint = e.getPoint(); if (extendsFrom == null) { setMode(MODE_SELECT); frame.updateMode(); } } else { if (e.getButton() == MouseEvent.BUTTON1) mousePressed = true; // get the clicked point mousePoint = e.getPoint(); // get clicked package getMousePackage(mousePoint); // get clicked class MyClass clickClass = getMouseClass(mousePoint); if (clickClass != null) mouseRelativePoint = clickClass.getRelative(mousePoint); else if (mousePackage != null) { mouseRelativePoint = mousePoint; } // load the clicked class loadClickedClass(e); } } }