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); }
/** ***************************************************************************** */ @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); }