void initControls() { JMenuItem jmi; jmi = new JMenuItem("JImage Menu"); jmi.setEnabled(false); popupMenu.add(jmi); jmi = new JMenuItem("Fit"); jmi.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { fit = true; repaint(); } }); popupMenu.add(jmi); JMenu scaleMenu = new JMenu("Set Scale"); popupMenu.add(scaleMenu); int scales[] = new int[] {25, 50, 100, 200, 400, 800}; for (int i = 0; i < scales.length; i++) { jmi = new JMenuItem(scales[i] + " %"); jmi.addActionListener(new ScaleAction(scales[i])); scaleMenu.add(jmi); } MyListener l = new MyListener(); addMouseMotionListener(l); addMouseListener(l); addMouseWheelListener(l); addKeyListener(l); }
public void mouseExited(MouseEvent e) { // if the popup menu for is visible, don't register this, // because the popup being set visible will fire a mouseExited() event if ((popup != null) && popup.isVisible()) return; if (state[OPEN] != INACTIVE) { setState(OPEN, INACTIVE, true); } status = ""; handleMouse(e.getX(), e.getY()); }
/** ***************************************************************************** */ @Override public void handlePopupMenu(MouseEvent e) { JPopupMenu popup = new JPopupMenu(); Point pt = SwingUtilities.convertPoint(getContentPane().getParent(), e.getPoint(), draw_area); BddtHistoryItem itm = getItemAtPoint(pt.x, pt.y); if (itm != null) { popup.add(new GotoSourceAction(itm)); popup.add(new GotoStackAction(itm)); } else { GraphObject go = getObjectAtPoint(pt.x, pt.y); if (go != null && go.getValue() != null) { popup.add(new GotoValueAction(go)); } } popup.add(getFloatBubbleAction()); popup.show(draw_area, pt.x, pt.y); }
public void mousePressed(MouseEvent e) { final int x = e.getX(); final int y = e.getY(); int sel = findSelection(x, y); /// if (sel == -1) return false; if (sel == -1) return; currentRollover = -1; // int currentSelection = sel; // if (!(disableRun && ((sel == RUN) || (sel == STOP)))) { // moving the handling of this over into the editor // setState(sel, ACTIVE, true); // } // if (currentSelection == OPEN) { // switch (currentSelection) { switch (sel) { case RUN: // if (!disableRun) { editor.handleRun(e.isShiftDown()); // } break; case STOP: // if (!disableRun) { // setState(RUN, INACTIVE, true); // setInactive(); editor.handleStop(); // } break; case OPEN: if (popup == null) { // popup = new JPopupMenu(); popup = editor.sketchbook.getPopupMenu(); // no events properly being fired, so nevermind /* popup.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.out.println("action " + e); } }); popup.addComponentListener(new ComponentAdapter() { public void componentHidden(ComponentEvent e) { System.out.println("hidden " + e); } }); */ add(popup); } // activate(OPEN); // SwingUtilities.invokeLater(new Runnable() { // public void run() { popup.show(EditorButtons.this, x, y); // }}); break; case NEW: editor.handleNew(e.isShiftDown()); break; case SAVE: editor.handleSave(false); break; case EXPORT: editor.handleExport(); break; case SERIAL: editor.handleSerial(); break; } }