Search in sources :

Example 16 with MouseEvent

use of java.awt.event.MouseEvent in project zaproxy by zaproxy.

the class AbstractParamContainerPanel method getTreeParam.

/**
     * This method initializes treeParam
     *
     * @return javax.swing.JTree
     */
private JTree getTreeParam() {
    if (treeParam == null) {
        treeParam = new JTree();
        treeParam.setModel(getTreeModel());
        treeParam.setShowsRootHandles(true);
        treeParam.setRootVisible(true);
        treeParam.addTreeSelectionListener(new javax.swing.event.TreeSelectionListener() {

            @Override
            public void valueChanged(javax.swing.event.TreeSelectionEvent e) {
                DefaultMutableTreeNode node = (DefaultMutableTreeNode) getTreeParam().getLastSelectedPathComponent();
                if (node == null) {
                    return;
                }
                String name = (String) node.getUserObject();
                showParamPanel(name);
            }
        });
        DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
        renderer.setLeafIcon(null);
        renderer.setOpenIcon(null);
        renderer.setClosedIcon(null);
        treeParam.setCellRenderer(renderer);
        treeParam.setRowHeight(DisplayUtils.getScaledSize(18));
        treeParam.addMouseListener(new MouseAdapter() {

            @Override
            public void mousePressed(MouseEvent e) {
                TreePath path = treeParam.getClosestPathForLocation(e.getX(), e.getY());
                if (path != null && !treeParam.isPathSelected(path)) {
                    treeParam.setSelectionPath(path);
                }
            }
        });
    }
    return treeParam;
}
Also used : JTree(javax.swing.JTree) MouseEvent(java.awt.event.MouseEvent) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) TreePath(javax.swing.tree.TreePath) MouseAdapter(java.awt.event.MouseAdapter) DefaultTreeCellRenderer(javax.swing.tree.DefaultTreeCellRenderer)

Example 17 with MouseEvent

use of java.awt.event.MouseEvent in project antlrworks by antlr.

the class XJRollOverButton method init.

private void init() {
    setBorderPainted(false);
    setFocusable(false);
    setIconTextGap(0);
    setMargin(new Insets(0, 0, 0, 0));
    setContentAreaFilled(false);
    addMouseListener(new MouseAdapter() {

        @Override
        public void mouseEntered(MouseEvent e) {
            inside = true;
            repaint();
        }

        @Override
        public void mouseExited(MouseEvent e) {
            inside = false;
            repaint();
        }
    });
}
Also used : MouseEvent(java.awt.event.MouseEvent) MouseAdapter(java.awt.event.MouseAdapter)

Example 18 with MouseEvent

use of java.awt.event.MouseEvent in project processing by processing.

the class JavaTextAreaPainter method startTweakMode.

protected void startTweakMode() {
    addMouseListener(new MouseListener() {

        @Override
        public void mouseReleased(MouseEvent e) {
            if (mouseHandle != null) {
                mouseHandle.resetProgress();
                mouseHandle = null;
                updateCursor(e.getX(), e.getY());
                repaint();
            }
        }

        @Override
        public void mousePressed(MouseEvent e) {
            int currentTab = getCurrentCodeIndex();
            // check for clicks on number handles
            for (Handle n : handles.get(currentTab)) {
                if (n.pick(e.getX(), e.getY())) {
                    cursorType = -1;
                    JavaTextAreaPainter.this.setCursor(blankCursor);
                    mouseHandle = n;
                    mouseHandle.setCenterX(e.getX());
                    repaint();
                    return;
                }
            }
            // check for clicks on color boxes
            for (ColorControlBox box : colorBoxes.get(currentTab)) {
                if (box.pick(e.getX(), e.getY())) {
                    if (colorSelector != null) {
                        // we already show a color selector, close it
                        colorSelector.frame.dispatchEvent(new WindowEvent(colorSelector.frame, WindowEvent.WINDOW_CLOSING));
                    }
                    colorSelector = new ColorSelector(box);
                    colorSelector.frame.addWindowListener(new WindowAdapter() {

                        public void windowClosing(WindowEvent e) {
                            colorSelector.frame.setVisible(false);
                            colorSelector = null;
                        }
                    });
                    colorSelector.show(getLocationOnScreen().x + e.getX() + 30, getLocationOnScreen().y + e.getY() - 130);
                }
            }
        }

        @Override
        public void mouseExited(MouseEvent e) {
        }

        @Override
        public void mouseEntered(MouseEvent e) {
        }

        @Override
        public void mouseClicked(MouseEvent e) {
        }
    });
    addMouseMotionListener(new MouseMotionListener() {

        @Override
        public void mouseMoved(MouseEvent e) {
            updateCursor(e.getX(), e.getY());
            if (!Settings.alwaysShowColorBoxes) {
                showHideColorBoxes(e.getY());
            }
        }

        @Override
        public void mouseDragged(MouseEvent e) {
            if (mouseHandle != null) {
                // set the current drag amount of the arrows
                mouseHandle.setCurrentX(e.getX());
                // update code text with the new value
                updateCodeText();
                if (colorSelector != null) {
                    colorSelector.refreshColor();
                }
                repaint();
            }
        }
    });
    tweakMode = true;
    setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    repaint();
}
Also used : MouseListener(java.awt.event.MouseListener) MouseEvent(java.awt.event.MouseEvent) WindowEvent(java.awt.event.WindowEvent) WindowAdapter(java.awt.event.WindowAdapter) ColorControlBox(processing.mode.java.tweak.ColorControlBox) ColorSelector(processing.mode.java.tweak.ColorSelector) MouseMotionListener(java.awt.event.MouseMotionListener) Cursor(java.awt.Cursor) Handle(processing.mode.java.tweak.Handle)

Example 19 with MouseEvent

use of java.awt.event.MouseEvent in project buck by facebook.

the class BuckToolWindowFactory method createBuildInfoPanel.

private JComponent createBuildInfoPanel(Project project) {
    Tree result = new Tree(BuckUIManager.getInstance(project).getTreeModel());
    result.addMouseListener(new MouseListener() {

        @Override
        public void mouseClicked(MouseEvent e) {
            Tree tree = (Tree) e.getComponent();
            int selRow = tree.getRowForLocation(e.getX(), e.getY());
            TreePath selPath = tree.getPathForLocation(e.getX(), e.getY());
            if (selRow != -1 && e.getClickCount() == 2) {
                TreeNode node = (TreeNode) selPath.getLastPathComponent();
                if (node.isLeaf()) {
                    BuckTreeNodeDetail buckNode = (BuckTreeNodeDetail) node;
                    if (buckNode instanceof BuckTreeNodeDetailError) {
                        BuckToolWindowFactory.this.handleClickOnError((BuckTreeNodeDetailError) buckNode);
                    }
                }
            }
        }

        @Override
        public void mousePressed(MouseEvent e) {
        }

        @Override
        public void mouseReleased(MouseEvent e) {
        }

        @Override
        public void mouseEntered(MouseEvent e) {
        }

        @Override
        public void mouseExited(MouseEvent e) {
        }
    });
    result.setCellRenderer(new BuckTreeCellRenderer());
    result.setShowsRootHandles(false);
    result.setRowHeight(0);
    JBScrollPane treeView = new JBScrollPane(result);
    return treeView;
}
Also used : MouseListener(java.awt.event.MouseListener) MouseEvent(java.awt.event.MouseEvent) TreePath(javax.swing.tree.TreePath) TreeNode(javax.swing.tree.TreeNode) Tree(com.intellij.ui.treeStructure.Tree) BuckTreeNodeDetailError(com.facebook.buck.intellij.ideabuck.ui.tree.BuckTreeNodeDetailError) BuckTreeCellRenderer(com.facebook.buck.intellij.ideabuck.ui.tree.renderers.BuckTreeCellRenderer) JBScrollPane(com.intellij.ui.components.JBScrollPane) BuckTreeNodeDetail(com.facebook.buck.intellij.ideabuck.ui.tree.BuckTreeNodeDetail)

Example 20 with MouseEvent

use of java.awt.event.MouseEvent in project languagetool by languagetool-org.

the class LanguageToolSupport method init.

private void init() {
    try {
        config = new Configuration(new File(System.getProperty("user.home")), CONFIG_FILE, null);
    } catch (IOException ex) {
        throw new RuntimeException("Could not load configuration", ex);
    }
    Language defaultLanguage = config.getLanguage();
    if (defaultLanguage == null) {
        defaultLanguage = Languages.getLanguageForLocale(Locale.getDefault());
    }
    /**
     * Warm-up: we have a lot of lazy init in LT, which causes the first check to
     * be very slow (several seconds) for languages with a lot of data and a lot of
     * rules. We just assume that the default language is the language that the user
     * often uses and init the LT object for that now, not just when it's first used.
     * This makes the first check feel much faster:
     */
    reloadLanguageTool(defaultLanguage);
    checkExecutor = new ScheduledThreadPoolExecutor(1, new ThreadFactory() {

        @Override
        public Thread newThread(Runnable r) {
            Thread t = new Thread(r);
            t.setDaemon(true);
            t.setPriority(Thread.MIN_PRIORITY);
            t.setName(t.getName() + "-lt-background");
            return t;
        }
    });
    check = new AtomicInteger(0);
    this.textComponent.getDocument().addDocumentListener(new DocumentListener() {

        @Override
        public void insertUpdate(DocumentEvent e) {
            mustDetectLanguage = config.getAutoDetect();
            recalculateSpans(e.getOffset(), e.getLength(), false);
            if (backgroundCheckEnabled) {
                checkDelayed(null);
            }
        }

        @Override
        public void removeUpdate(DocumentEvent e) {
            mustDetectLanguage = config.getAutoDetect();
            recalculateSpans(e.getOffset(), e.getLength(), true);
            if (backgroundCheckEnabled) {
                checkDelayed(null);
            }
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            mustDetectLanguage = config.getAutoDetect();
            if (backgroundCheckEnabled) {
                checkDelayed(null);
            }
        }
    });
    mouseListener = new MouseListener() {

        @Override
        public void mouseClicked(MouseEvent me) {
        }

        @Override
        public void mousePressed(MouseEvent me) {
            if (me.isPopupTrigger()) {
                showPopup(me);
            }
        }

        @Override
        public void mouseReleased(MouseEvent me) {
            if (me.isPopupTrigger()) {
                showPopup(me);
            }
        }

        @Override
        public void mouseEntered(MouseEvent me) {
        }

        @Override
        public void mouseExited(MouseEvent me) {
        }
    };
    this.textComponent.addMouseListener(mouseListener);
    actionListener = e -> _actionPerformed(e);
    mustDetectLanguage = config.getAutoDetect();
    if (!this.textComponent.getText().isEmpty() && backgroundCheckEnabled) {
        checkImmediately(null);
    }
}
Also used : ThreadFactory(java.util.concurrent.ThreadFactory) MouseEvent(java.awt.event.MouseEvent) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) IOException(java.io.IOException) MouseListener(java.awt.event.MouseListener) Language(org.languagetool.Language) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) File(java.io.File)

Aggregations

MouseEvent (java.awt.event.MouseEvent)407 MouseAdapter (java.awt.event.MouseAdapter)201 JLabel (javax.swing.JLabel)78 JPanel (javax.swing.JPanel)71 ActionEvent (java.awt.event.ActionEvent)60 JScrollPane (javax.swing.JScrollPane)53 ActionListener (java.awt.event.ActionListener)52 Dimension (java.awt.Dimension)51 BorderLayout (java.awt.BorderLayout)46 JButton (javax.swing.JButton)45 Point (java.awt.Point)44 MouseListener (java.awt.event.MouseListener)41 Insets (java.awt.Insets)40 KeyEvent (java.awt.event.KeyEvent)36 JTable (javax.swing.JTable)34 GridBagConstraints (java.awt.GridBagConstraints)33 KeyAdapter (java.awt.event.KeyAdapter)30 JTextField (javax.swing.JTextField)30 GridBagLayout (java.awt.GridBagLayout)27 ListSelectionEvent (javax.swing.event.ListSelectionEvent)26