List of usage examples for java.awt.event MouseEvent getSource
public Object getSource()
From source file:io.github.jeremgamer.editor.panels.Panels.java
public Panels(final JFrame frame, final PanelsPanel pp) { this.setBorder(BorderFactory.createTitledBorder("")); JButton add = null;//from w w w. j a va2 s. co 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((JFrame) SwingUtilities.windowForComponent(panelList), "Nommez le panneau :", "Crer un panneau", 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 PanelSave(name); PanelsPanel.updateLists(); mainPanel.addItem(name); } } 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 (panelList.getSelectedValue() != null) { File file = new File("projects/" + Editor.getProjectName() + "/panels/" + panelList.getSelectedValue() + "/" + panelList.getSelectedValue() + ".rbd"); JOptionPane jop = new JOptionPane(); @SuppressWarnings("static-access") int option = jop.showConfirmDialog((JFrame) SwingUtilities.windowForComponent(panelList), "tes-vous sr de vouloir supprimer ce panneau?", "Avertissement", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if (option == JOptionPane.OK_OPTION) { if (panelList.getSelectedValue().equals(pp.getFileName())) { pp.setFileName(""); } pp.hide(); file.delete(); File parent = new File(file.getParent()); for (File img : FileUtils.listFiles(parent, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE)) { img.delete(); } parent.delete(); mainPanel.removeItem(panelList.getSelectedValue()); data.remove(panelList.getSelectedIndex()); ActionPanel.updateLists(); PanelsPanel.updateLists(); } } } catch (NullPointerException npe) { npe.printStackTrace(); } } }); JPanel buttons = new JPanel(); buttons.setLayout(new BoxLayout(buttons, BoxLayout.LINE_AXIS)); buttons.add(add); buttons.add(remove); mainPanel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { @SuppressWarnings("unchecked") JComboBox<String> combo = (JComboBox<String>) event.getSource(); GeneralSave gs = new GeneralSave(); try { gs.load(new File("projects/" + Editor.getProjectName() + "/general.rbd")); gs.set("mainPanel", combo.getSelectedItem()); } catch (IOException e) { e.printStackTrace(); } } }); updateList(); panelList.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) { pp.load(new File("projects/" + Editor.getProjectName() + "/panels/" + list.getModel().getElementAt(index) + "/" + list.getModel().getElementAt(index) + ".rbd")); PanelsPanel.updateLists(); pp.show(); previousSelection = list.getSelectedValue(); isOpen = true; } else { try { if (previousSelection.equals(list.getModel().getElementAt(index))) { pp.hide(); previousSelection = list.getSelectedValue(); list.clearSelection(); isOpen = false; } else { pp.hideThenShow(); previousSelection = list.getSelectedValue(); pp.load(new File("projects/" + Editor.getProjectName() + "/panels/" + list.getModel().getElementAt(index) + "/" + list.getModel().getElementAt(index) + ".rbd")); PanelsPanel.updateLists(); } } catch (NullPointerException npe) { pp.hide(); list.clearSelection(); } } } else if (evt.getClickCount() == 3) { int index = list.locationToIndex(evt.getPoint()); if (isOpen == false) { pp.load(new File("projects/" + Editor.getProjectName() + "/panels/" + list.getModel().getElementAt(index) + "/" + list.getModel().getElementAt(index) + ".rbd")); PanelsPanel.updateLists(); pp.show(); previousSelection = list.getSelectedValue(); isOpen = true; } else { try { if (previousSelection.equals(list.getModel().getElementAt(index))) { pp.hide(); previousSelection = list.getSelectedValue(); list.clearSelection(); isOpen = false; } else { pp.hideThenShow(); previousSelection = list.getSelectedValue(); pp.load(new File("projects/" + Editor.getProjectName() + "/panels/" + list.getModel().getElementAt(index) + "/" + list.getModel().getElementAt(index) + ".rbd")); PanelsPanel.updateLists(); } } catch (NullPointerException npe) { pp.hide(); list.clearSelection(); } } } } }); JScrollPane listPane = new JScrollPane(panelList); listPane.getVerticalScrollBar().setUnitIncrement(Editor.SCROLL_SPEED); this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); this.add(buttons); this.add(listPane); JPanel mainPanelInput = new JPanel(); mainPanelInput.setPreferredSize(new Dimension(280, 35)); mainPanelInput.setMaximumSize(new Dimension(280, 35)); mainPanelInput.add(new JLabel("Panneau principal:")); mainPanel.setPreferredSize(new Dimension(150, 27)); mainPanelInput.add(mainPanel); this.add(mainPanelInput); }
From source file:com.ssn.event.controller.SSNShareController.java
@Override public void mouseEntered(MouseEvent e) { Object mouseEventObj = e.getSource(); if (mouseEventObj != null && mouseEventObj instanceof JLabel) { JLabel jLbl = (JLabel) mouseEventObj; if (jLbl.getName().equalsIgnoreCase("FacebookSharing")) { jLbl.setIcon(new ImageIcon(getClass().getResource("/icon/fb-hover.png"))); } else if (jLbl.getName().equalsIgnoreCase("TwitterSharing")) { jLbl.setIcon(new ImageIcon(getClass().getResource("/icon/twitter-hover.png"))); } else if (jLbl.getName().equalsIgnoreCase("moveCopy")) { jLbl.setIcon(new ImageIcon(getClass().getResource("/icon/move-hover.png"))); } else if (jLbl.getName().equalsIgnoreCase("MailSharing")) { jLbl.setIcon(new ImageIcon(getClass().getResource("/icon/mail-hover.png"))); }/*w w w. j av a 2s. c o m*/ } }
From source file:com.ssn.event.controller.SSNShareController.java
@Override public void mouseExited(MouseEvent e) { Object mouseEventObj = e.getSource(); if (mouseEventObj != null && mouseEventObj instanceof JLabel) { JLabel jLbl = (JLabel) mouseEventObj; if (jLbl.getName().equalsIgnoreCase("FacebookSharing")) { jLbl.setIcon(new ImageIcon(getClass().getResource("/icon/fb-normal.png"))); } else if (jLbl.getName().equalsIgnoreCase("TwitterSharing")) { jLbl.setIcon(new ImageIcon(getClass().getResource("/icon/twitter-normal.png"))); } else if (jLbl.getName().equalsIgnoreCase("moveCopy")) { jLbl.setIcon(new ImageIcon(getClass().getResource("/icon/move-normal.png"))); } else if (jLbl.getName().equalsIgnoreCase("MailSharing")) { jLbl.setIcon(new ImageIcon(getClass().getResource("/icon/mail-normal.png"))); }/*from w ww . ja v a 2 s. co m*/ } }
From source file:lu.lippmann.cdb.graph.mouse.CadralEditingGraphMousePlugin.java
/** * {@inheritDoc}/*ww w. j av a2 s. c o m*/ */ @Override public void mouseReleased(MouseEvent e) { //Don't create node or edge with right click ! if (!e.isPopupTrigger()) { @SuppressWarnings("unchecked") final VisualizationViewer<CNode, CEdge> vv = (VisualizationViewer<CNode, CEdge>) e.getSource(); final Point2D p = e.getPoint(); final Layout<CNode, CEdge> layout = vv.getModel().getGraphLayout(); final GraphWithOperations graph = (GraphWithOperations) layout.getGraph(); final GraphElementAccessor<CNode, CEdge> pickSupport = vv.getPickSupport(); if (pickSupport != null) { CNode vertex = pickSupport.getVertex(layout, p.getX(), p.getY()); // if no vertex create one on the fly if (vertex == null) { final CNode newNode = vertexFactory.create(); final Point2D newPos = vv.getRenderContext().getMultiLayerTransformer() .inverseTransform(e.getPoint()); graph.addVertex(newNode, new CPoint(newPos.getX(), newPos.getY())); layout.lock(newNode, false); vertex = newNode; } else { //reset to initial color if needed if (startVertex != null && !startVertex.equals(vertex)) { if (pointedVertices.containsKey(vertex)) { vertex.setColor(pointedVertices.get(vertex)); } } layout.lock(vertex, false); } // if the source & destination vertex are not the same : create edge if (vertex != null && startVertex != null) { if (!startVertex.equals(vertex)) { transformEdgeShape(down, down); transformArrowShape(down, e.getPoint()); graph.addEdge(edgeFactory.create(), startVertex, vertex, edgeIsDirected); } } } //Reset fields startVertex = null; down = null; edgeIsDirected = EdgeType.UNDIRECTED; vv.removePostRenderPaintable(edgePaintable); vv.removePostRenderPaintable(arrowPaintable); //clear color mapping map pointedVertices.clear(); dragVertex = null; lastDragVertex = null; vv.repaint(); } }
From source file:org.adempiere.apps.graph.PerformanceIndicator.java
/************************************************************************** * Mouse Clicked//from w w w . ja v a2s . c o m * @param e mouse event */ public void mouseClicked(MouseEvent e) { if (SwingUtilities.isLeftMouseButton(e) && e.getClickCount() > 1) fireActionPerformed(e); if (SwingUtilities.isRightMouseButton(e)) popupMenu.show((Component) e.getSource(), e.getX(), e.getY()); }
From source file:com.haskins.cloudtrailviewer.sidebar.AbstractChart.java
private void addTable() { defaultTableModel.addColumn(""); defaultTableModel.addColumn("Property"); defaultTableModel.addColumn("Value"); final LegendColourRenderer cellRenderer = new LegendColourRenderer(); final JTable table = new JTable(defaultTableModel) { private static final long serialVersionUID = -6272711583089149891L; @Override//from ww w . jav a 2 s .c o m public TableCellRenderer getCellRenderer(int row, int column) { if (column == 0) { return cellRenderer; } return super.getCellRenderer(row, column); } @Override public boolean isCellEditable(int row, int column) { return false; } }; table.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent me) { JTable table = (JTable) me.getSource(); String value = (String) defaultTableModel.getValueAt(table.getSelectedRow(), 1); if (me.getClickCount() == 2) { if (value.startsWith("i-")) { Event event = null; AllFilter filter = new AllFilter(); filter.setNeedle(value); for (Event searchEvent : eventDb.getEvents()) { if (filter.passesFilter(searchEvent)) { event = searchEvent; break; } } if (event != null) { AwsAccount account = AccountDao.getAccountByAcctNum(event.getRecipientAccountId()); ResourceDetailRequest request = new ResourceDetailRequest(account, event.getAwsRegion(), "EC2 Instance", value); ResourceDetailDialog.showDialog(CloudTrailViewer.frame, request); } } } else if (me.getClickCount() == 1) { try { eventTablePanel.setFilterString(value); } catch (Exception ex) { LOGGER.log(Level.WARNING, "Problem responding to mouse event on chart table", ex); } } } }); TableColumn column; for (int i = 0; i < 3; i++) { column = table.getColumnModel().getColumn(i); switch (i) { case 0: column.setMinWidth(15); column.setMaxWidth(15); column.setPreferredWidth(15); break; case 2: column.setMinWidth(70); column.setMaxWidth(70); column.setPreferredWidth(70); break; } } JScrollPane tablecrollPane = new JScrollPane(table); tablecrollPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); this.add(tablecrollPane, BorderLayout.CENTER); }
From source file:cz.muni.fi.javaseminar.kafa.bookregister.gui.MainWindow.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./*from www .ja v a 2s. co m*/ */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { authorsPanel = new javax.swing.JPanel(); authorsLabel = new javax.swing.JLabel(); authorsScrollPane = new javax.swing.JScrollPane(); authorsTable = new javax.swing.JTable(); booksPanel = new javax.swing.JPanel(); booksScrollPane = new javax.swing.JScrollPane(); booksTable = new javax.swing.JTable(); booksLabel = new javax.swing.JLabel(); mainMenuBar = new javax.swing.JMenuBar(); fileMenu = new javax.swing.JMenu(); newAuthorMenuItem = new javax.swing.JMenuItem(); newBookMenuItem = new javax.swing.JMenuItem(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("Book Register 1.0"); setMinimumSize(new java.awt.Dimension(1024, 480)); setPreferredSize(new java.awt.Dimension(1024, 640)); getContentPane().setLayout(new java.awt.GridLayout(2, 1)); authorsPanel.setLayout(new java.awt.BorderLayout()); java.util.ResourceBundle bundle = java.util.ResourceBundle .getBundle("cz/muni/fi/javaseminar/kafa/bookregister/gui/Bundle"); // NOI18N authorsLabel.setText(bundle.getString("Table.authors.title")); // NOI18N authorsPanel.add(authorsLabel, java.awt.BorderLayout.PAGE_START); authorsTable.setModel(authorsTableModel); authorsTable.setMinimumSize(new java.awt.Dimension(480, 640)); authorsScrollPane.setViewportView(authorsTable); authorsPanel.add(authorsScrollPane, java.awt.BorderLayout.CENTER); getContentPane().add(authorsPanel); booksPanel.setLayout(new java.awt.BorderLayout()); booksTable.setModel(booksTableModel); booksScrollPane.setViewportView(booksTable); booksPanel.add(booksScrollPane, java.awt.BorderLayout.CENTER); booksLabel.setText(bundle.getString("Table.books.title")); // NOI18N booksPanel.add(booksLabel, java.awt.BorderLayout.PAGE_START); getContentPane().add(booksPanel); fileMenu.setText(bundle.getString("Menu.file")); // NOI18N newAuthorMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_A, java.awt.event.InputEvent.CTRL_MASK)); newAuthorMenuItem.setText(bundle.getString("Menu.file.newAuthor")); // NOI18N newAuthorMenuItem.setMnemonic(KeyEvent.VK_N); newAuthorMenuItem.setAction(spawnNewAuthorWindowAction); newAuthorMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.CTRL_DOWN_MASK)); fileMenu.add(newAuthorMenuItem); newBookMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_B, java.awt.event.InputEvent.CTRL_MASK)); newBookMenuItem.setText(bundle.getString("Menu.file.newBook")); // NOI18N newBookMenuItem.setMnemonic(KeyEvent.VK_B); newBookMenuItem.setAction(spawnNewBookWindowAction); newBookMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_B, KeyEvent.CTRL_DOWN_MASK)); newBookMenuItem.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { JMenuItem m = (JMenuItem) e.getSource(); if (!m.isEnabled()) JOptionPane.showMessageDialog(MainWindow.this, "You have to create an author first."); } }); fileMenu.add(newBookMenuItem); fileMenu.setMnemonic(KeyEvent.VK_F); mainMenuBar.add(fileMenu); setJMenuBar(mainMenuBar); pack(); }
From source file:lu.lippmann.cdb.graph.mouse.CadralGraphMouse.java
/** * {@inheritDoc}//w w w . j av a2 s. c o m * Mode.PICKING : Move node & edge * Mode.EDITING : Add node & edge * Mode.TRANSFORMING : Move graph layout */ @Override public void mousePressed(MouseEvent e) { before.clear(); //System.out.println("Before map cleared"); if (!mode.equals(Mode.EDITING)) { @SuppressWarnings("unchecked") final VisualizationViewer<CNode, CEdge> vv = (VisualizationViewer<CNode, CEdge>) e.getSource(); final Point2D p = e.getPoint(); final Layout<CNode, CEdge> layout = vv.getModel().getGraphLayout(); final GraphElementAccessor<CNode, CEdge> pickSupport = vv.getPickSupport(); if (pickSupport != null) { final CNode vertex = pickSupport.getVertex(layout, p.getX(), p.getY()); final CEdge edge = pickSupport.getEdge(layout, p.getX(), p.getY()); if (mode.equals(Mode.TRANSFORMING)) { if (vertex != null || edge != null) { setMode(Mode.PICKING); vv.setCursor(Cursor.getPredefinedCursor(12)); } if ((vertex == null && edge == null) && (e.isShiftDown())) { setMode(Mode.PICKING); vv.setCursor(Cursor.getPredefinedCursor(12)); } } else if (mode.equals(Mode.PICKING) && !e.isShiftDown()) { if (vertex == null && edge == null) { setMode(Mode.TRANSFORMING); } } //Final choosen mode is transforming ! -> Deselect all nodes if (mode.equals(Mode.TRANSFORMING)) { commandDispatcher.dispatch(new DeselectAllCommand()); } //Save initial positions if (mode.equals(Mode.PICKING)) { if (vertex != null) { saveInitialPositionOfPickedNodes(vv); } } } } //will call either : // - CadralEditingGraphMousePlugin.mousePressed(e) // - CadralPickingGraphMousePlugin.mousePressed(e) super.mousePressed(e); //System.out.println("Coords clicked : " + e.getPoint()); }
From source file:org.broad.igv.ui.panel.PanTool.java
@Override final public void mouseDragged(final MouseEvent e) { long currentTime = System.currentTimeMillis(); if ((currentTime - lastDragEventTime) < throttleTimeMS) { return;/*from ww w .java 2 s. c o m*/ } //System.out.println("T=" + ctr); lastDragEventTime = currentTime; try { Component panel = (Component) e.getSource(); panel.setCursor(dragCursor); if (lastMousePoint == null) { lastMousePoint = e.getPoint(); return; } if (!isDragging && e.getPoint().distance(lastMousePoint) < 2) { return; } else { isDragging = true; int deltaX = lastMousePoint.x - e.getX(); int deltaY = lastMousePoint.y - e.getY(); cumulativeDeltaX += Math.abs(deltaX); cumulativeDeltaY += Math.abs(deltaY); // Test for horizontal vs vertical panning. if (cumulativeDeltaX > cumulativeDeltaY) { // Horizontal scrolling getReferenceFame().shiftOriginPixels(deltaX); } else { // Vertical Scrolling int totalYChange = (int) (lastMousePoint.getY() - e.getY()); if (totalYChange != 0) { // This section handles false drag direction changes int currentYDirection = 0; // Figure out the current drag direction currentYDirection = totalYChange / Math.abs(totalYChange); // If the previous direction is 0 we were not moving before if (previousYDirection != 0) { // See if we changed direction boolean changedYDirection = currentYDirection != previousYDirection; if (!changedYDirection) { // Don't save lastMousePressedPoint because may // be incorrect (this is the problem we are // solving with the direction flag) instead // we'll just check the next drag Point to be // sure of the correct direction. previousYDirection = currentYDirection; // If we have a vertical scrollbar use it to move if (verticalScrollBar != null) { int adjustedScrollbarValue = verticalScrollBar.getValue(); adjustedScrollbarValue += totalYChange; verticalScrollBar.setValue(adjustedScrollbarValue); } } } previousYDirection = currentYDirection; } } } } finally { lastMousePoint = e.getPoint(); // Always save the last Point } }
From source file:io.github.jeremgamer.editor.panels.Others.java
public Others(final JFrame frame, final OtherPanel op, final PanelSave ps) { this.frame = frame; this.setBorder(BorderFactory.createTitledBorder("")); JButton add = null;// www.ja v a2 s .c om 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((JFrame) SwingUtilities.windowForComponent(otherList), "Nommez le composant :", "Crer un composant", 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 OtherSave(name); ActionPanel.updateLists(); PanelsPanel.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 (otherList.getSelectedValue() != null) { File file = new File("projects/" + Editor.getProjectName() + "/others/" + otherList.getSelectedValue() + ".rbd"); JOptionPane jop = new JOptionPane(); @SuppressWarnings("static-access") int option = jop.showConfirmDialog((JFrame) SwingUtilities.windowForComponent(otherList), "tes-vous sr de vouloir supprimer ce composant?", "Avertissement", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if (option == JOptionPane.OK_OPTION) { File dir = new File("projects/" + Editor.getProjectName() + "/panels"); for (File f : FileUtils.listFilesAndDirs(dir, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE)) { if (!f.isDirectory()) { try { ps.load(f); } catch (IOException e) { e.printStackTrace(); } OtherSave os = new OtherSave(); try { os.load(file); } catch (IOException e1) { e1.printStackTrace(); } String type = null; switch (os.getInt("type")) { case 0: type = "Zone de saisie"; break; case 1: type = "Zone de saisie de mot de passe"; break; case 2: type = "Zone de saisie (Grande)"; break; case 3: type = "Case cocher"; break; case 4: type = "Menu droulant"; break; case 5: type = "Barre de progression"; break; case 6: type = "Slider"; break; case 7: type = "Spinner"; break; } for (String section : ps.getSectionsContaining( otherList.getSelectedValue() + " (" + type + ")")) { ps.removeSection(section); try { ps.save(f); } catch (IOException e) { e.printStackTrace(); } } } } if (otherList.getSelectedValue().equals(op.getFileName())) { op.setFileName(""); } op.hide(); file.delete(); data.remove(otherList.getSelectedIndex()); ActionPanel.updateLists(); OtherPanel.updateLists(); PanelsPanel.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(); otherList.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) { op.show(); op.load(new File("projects/" + Editor.getProjectName() + "/others/" + list.getModel().getElementAt(index) + ".rbd")); previousSelection = list.getSelectedValue(); isOpen = true; } else { try { if (previousSelection.equals(list.getModel().getElementAt(index))) { op.hide(); previousSelection = list.getSelectedValue(); list.clearSelection(); isOpen = false; } else { op.hideThenShow(); previousSelection = list.getSelectedValue(); op.load(new File("projects/" + Editor.getProjectName() + "/others/" + list.getModel().getElementAt(index) + ".rbd")); } } catch (NullPointerException npe) { op.hide(); list.clearSelection(); } } } else if (evt.getClickCount() == 3) { int index = list.locationToIndex(evt.getPoint()); if (isOpen == false) { op.show(); op.load(new File("projects/" + Editor.getProjectName() + "/others/" + list.getModel().getElementAt(index) + ".rbd")); previousSelection = list.getSelectedValue(); isOpen = true; } else { try { if (previousSelection.equals(list.getModel().getElementAt(index))) { op.hide(); previousSelection = list.getSelectedValue(); list.clearSelection(); isOpen = false; } else { op.hideThenShow(); previousSelection = list.getSelectedValue(); op.load(new File("projects/" + Editor.getProjectName() + "/others/" + list.getModel().getElementAt(index) + ".rbd")); } } catch (NullPointerException npe) { op.hide(); list.clearSelection(); } } } } }); JScrollPane listPane = new JScrollPane(otherList); listPane.getVerticalScrollBar().setUnitIncrement(Editor.SCROLL_SPEED); this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); this.add(buttons); this.add(listPane); OtherPanel.updateLists(); }