Package net.sf.jpluck.swing

Examples of net.sf.jpluck.swing.PopupListener


                    if (SwingUtilities.isLeftMouseButton(ev) && (ev.getClickCount() == 2)) {
                        editAction.actionPerformed(null);
                    }
                }
            });
        tableList.addMouseListener(new PopupListener(tableList, popupMenu) {
                protected void checkPopup(MouseEvent e) {
                    if (e.isPopupTrigger()) {
                        Point p = new Point(e.getX(), e.getY());
                        int idx = tableList.rowAtPoint(p);
                        int[] rows = tableList.getSelectedRows();
                        boolean inSelection = false;
                        for (int i = 0; i < rows.length; i++) {
                            if (rows[i] == idx) {
                                inSelection = true;
                                break;
                            }
                        }
                        if (!inSelection && (idx > -1)) {
                            tableList.setRowSelectionInterval(idx, idx);
                        }
                        this.popupMenu.show(component, e.getX(), e.getY());
                    }
                }
            });

        JPopupMenu tableHeaderMenu = new JPopupMenu();
        JMenuItem optimizeColumnWidths = new JMenuItem("Optimal Column Widths");
        optimizeColumnWidths.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    tableList.optimizeWidths(4);
                }
            });
        tableHeaderMenu.add(optimizeColumnWidths);
        tableList.getTableHeader().addMouseListener(new PopupListener(tableList.getTableHeader(), tableHeaderMenu));
        tableList.sortByColumn(0);

        JScrollPane scrollPane = new JScrollPane(tableList);
        scrollPane.getViewport().setBackground(UIManager.getColor("Table.background"));
        scrollPane.setBorder(new EmptyBorder(0, 0, 0, 0));
        scrollPane.getViewport().addMouseListener(new PopupListener(tableList, popupMenu));

        Container c = getContentPane();
        c.add(BorderLayout.NORTH, toolBar);
        c.add(BorderLayout.CENTER, scrollPane);
View Full Code Here


                            showcasePanel.showPreview(document.getName());
                        }
                    }
                }
            });
        tableList.addMouseListener(new PopupListener(tableList, popupMenu) {
                protected void checkPopup(MouseEvent e) {
                    if (e.isPopupTrigger()) {
                        Point p = new Point(e.getX(), e.getY());
                        int idx = tableList.rowAtPoint(p);
                        int[] rows = tableList.getSelectedRows();
View Full Code Here

TOP

Related Classes of net.sf.jpluck.swing.PopupListener

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.