Search in sources :

Example 96 with MouseAdapter

use of java.awt.event.MouseAdapter in project Botnak by Gocnak.

the class BaseTableHeaderUI method installListeners.

public void installListeners() {
    super.installListeners();
    myMouseAdapter = new MouseAdapter() {

        public void mouseReleased(MouseEvent e) {
            if ((header == null) || (header.getTable() == null)) {
                return;
            }
            boolean rolloverEnabled = Boolean.TRUE.equals(header.getClientProperty("rolloverEnabled"));
            boolean sortingAllowed = false;
            if (JTattooUtilities.getJavaVersion() >= 1.6) {
                sortingAllowed = header.getTable().getRowSorter() != null;
            }
            if (rolloverEnabled || sortingAllowed || header.getReorderingAllowed()) {
                if (header.getBounds().contains(e.getPoint())) {
                    int oldRolloverCol = rolloverCol;
                    rolloverCol = header.getColumnModel().getColumnIndexAtX(e.getX());
                    updateRolloverColumn(oldRolloverCol, rolloverCol);
                } else {
                    int oldRolloverCol = rolloverCol;
                    rolloverCol = -1;
                    updateRolloverColumn(oldRolloverCol, rolloverCol);
                }
            }
        }

        public void mouseEntered(MouseEvent e) {
            if ((header == null) || (header.getTable() == null)) {
                return;
            }
            boolean rolloverEnabled = Boolean.TRUE.equals(header.getClientProperty("rolloverEnabled"));
            boolean sortingAllowed = false;
            if (JTattooUtilities.getJavaVersion() >= 1.6) {
                sortingAllowed = header.getTable().getRowSorter() != null;
            }
            if (rolloverEnabled || sortingAllowed || header.getReorderingAllowed()) {
                int oldRolloverCol = rolloverCol;
                rolloverCol = header.getColumnModel().getColumnIndexAtX(e.getX());
                updateRolloverColumn(oldRolloverCol, rolloverCol);
            }
        }

        public void mouseExited(MouseEvent e) {
            if ((header == null) || (header.getTable() == null)) {
                return;
            }
            boolean rolloverEnabled = Boolean.TRUE.equals(header.getClientProperty("rolloverEnabled"));
            boolean sortingAllowed = false;
            if (JTattooUtilities.getJavaVersion() >= 1.6) {
                sortingAllowed = header.getTable().getRowSorter() != null;
            }
            if (rolloverEnabled || sortingAllowed || header.getReorderingAllowed()) {
                int oldRolloverCol = rolloverCol;
                rolloverCol = -1;
                updateRolloverColumn(oldRolloverCol, rolloverCol);
            }
        }
    };
    myMouseMotionAdapter = new MouseMotionAdapter() {

        public void mouseMoved(MouseEvent e) {
            if ((header == null) || (header.getTable() == null)) {
                return;
            }
            boolean rolloverEnabled = Boolean.TRUE.equals(header.getClientProperty("rolloverEnabled"));
            boolean sortingAllowed = false;
            if (JTattooUtilities.getJavaVersion() >= 1.6) {
                sortingAllowed = header.getTable().getRowSorter() != null;
            }
            if (rolloverEnabled || sortingAllowed || header.getReorderingAllowed()) {
                if (header.getDraggedColumn() == null) {
                    int oldRolloverCol = rolloverCol;
                    rolloverCol = header.getColumnModel().getColumnIndexAtX(e.getX());
                    updateRolloverColumn(oldRolloverCol, rolloverCol);
                }
            }
        }

        public void mouseDragged(MouseEvent e) {
            if ((header == null) || (header.getTable() == null)) {
                return;
            }
            boolean rolloverEnabled = Boolean.TRUE.equals(header.getClientProperty("rolloverEnabled"));
            boolean sortingAllowed = false;
            if (JTattooUtilities.getJavaVersion() >= 1.6) {
                sortingAllowed = header.getTable().getRowSorter() != null;
            }
            if (rolloverEnabled || sortingAllowed || header.getReorderingAllowed()) {
                if (header.getDraggedColumn() != null && header.getDraggedColumn().getIdentifier() != null) {
                    rolloverCol = header.getColumnModel().getColumnIndex(header.getDraggedColumn().getIdentifier());
                } else if (header.getResizingColumn() != null) {
                    rolloverCol = -1;
                }
            }
        }
    };
    header.addMouseListener(myMouseAdapter);
    header.addMouseMotionListener(myMouseMotionAdapter);
}
Also used : MouseMotionAdapter(java.awt.event.MouseMotionAdapter) MouseEvent(java.awt.event.MouseEvent) MouseAdapter(java.awt.event.MouseAdapter)

Example 97 with MouseAdapter

use of java.awt.event.MouseAdapter in project CoreNLP by stanfordnlp.

the class DisplayMatchesPanel method getTreeJPanel.

// END - sebschu
private ScrollableTreeJPanel getTreeJPanel(Tree t, List<Tree> matchedParts) {
    final ScrollableTreeJPanel treeJP = new ScrollableTreeJPanel(SwingConstants.CENTER, SwingConstants.TOP);
    treeJP.setFontName(fontName);
    treeJP.setFontSize(fontSize);
    treeJP.setDefaultColor(defaultColor);
    treeJP.setMatchedColor(matchedColor);
    treeJP.setTree(t);
    treeJP.setMatchedParts(matchedParts);
    treeJP.setBackground(Color.WHITE);
    treeJP.setFocusable(true);
    final JPopupMenu treePopup = new JPopupMenu();
    JMenuItem copy = new JMenuItem("Copy");
    copy.setActionCommand((String) TransferHandler.getCopyAction().getValue(Action.NAME));
    copy.addActionListener(new TregexGUI.TransferActionListener());
    int mask = TregexGUI.isMacOSX() ? InputEvent.META_MASK : InputEvent.CTRL_MASK;
    copy.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, mask));
    treePopup.add(copy);
    JMenuItem exportTree = new JMenuItem("Export tree as image");
    exportTree.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            doExportTree();
        }
    });
    treePopup.add(exportTree);
    //BEGIN - sebschu
    JMenuItem showDependencies = new JMenuItem("Show dependencies");
    showDependencies.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            showDependencies();
        }
    });
    treePopup.add(showDependencies);
    JMenuItem showUniversalDependencies = new JMenuItem("Show universal dependencies");
    showUniversalDependencies.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            showUniversalDependencies();
        }
    });
    treePopup.add(showUniversalDependencies);
    //END - sebschu
    treeJP.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            treeJP.requestFocusInWindow();
        }

        private void maybeShowPopup(MouseEvent e) {
            if (e.isPopupTrigger())
                treePopup.show(e.getComponent(), e.getX(), e.getY());
        }

        @Override
        public void mousePressed(MouseEvent e) {
            maybeShowPopup(e);
        }

        @Override
        public void mouseReleased(MouseEvent e) {
            maybeShowPopup(e);
        }
    });
    DisplayMouseMotionAdapter d = new DisplayMouseMotionAdapter();
    treeJP.addMouseMotionListener(d);
    treeJP.addMouseListener(d);
    treeJP.setTransferHandler(new DisplayTransferHandler());
    InputMap imap = treeJP.getInputMap();
    imap.put(KeyStroke.getKeyStroke("ctrl C"), TransferHandler.getCopyAction().getValue(Action.NAME));
    ActionMap map = treeJP.getActionMap();
    map.put(TransferHandler.getCopyAction().getValue(Action.NAME), TransferHandler.getCopyAction());
    return treeJP;
}
Also used : MouseEvent(java.awt.event.MouseEvent) ActionEvent(java.awt.event.ActionEvent) MouseAdapter(java.awt.event.MouseAdapter) ActionListener(java.awt.event.ActionListener)

Example 98 with MouseAdapter

use of java.awt.event.MouseAdapter in project EnrichmentMapApp by BaderLab.

the class DataSetSelector method getTableScrollPane.

private JScrollPane getTableScrollPane() {
    if (tableScrollPane == null) {
        tableScrollPane = new JScrollPane();
        tableScrollPane.setViewportView(getTable());
        final Color bg = UIManager.getColor("Table.background");
        tableScrollPane.setBackground(bg);
        tableScrollPane.getViewport().setBackground(bg);
        tableScrollPane.getViewport().addMouseListener(new MouseAdapter() {

            @Override
            public void mousePressed(MouseEvent e) {
                getTable().clearSelection();
            }
        });
    }
    return tableScrollPane;
}
Also used : JScrollPane(javax.swing.JScrollPane) MouseEvent(java.awt.event.MouseEvent) Color(java.awt.Color) MouseAdapter(java.awt.event.MouseAdapter)

Example 99 with MouseAdapter

use of java.awt.event.MouseAdapter in project EnrichmentMapApp by BaderLab.

the class DataSetSelector method getTable.

private JTable getTable() {
    if (table == null) {
        final DefaultSelectorTableCellRenderer defRenderer = new DefaultSelectorTableCellRenderer();
        final CheckBoxTableCellRenderer checkBoxRenderer = new CheckBoxTableCellRenderer();
        table = new JTable(new DefaultTableModel(HEARDER_NAMES, 0)) {

            @Override
            public TableCellRenderer getCellRenderer(int row, int column) {
                if (column == SELECTED_COL_IDX)
                    return checkBoxRenderer;
                return defRenderer;
            }
        };
        table.setTableHeader(null);
        table.setShowGrid(false);
        JTextField tmpField = new JTextField();
        makeSmall(tmpField);
        table.setRowHeight(Math.max(table.getRowHeight(), tmpField.getPreferredSize().height - 4));
        table.setIntercellSpacing(new Dimension(0, 1));
        table.getSelectionModel().addListSelectionListener(e -> {
            if (!e.getValueIsAdjusting()) {
                updateRemoveButton();
                if (table.getSelectedRowCount() > 0)
                    previousSelectedRows = Arrays.stream(table.getSelectedRows()).boxed().collect(Collectors.toList());
            }
        });
        table.addMouseListener(new MouseAdapter() {

            @Override
            public void mousePressed(MouseEvent e) {
                final boolean isMac = LookAndFeelUtil.isMac();
                // COMMAND button down on MacOS (or CONTROL button down on another OS) or SHIFT?
                if ((isMac && e.isMetaDown()) || (!isMac && e.isControlDown()) || e.isShiftDown())
                    // Ignore!
                    return;
                final int col = table.columnAtPoint(e.getPoint());
                if (col == SELECTED_COL_IDX) {
                    final int row = table.rowAtPoint(e.getPoint());
                    // Restore previous multiple-row selection first
                    if (previousSelectedRows != null && previousSelectedRows.contains(row)) {
                        for (int i : previousSelectedRows) table.addRowSelectionInterval(i, i);
                    }
                    toggleChecked(row);
                }
            }
        });
    }
    return table;
}
Also used : TableCellRenderer(javax.swing.table.TableCellRenderer) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer) MouseEvent(java.awt.event.MouseEvent) JTable(javax.swing.JTable) DefaultTableModel(javax.swing.table.DefaultTableModel) MouseAdapter(java.awt.event.MouseAdapter) Dimension(java.awt.Dimension) JTextField(javax.swing.JTextField)

Example 100 with MouseAdapter

use of java.awt.event.MouseAdapter in project azure-tools-for-java by Microsoft.

the class CreateRedisCacheForm method initWidgetListeners.

private void initWidgetListeners() {
    txtRedisName.getDocument().addDocumentListener(new DocumentListener() {

        @Override
        public void insertUpdate(DocumentEvent documentEvent) {
            validateEmptyFields();
        }

        @Override
        public void removeUpdate(DocumentEvent documentEvent) {
            validateEmptyFields();
        }

        @Override
        public void changedUpdate(DocumentEvent documentEvent) {
            validateEmptyFields();
        }
    });
    cbSubs.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            currentSub = (SubscriptionDetail) cbSubs.getSelectedItem();
            fillLocationsAndResourceGrps(currentSub);
            validateEmptyFields();
        }
    });
    rdoCreateNewGrp.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            txtNewResGrp.setVisible(true);
            cbUseExist.setVisible(false);
            newResGrp = true;
            validateEmptyFields();
        }
    });
    txtNewResGrp.getDocument().addDocumentListener(new DocumentListener() {

        @Override
        public void insertUpdate(DocumentEvent documentEvent) {
            validateEmptyFields();
        }

        @Override
        public void removeUpdate(DocumentEvent documentEvent) {
            validateEmptyFields();
        }

        @Override
        public void changedUpdate(DocumentEvent documentEvent) {
            validateEmptyFields();
        }
    });
    rdoUseExist.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            txtNewResGrp.setVisible(false);
            cbUseExist.setVisible(true);
            newResGrp = false;
            validateEmptyFields();
        }
    });
    cbUseExist.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            validateEmptyFields();
        }
    });
    cbLocations.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            validateEmptyFields();
        }
    });
    lblPricing.addMouseListener(new LinkListener(PRICING_LINK));
    cbPricing.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            validateEmptyFields();
        }
    });
    chkNoSSL.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            if (chkNoSSL.isSelected()) {
                noSSLPort = true;
            } else {
                noSSLPort = false;
            }
        }
    });
    cbLocations.setRenderer(new ListCellRendererWrapper<Object>() {

        @Override
        public void customize(JList jList, Object o, int i, boolean b, boolean b1) {
            if (o != null && (o instanceof Location)) {
                setText("  " + ((Location) o).displayName());
            }
        }
    });
}
Also used : DocumentListener(javax.swing.event.DocumentListener) MouseEvent(java.awt.event.MouseEvent) LinkListener(com.microsoft.intellij.helpers.LinkListener) ActionEvent(java.awt.event.ActionEvent) MouseAdapter(java.awt.event.MouseAdapter) DocumentEvent(javax.swing.event.DocumentEvent) ActionListener(java.awt.event.ActionListener) SubscriptionDetail(com.microsoft.azuretools.authmanage.models.SubscriptionDetail) Location(com.microsoft.azure.management.resources.Location)

Aggregations

MouseAdapter (java.awt.event.MouseAdapter)147 MouseEvent (java.awt.event.MouseEvent)144 JLabel (javax.swing.JLabel)31 JPanel (javax.swing.JPanel)30 ActionEvent (java.awt.event.ActionEvent)28 JButton (javax.swing.JButton)27 ActionListener (java.awt.event.ActionListener)25 BorderLayout (java.awt.BorderLayout)23 JScrollPane (javax.swing.JScrollPane)22 Dimension (java.awt.Dimension)17 KeyEvent (java.awt.event.KeyEvent)17 KeyAdapter (java.awt.event.KeyAdapter)16 FlowLayout (java.awt.FlowLayout)13 JTextField (javax.swing.JTextField)13 ListSelectionEvent (javax.swing.event.ListSelectionEvent)12 IOException (java.io.IOException)11 ListSelectionListener (javax.swing.event.ListSelectionListener)11 Insets (java.awt.Insets)10 JTable (javax.swing.JTable)10 NotNull (org.jetbrains.annotations.NotNull)10