List of usage examples for java.awt.event MouseAdapter MouseAdapter
MouseAdapter
From source file:io.github.jeremgamer.editor.panels.Actions.java
public Actions(final JFrame frame, final ActionPanel ap) { this.frame = frame; this.setBorder(BorderFactory.createTitledBorder("")); JButton add = null;/*from www .j a v a 2s . c o m*/ try { add = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("add.png")))); } catch (IOException e) { e.printStackTrace(); } add.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { try { JOptionPane jop = new JOptionPane(); @SuppressWarnings("static-access") String name = jop.showInputDialog(null, "Nommez l'action :", "Crer une action", JOptionPane.QUESTION_MESSAGE); if (name != null) { for (int i = 0; i < data.getSize(); i++) { if (data.get(i).equals(name)) { name += "1"; } } data.addElement(name); new ActionSave(name); OtherPanel.updateLists(); ButtonPanel.updateLists(); ActionPanel.updateLists(); } } catch (IOException e) { e.printStackTrace(); } } }); JButton remove = null; try { remove = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png")))); } catch (IOException e) { e.printStackTrace(); } remove.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { try { if (actionList.getSelectedValue() != null) { File file = new File("projects/" + Editor.getProjectName() + "/actions/" + actionList.getSelectedValue() + ".rbd"); JOptionPane jop = new JOptionPane(); @SuppressWarnings("static-access") int option = jop.showConfirmDialog(null, "tes-vous sr de vouloir supprimer cette action?", "Avertissement", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if (option == JOptionPane.OK_OPTION) { if (actionList.getSelectedValue().equals(ap.getFileName())) { ap.setFileName(""); } ap.hide(); file.delete(); data.remove(actionList.getSelectedIndex()); OtherPanel.updateLists(); ButtonPanel.updateLists(); } } } catch (NullPointerException npe) { npe.printStackTrace(); } } }); JPanel buttons = new JPanel(); buttons.setLayout(new BoxLayout(buttons, BoxLayout.LINE_AXIS)); buttons.add(add); buttons.add(remove); updateList(); actionList.addMouseListener(new MouseAdapter() { @SuppressWarnings("unchecked") public void mouseClicked(MouseEvent evt) { JList<String> list = (JList<String>) evt.getSource(); if (evt.getClickCount() == 2) { int index = list.locationToIndex(evt.getPoint()); if (isOpen == false) { ap.show(); ap.load(new File("projects/" + Editor.getProjectName() + "/actions/" + list.getModel().getElementAt(index) + ".rbd")); previousSelection = list.getSelectedValue(); isOpen = true; } else { try { if (previousSelection.equals(list.getModel().getElementAt(index))) { ap.hide(); previousSelection = list.getSelectedValue(); list.clearSelection(); isOpen = false; } else { ap.hideThenShow(); previousSelection = list.getSelectedValue(); ap.load(new File("projects/" + Editor.getProjectName() + "/actions/" + list.getModel().getElementAt(index) + ".rbd")); } } catch (NullPointerException npe) { ap.hide(); list.clearSelection(); } } } else if (evt.getClickCount() == 3) { int index = list.locationToIndex(evt.getPoint()); if (isOpen == false) { ap.show(); ap.load(new File("projects/" + Editor.getProjectName() + "/actions/" + list.getModel().getElementAt(index) + ".rbd")); previousSelection = list.getSelectedValue(); isOpen = true; } else { try { if (previousSelection.equals(list.getModel().getElementAt(index))) { ap.hide(); previousSelection = list.getSelectedValue(); list.clearSelection(); isOpen = false; } else { ap.hideThenShow(); previousSelection = list.getSelectedValue(); ap.load(new File("projects/" + Editor.getProjectName() + "/actions/" + list.getModel().getElementAt(index) + ".rbd")); } } catch (NullPointerException npe) { ap.hide(); list.clearSelection(); } } } } }); JScrollPane listPane = new JScrollPane(actionList); listPane.getVerticalScrollBar().setUnitIncrement(Editor.SCROLL_SPEED); this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); this.add(buttons); this.add(listPane); OtherPanel.updateLists(); }
From source file:org.griphyn.vdl.karajan.monitor.monitors.swing.GraphPanel.java
private void createChart() { chart = ChartFactory.createTimeSeriesChart(null, "Time", null, null, false, false, false); cp = new ChartPanel(chart); // avoid stretching fonts and such cp.setMaximumDrawWidth(Integer.MAX_VALUE); cp.setMaximumDrawHeight(Integer.MAX_VALUE); XYPlot plot = chart.getXYPlot();// ww w . j a v a 2s .com plot.setBackgroundPaint(UIManager.getColor("TextField.background")); plot.setDomainCrosshairVisible(true); plot.setDomainCrosshairLockedOnData(false); cp.addChartMouseListener(this); cp.setLayout(new DummyLayoutManager()); cp.add(toolTip = new JToolTip()); toolTip.setVisible(false); cp.addMouseListener(new MouseAdapter() { @Override public void mouseExited(MouseEvent e) { disableToolTip(); } }); chart.addChangeListener(new ChartChangeListener() { @Override public void chartChanged(ChartChangeEvent e) { if (e.getType() == ChartChangeEventType.DATASET_UPDATED) { updateMaxRange(); updateToolTipLocation(); } } }); for (String s : enabled) { addSeries(sampler.getSeries(s)); } JPanel p = new JPanel(); p.setLayout(new BorderLayout()); p.add(cp, BorderLayout.CENTER); legend = new JPanel(); legend.setLayout(new FlowLayout()); rebuildLegend(); this.add(p, BorderLayout.CENTER); this.add(legend, BorderLayout.SOUTH); }
From source file:com.mirth.connect.connectors.ws.WebServiceSender.java
public WebServiceSender() { this.parent = PlatformUI.MIRTH_FRAME; initComponents();/*from w w w .j a va2 s . c om*/ SyntaxDocument document = new SyntaxDocument(); document.setTokenMarker(new XMLTokenMarker()); soapEnvelope.setDocument(document); KeyListener keyListener = new KeyAdapter() { public void keyReleased(KeyEvent evt) { urlFieldChanged(); } }; wsdlUrlField.addKeyListener(keyListener); soapActionField.addKeyListener(keyListener); headersPane.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { deselectRows(headersTable, headersDeleteButton); } }); headersDeleteButton.setEnabled(false); sslWarningPanel = new SSLWarningPanel(); }
From source file:gdt.jgui.entity.webset.JWeblinkEditor.java
/** * The default constructor./*from w w w. j a v a2 s . co m*/ */ public JWeblinkEditor() { GridBagLayout gridBagLayout = new GridBagLayout(); gridBagLayout.rowHeights = new int[] { 0, 0, 0, 0, 0 }; gridBagLayout.columnWeights = new double[] { 0.0, 1.0 }; gridBagLayout.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0 }; setLayout(gridBagLayout); String icon$ = Support.readHandlerIcon(null, JEntitiesPanel.class, "globe.png"); byte[] ba = Base64.decodeBase64(icon$); ImageIcon icon = new ImageIcon(ba); Image image = icon.getImage().getScaledInstance(24, 24, 0); icon.setImage(image); JLabel iconLabel = new JLabel("Icon"); c = new GridBagConstraints(); c.insets = new Insets(5, 5, 5, 5); c.anchor = GridBagConstraints.FIRST_LINE_START; c.weighty = 0; c.gridx = 0; c.gridy = 0; add(iconLabel, c); iconLabel.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { showIconMenu(e); } }); iconIcon = new JLabel(); iconIcon.setIcon(icon); c_0 = new GridBagConstraints(); c_0.anchor = GridBagConstraints.WEST; c_0.insets = new Insets(0, 5, 5, 0); c.anchor = GridBagConstraints.WEST; c_0.gridx = 1; c_0.gridy = 0; add(iconIcon, c_0); iconIcon.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { showIconMenu(e); } }); JLabel lblName = new JLabel("Name"); c_1 = new GridBagConstraints(); c_1.insets = new Insets(5, 5, 5, 5); c_1.fill = GridBagConstraints.HORIZONTAL; c_1.gridx = 0; c_1.gridy = 1; add(lblName, c_1); nameField = new JTextField(); c_2 = new GridBagConstraints(); c_2.insets = new Insets(0, 5, 5, 0); c_2.fill = GridBagConstraints.HORIZONTAL; c_2.gridx = 1; c_2.gridy = 1; add(nameField, c_2); JLabel lblUrl = new JLabel("Address"); c_3 = new GridBagConstraints(); c_3.insets = new Insets(5, 5, 5, 5); c_3.fill = GridBagConstraints.HORIZONTAL; c_3.gridx = 0; c_3.gridy = 2; add(lblUrl, c_3); addressField = new JTextField(); c_4 = new GridBagConstraints(); c_4.insets = new Insets(0, 5, 5, 0); c_4.fill = GridBagConstraints.HORIZONTAL; c_4.gridx = 1; c_4.gridy = 2; add(addressField, c_4); JLabel lblLogin = new JLabel("Login"); c_5 = new GridBagConstraints(); c_5.insets = new Insets(5, 5, 5, 5); c_5.fill = GridBagConstraints.HORIZONTAL; c_5.gridx = 0; c_5.gridy = 3; add(lblLogin, c_5); lblLogin.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { showLoginMenu(e); } }); loginField = new JTextField(); c_6 = new GridBagConstraints(); c_6.insets = new Insets(0, 5, 5, 0); c_6.fill = GridBagConstraints.HORIZONTAL; c_6.gridx = 1; c_6.gridy = 3; add(loginField, c_6); JLabel lblPassword = new JLabel("Password"); c_7 = new GridBagConstraints(); c_7.insets = new Insets(5, 5, 5, 5); c_7.fill = GridBagConstraints.HORIZONTAL; c_7.gridx = 0; c_7.gridy = 4; add(lblPassword, c_7); lblPassword.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { showPasswordMenu(e); } }); passwordField = new JTextField(); c_8 = new GridBagConstraints(); c_8.insets = new Insets(0, 5, 5, 0); c_8.fill = GridBagConstraints.HORIZONTAL; c_8.gridx = 1; c_8.gridy = 4; add(passwordField, c_8); JPanel bottom = new JPanel(); c_9 = new GridBagConstraints(); c_9.weighty = 1; c_9.fill = GridBagConstraints.VERTICAL; c_9.gridx = 0; c_9.gridy = 5; add(bottom, c_9); }
From source file:SimpleTableSelectionDemo.java
public SimpleTableSelectionDemo() { super(new GridLayout(1, 0)); final String[] columnNames = { "First Name", "Last Name", "Sport", "# of Years", "Vegetarian" }; final Object[][] data = { { "Mary", "Campione", "Snowboarding", new Integer(5), new Boolean(false) }, { "Alison", "Huml", "Rowing", new Integer(3), new Boolean(true) }, { "Kathy", "Walrath", "Knitting", new Integer(2), new Boolean(false) }, { "Sharon", "Zakhour", "Speed reading", new Integer(20), new Boolean(true) }, { "Philip", "Milne", "Pool", new Integer(10), new Boolean(false) } }; final JTable table = new JTable(data, columnNames); table.setPreferredScrollableViewportSize(new Dimension(500, 70)); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); if (ALLOW_ROW_SELECTION) { // true by default ListSelectionModel rowSM = table.getSelectionModel(); rowSM.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { //Ignore extra messages. if (e.getValueIsAdjusting()) return; ListSelectionModel lsm = (ListSelectionModel) e.getSource(); if (lsm.isSelectionEmpty()) { System.out.println("No rows are selected."); } else { int selectedRow = lsm.getMinSelectionIndex(); System.out.println("Row " + selectedRow + " is now selected."); }// w ww. ja v a 2 s . c o m } }); } else { table.setRowSelectionAllowed(false); } if (ALLOW_COLUMN_SELECTION) { // false by default if (ALLOW_ROW_SELECTION) { //We allow both row and column selection, which //implies that we *really* want to allow individual //cell selection. table.setCellSelectionEnabled(true); } table.setColumnSelectionAllowed(true); ListSelectionModel colSM = table.getColumnModel().getSelectionModel(); colSM.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { //Ignore extra messages. if (e.getValueIsAdjusting()) return; ListSelectionModel lsm = (ListSelectionModel) e.getSource(); if (lsm.isSelectionEmpty()) { System.out.println("No columns are selected."); } else { int selectedCol = lsm.getMinSelectionIndex(); System.out.println("Column " + selectedCol + " is now selected."); } } }); } if (DEBUG) { table.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { printDebugData(table); } }); } //Create the scroll pane and add the table to it. JScrollPane scrollPane = new JScrollPane(table); //Add the scroll pane to this panel. add(scrollPane); }
From source file:maltcms.ui.fileHandles.csv.CSVTableView.java
/** * * @param tm// w w w . ja v a2s. c om */ public void setTableModel(TableModel tm) { if (tm == null) { Logger.getLogger(this.getClass().getName()).log(Level.WARNING, "Received table model was null!"); return; } this.jTable1.setModel(tm); //default column model for (int i = 0; i < tm.getColumnCount(); i++) { this.jTable1.getColumnModel().getColumn(i).setCellRenderer( new ColorColumnRenderer(new Color(255, 255, 255, 255), jTable1.getSelectedRows())); } JTableCustomizer.changeComparators(this.jTable1); JTableCustomizer.fitAllColumnWidth(this.jTable1); this.jTable1.getTableHeader().addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { if (e.getButton() == 3) { activeColumn = jTable1.getTableHeader().columnAtPoint(e.getPoint()); int[] selectedRows = jTable1.getSelectedRows(); int minRow = 0;// int maxRow = jTable1.getRowCount() - 1;// int[] selectedColumns = jTable1.getSelectedColumns(); int minCol = 0; int maxCol = jTable1.getColumnCount() - 1; if (cellSelection) { jTable1.setRowSelectionAllowed(true); minRow = MathTools.min(selectedRows); maxRow = MathTools.max(selectedRows); minCol = MathTools.min(selectedColumns); maxCol = MathTools.min(selectedColumns); } else { } jTable1.setColumnSelectionInterval(activeColumn, activeColumn); jTable1.setRowSelectionInterval(minRow, maxRow); createAndShowPopupMenu(e); } } }); }
From source file:com.intuit.tank.tools.debugger.PanelBuilder.java
/** * @param debuggerActions/*from www . jav a 2s . c o m*/ * @return */ static Component createContentPanel(final AgentDebuggerFrame frame) { JSplitPane pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true); pane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); final RSyntaxTextArea scriptEditorTA = new RSyntaxTextArea(); frame.setScriptEditorTA(scriptEditorTA); scriptEditorTA.setSelectionColor(scriptEditorTA.getCurrentLineHighlightColor()); scriptEditorTA.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_NONE); scriptEditorTA.setHyperlinksEnabled(false); scriptEditorTA.setEditable(false); scriptEditorTA.setEnabled(false); scriptEditorTA.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { scriptEditorTA.grabFocus(); try { int offs = scriptEditorTA.viewToModel(e.getPoint()); if (offs > -1) { int line = scriptEditorTA.getLineOfOffset(offs); if (frame.getSteps().size() > line) { frame.fireStepChanged(line); if (e.getClickCount() == 2 && !e.isPopupTrigger()) { // show step xml try { DebugStep debugStep = frame.getSteps().get(line); String text = JaxbUtil.marshall(debugStep.getStepRun()); StepDialog dlg = new StepDialog(frame, text, SyntaxConstants.SYNTAX_STYLE_XML); dlg.setVisible(true); } catch (JAXBException e1) { frame.showError("Error showing step xml: " + e); } } } } } catch (BadLocationException ble) { ble.printStackTrace(); // Never happens } } }); RTextScrollPane scriptEditorScrollPane = new RTextScrollPane(scriptEditorTA); frame.setScriptEditorScrollPane(scriptEditorScrollPane); scriptEditorScrollPane.setIconRowHeaderEnabled(true); scriptEditorScrollPane.getGutter() .setBookmarkIcon(ActionProducer.getIcon("bullet_blue.png", IconSize.SMALL)); scriptEditorScrollPane.getGutter() .setCurrentLineIcon(ActionProducer.getIcon("current_line.png", IconSize.SMALL)); scriptEditorScrollPane.getGutter().setBookmarkingEnabled(true); pane.setLeftComponent(scriptEditorScrollPane); pane.setRightComponent(createRightPanel(frame)); pane.setDividerLocation(300); pane.setResizeWeight(0.4D); return pane; }
From source file:com.sec.ose.osi.ui.frm.main.identification.codematch.table.JPanCMTableArea.java
protected JTableInfoForCMFolder getJTableInfoForCMFolder() { if (jTableInfoForCMFolder == null) { jTableInfoForCMFolder = new JTableInfoForCMFolder(); jTableInfoForCMFolder.addKeyListener(new KeyAdapter() { public void keyReleased(java.awt.event.KeyEvent e) { keyReleasedAction(jTableInfoForCMFolder); }// ww w .jav a 2s.com }); jTableInfoForCMFolder.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { mouseClickedAction(jTableInfoForCMFolder, e); } }); } return jTableInfoForCMFolder; }
From source file:medsavant.enrichment.app.RegionListAggregatePanel.java
private void createSearchableTable() { tablePanel = new SearchableTablePanel(pageName, new String[] { "Name", "Chromosome", "Start", "End", "Length", "Variants", "Variants / KB", "Individuals" }, new Class[] { String.class, String.class, Integer.class, Integer.class, Integer.class, Integer.class, Double.class, Integer.class }, new int[0], true, true, Integer.MAX_VALUE, false, SearchableTablePanel.TableSelectionType.ROW, Integer.MAX_VALUE, new AggregationRetriever()); tablePanel.getTable().addMouseListener(new MouseAdapter() { @Override/*w ww . j a v a2 s . c om*/ public void mouseReleased(MouseEvent e) { if (SwingUtilities.isRightMouseButton(e)) { createPopup().show(e.getComponent(), e.getX(), e.getY()); } } }); showShowCard(); }
From source file:com.mirth.connect.client.ui.components.MirthTreeTable.java
public MirthTreeTable(String prefix, Set<String> defaultVisibleColumns) { customHiddenColumnMap = new HashMap<String, Set<String>>(); this.prefix = prefix; this.defaultVisibleColumns = defaultVisibleColumns; columnOrderMap = new HashMap<String, Integer>(); sortOrderColumn = -1;/* w ww . j a v a 2 s. c o m*/ sortOrder = null; if (StringUtils.isNotEmpty(prefix)) { try { userPreferences = Preferences.userNodeForPackage(Mirth.class); String columns = userPreferences.get(prefix + "ColumnOrderMap", ""); if (StringUtils.isNotEmpty(columns)) { columnOrderMap = (Map<String, Integer>) ObjectXMLSerializer.getInstance().deserialize(columns, Map.class); } } catch (Exception e) { } try { String order = userPreferences.get(prefix + "SortOrder", ""); if (StringUtils.isNotEmpty(order)) { sortOrder = ObjectXMLSerializer.getInstance().deserialize(order, SortOrder.class); sortOrderColumn = userPreferences.getInt(prefix + "SortOrderColumn", -1); } } catch (Exception e) { } } addKeyListener(new KeyListener() { public void keyPressed(KeyEvent e) { boolean isAccelerated = (((e.getModifiers() & Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()) > 0) || ((e.getModifiers() & InputEvent.CTRL_MASK) > 0)); if ((e.getKeyCode() == KeyEvent.VK_S) && isAccelerated) { PlatformUI.MIRTH_FRAME.doContextSensitiveSave(); } } public void keyReleased(KeyEvent e) { } public void keyTyped(KeyEvent e) { } }); /* * Swingx 1.0 has this set to true by default, which doesn't allow dragging and dropping * into tables. Swingx 0.8 had this set to false. Tables that want it set to true can * override it. */ putClientProperty("terminateEditOnFocusLost", Boolean.FALSE); JTableHeader header = getTableHeader(); header.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { saveColumnOrder(); } }); header.setDefaultRenderer(new SortableHeaderCellRenderer(header.getDefaultRenderer())); final JButton columnControlButton = new JButton(new ColumnControlButton(this).getIcon()); columnControlButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JPopupMenu columnMenu = getColumnMenu(); Dimension buttonSize = columnControlButton.getSize(); int xPos = columnControlButton.getComponentOrientation().isLeftToRight() ? buttonSize.width - columnMenu.getPreferredSize().width : 0; columnMenu.show(columnControlButton, xPos, columnControlButton.getHeight()); } }); setColumnControl(columnControlButton); }