List of usage examples for java.awt.event MouseEvent getPoint
public Point getPoint()
From source file:at.ac.tuwien.ibk.biqini.pep.gui.PEPGUI.java
public PEPGUI(String arg0, Vector<IBandwidthTracer> qosRules) { super(arg0);//www . ja v a 2 s. c o m // initiate all collections tsc = new TimeSeriesCollection[MAXCHARTS]; charts = new JFreeChart[MAXCHARTS]; positions = new Vector<Integer>(); chartPosition = new Hashtable<String, Integer>(); for (int i = 0; i < MAXCHARTS; i++) positions.add(i); allSessions = new Hashtable<String, IBandwidthTracer>(); // fill the BandwidthGenerator with the ongoing QoSRules bandwidthGenerator = new BandwidthGenerator(); Enumeration<IBandwidthTracer> enbandwidth = qosRules.elements(); while (enbandwidth.hasMoreElements()) { IBandwidthTracer b = enbandwidth.nextElement(); allSessions.put(b.getName(), b); bandwidthGenerator.add(b); } gridBagLayout = new GridBagLayout(); //insert the list with all QoS rules GridBagConstraints c = new GridBagConstraints(); c.weighty = 9; c.weightx = 2.0; c.gridheight = MAXCHARTS; c.fill = GridBagConstraints.BOTH; content = new JPanel(gridBagLayout); qoSRuleList = new JList(allSessions.keySet().toArray()); qoSRuleList.setPreferredSize(new java.awt.Dimension(200, 600)); qoSRuleList.setBorder(BorderFactory.createRaisedBevelBorder()); // set a MouseListner on the List MouseListener mouseListener = new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { int index = qoSRuleList.locationToIndex(e.getPoint()); addStream(allSessions.get(allSessions.keySet().toArray()[index])); } if (e.getButton() == MouseEvent.BUTTON3) { int index = qoSRuleList.locationToIndex(e.getPoint()); removeStream(allSessions.get(allSessions.keySet().toArray()[index])); } } }; qoSRuleList.addMouseListener(mouseListener); // place all parts at the content pane gridBagLayout.setConstraints(qoSRuleList, c); content.add(qoSRuleList); setContentPane(content); content.setSize(1000, 800); //create all GUI aspects for our Charts insertAllCharts(); //Start the thread that fills up our time series periodicBandwidthReader = new Thread(bandwidthGenerator); periodicBandwidthReader.setName("data-collector"); periodicBandwidthReader.start(); }
From source file:org.parosproxy.paros.view.SiteMapPanel.java
/** * This method initializes treeSite/*from w ww .j a va 2s. c o m*/ * * @return JTree */ public JTree getTreeSite() { if (treeSite == null) { treeSite = new JTree(); treeSite.setShowsRootHandles(true); treeSite.setName("treeSite"); treeSite.setToggleClickCount(1); treeSite.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0) { // ZAP: Select site list item on right click TreePath tp = treeSite.getPathForLocation(e.getPoint().x, e.getPoint().y); if (tp != null) { boolean select = true; // Only select a new item if the current item is not // already selected - this is to allow multiple items // to be selected if (treeSite.getSelectionPaths() != null) { for (TreePath t : treeSite.getSelectionPaths()) { if (t.equals(tp)) { select = false; break; } } } if (select) { treeSite.getSelectionModel().setSelectionPath(tp); } } View.getSingleton().getPopupMenu().show(e.getComponent(), e.getX(), e.getY()); } } }); treeSite.addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { HttpMessage msg = null; SiteNode node = (SiteNode) treeSite.getLastSelectedPathComponent(); if (node == null) { return; } if (!node.isRoot()) { try { msg = node.getHistoryReference().getHttpMessage(); } catch (Exception e1) { // ZAP: Log exceptions log.warn(e1.getMessage(), e1); return; } HttpPanel reqPanel = getView().getRequestPanel(); HttpPanel resPanel = getView().getResponsePanel(); reqPanel.setMessage(msg, true); resPanel.setMessage(msg, false); // ZAP: Call SiteMapListenners for (SiteMapListener listener : listenners) { listener.nodeSelected(node); } } } }); } return treeSite; }
From source file:org.pmedv.blackboard.dialogs.PartDialog.java
private void handlePopupTrigger(MouseEvent e) { if (e.isPopupTrigger() && model.getParts().size() >= 1) { Point p = e.getPoint(); // get the row index that contains that coordinate int rowNumber = partPanel.getPartTable().rowAtPoint(p); // Get the ListSelectionModel of the JTable ListSelectionModel model = partPanel.getPartTable().getSelectionModel(); // set the selected interval of rows. Using the "rowNumber" // variable for the beginning and end selects only that one row. model.setSelectionInterval(rowNumber, rowNumber); tablePopupMenu.show(e.getComponent(), e.getX(), e.getY()); }/* ww w .j a va2 s . co m*/ }
From source file:org.interreg.docexplore.management.manage.ManageComponent.java
@SuppressWarnings("serial") public ManageComponent(MainWindow win, final ManageHandler handler, boolean editable, boolean showPages) { super(new BorderLayout()); this.win = win; this.handler = handler; this.bookList = new JList(new CollectionNode(this)); setBorder(BorderFactory.createLineBorder(Color.black, 1)); bookList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); bookList.setCellRenderer(new ManageCellRenderer()); //tree.setRowHeight(52); add(new JScrollPane(bookList), BorderLayout.CENTER); if (editable) { bookList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) { int index = bookList.locationToIndex(e.getPoint()); if (index < 0 || !bookList.getCellBounds(index, index).contains(e.getPoint())) return; handler.bookOpened((Book) bookList.getModel().getElementAt(index)); }//from ww w.j a v a 2 s . c o m } }); this.toolbar = new ManageToolbar(this); add(toolbar, BorderLayout.NORTH); bookList.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting()) return; int count = bookList.getSelectedIndices().length; toolbar.deleteButton.setEnabled(count > 0); toolbar.editButton.setEnabled(count == 1); // toolbar.processButton.setEnabled(count == 1); toolbar.exportButton.setEnabled(count == 1); } }); } bookList.setBackground(new JPanel().getBackground()); getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) .put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "DEL"); getActionMap().put("DEL", new AbstractAction() { public void actionPerformed(ActionEvent arg0) { @SuppressWarnings({ "unchecked", "rawtypes" }) Vector<Book> books = new Vector(Arrays.asList(bookList.getSelectedValues())); if (books.size() > 0 && handler.booksDeleted(books)) { ((CollectionNode) bookList.getModel()).reload(); bookList.clearSelection(); bookList.repaint(); } } }); }
From source file:grafix.telas.MolduraAreaDados.java
private void molduraMouseDragged(java.awt.event.MouseEvent evt) { //Controle.getTela().getJanelaAtiva().getPanelGraficos().setIgnoreRepaint(true); if (origemDoNovoElemento != null) { finalDoNovoElemento = evt.getPoint(); repaint();/*from ww w. j av a 2s . c om*/ } else { descartarEvento(evt); } }
From source file:grafix.telas.MolduraAreaDados.java
private void molduraMousePressed(java.awt.event.MouseEvent evt) { ElementoGrafico novoElemento = panelMolduras.getJanela().getTela().getNovoElemento(); if (novoElemento != null) { origemDoNovoElemento = evt.getPoint(); if (!novoElemento.isDesenhaArrastando()) { finalDoNovoElemento = evt.getPoint(); molduraMouseReleased(evt);//from ww w . j a va 2 s . c om } } else { descartarEvento(evt); } }
From source file:com.univocity.app.swing.DataAnalysisWindow.java
private void addPopupMenuToTable(DaoTable daoTable, boolean isSourceTable) { String engineName = isSourceTable ? config.getSourceEngineName() : config.getDestinationEngineName(); if (engineName == null) { return;/*from w w w . j a v a 2 s .c om*/ } final JTable table = daoTable.getDataTable(); final JPopupMenu menu = new JPopupMenu(); menu.add(newJMenuItem("Disable updates", daoTable, engineName, false, false)); menu.add(newJMenuItem("Enable updates", daoTable, engineName, true, false)); menu.add(new JSeparator()); menu.add(newJMenuItem("Disable updates on all rows", daoTable, engineName, false, true)); menu.add(newJMenuItem("Enable updates on all rows", daoTable, engineName, true, true)); table.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON3) { int rowNumber = table.rowAtPoint(e.getPoint()); if (rowNumber != -1) { table.getSelectionModel().setSelectionInterval(rowNumber, rowNumber); menu.show(table, e.getX(), e.getY()); } } }; }); }
From source file:gui.SpamPanel.java
public void generate() { Message[] arrMsg = GmailAPI.Spam.toArray(new Message[GmailAPI.Spam.size()]); SpamList = new JList(arrMsg); SpamList.setCellRenderer(new DefaultListCellRenderer() { // Setting the DefaultListCellRenderer public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { Message message = (Message) value; // Using value we are getting the object in JList Map<String, String> map = null; try { map = GmailAPI.getMessageDetails(message.getId()); } catch (MessagingException ex) { Logger.getLogger(SpamPanel.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(SpamPanel.class.getName()).log(Level.SEVERE, null, ex); }/*w ww . j av a 2 s .com*/ String sub = map.get("subject"); if (map.get("subject").length() > 22) { sub = map.get("subject").substring(0, 20) + "..."; } setText(sub); // Setting the text //setIcon( shape.getImage() ); // Setting the Image Icon return this; } }); SpamList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); SpamList.setLayoutOrientation(JList.VERTICAL); SpamList.setVisibleRowCount(-1); jScrollPane1.setViewportView(SpamList); SpamList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { try { JList list = (JList) evt.getSource(); int index = list.locationToIndex(evt.getPoint()); String id = arrMsg[index].getId(); Map<String, String> map = GmailAPI.getMessageDetails(id); jTextField1.setText(map.get("from")); jTextField2.setText(map.get("subject")); dateTextField.setText(map.get("senddate")); BodyTextPane.setText(map.get("body")); BodyTextPane.setContentType("text/html"); //BodyTextArea.setCo } catch (IOException ex) { Logger.getLogger(SpamPanel.class.getName()).log(Level.SEVERE, null, ex); } catch (MessagingException ex) { Logger.getLogger(SpamPanel.class.getName()).log(Level.SEVERE, null, ex); } } }); }
From source file:de.wusel.partyplayer.gui.PartyPlayer.java
private Component createSongPanel() { final SongsTableModel model = new SongsTableModel(playerModel, settings, this); table = new JXTable(model) { @Override/*from ww w.j a v a2 s.c o m*/ public String getToolTipText(MouseEvent event) { int viewRowIndex = rowAtPoint(event.getPoint()); if (viewRowIndex != -1) { int modelIndex = convertRowIndexToModel(viewRowIndex); SongWrapper songFromList = playerModel.getSongFromList(modelIndex); return songFromList.getFileName(); } return super.getToolTipText(event); } }; table.setAutoCreateRowSorter(true); String numberColumnName = getText("table.songs.column.number.label"); table.getColumn(numberColumnName).setMaxWidth(25); table.getColumn(numberColumnName).setResizable(false); TableSortController sorter = (TableSortController) table.getRowSorter(); sorter.setComparator(2, new SongComparator()); table.getColumn(numberColumnName).setCellRenderer(new SubstanceDefaultTableCellRenderer() { @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); if (value != null) label.setText(((SongWrapper) value).getTrackNumber() + ""); return label; } }); table.getColumn(getText("table.songs.column.duration.label")) .setCellRenderer(new SubstanceDefaultTableCellRenderer() { @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); if (value != null) label.setText(Util.getTimeString((Double) value)); return label; } }); table.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { addSongToPlaylist( playerModel.getSongFromList(table.convertRowIndexToModel(table.getSelectedRow()))); } } }); table.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { addSongToPlaylist( playerModel.getSongFromList(table.convertRowIndexToModel(table.getSelectedRow()))); } } }); JScrollPane scrollPane = new JScrollPane(table); table.setFillsViewportHeight(true); return scrollPane; }
From source file:de.dakror.villagedefense.game.entity.Entity.java
public boolean mousePressed(MouseEvent e) { if (alpha == 0) return false; if (alpha != 1 && this instanceof Struct) return clicked = getBump(true).contains(e.getPoint()); return clicked = contains(e.getX(), e.getY()); }