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;
}
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();
}
});
}
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();
}
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;
}
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);
}
}
Aggregations