Search in sources :

Example 6 with MouseMotionListener

use of java.awt.event.MouseMotionListener in project JMRI by JMRI.

the class DrawRectangle method makeParamsPanel.

@Override
protected JPanel makeParamsPanel(PositionableShape ps) {
    JPanel panel = super.makeParamsPanel(ps);
    JPanel p = new JPanel();
    p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
    JPanel pp = new JPanel();
    _widthText = new JTextField(6);
    _width = ps.getWidth();
    _widthText.setText(Integer.toString(_width));
    _widthText.setHorizontalAlignment(JTextField.RIGHT);
    pp.add(_widthText);
    pp.add(new JLabel(Bundle.getMessage("width")));
    p.add(pp);
    p.add(Box.createHorizontalStrut(STRUT_SIZE));
    _widthText.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            _shape.setWidth(Integer.parseInt(_widthText.getText()));
            updateShape();
        }
    });
    pp = new JPanel();
    _heightText = new JTextField(6);
    _height = ps.getHeight();
    _heightText.setText(Integer.toString(_height));
    _heightText.setHorizontalAlignment(JTextField.RIGHT);
    pp.add(_heightText);
    pp.add(new JLabel(Bundle.getMessage("height")));
    p.add(pp);
    _heightText.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            _shape.setHeight(Integer.parseInt(_heightText.getText()));
            updateShape();
        }
    });
    p.addMouseMotionListener(new MouseMotionListener() {

        @Override
        public void mouseDragged(MouseEvent e) {
            updateShape();
        }

        @Override
        public void mouseMoved(MouseEvent e) {
            int w = Integer.parseInt(_widthText.getText());
            int h = Integer.parseInt(_heightText.getText());
            if (w != _shape.getWidth() || h != _shape.getHeight()) {
                _shape.setHeight(h);
                _shape.setWidth(w);
                updateShape();
            }
        }
    });
    panel.add(p);
    panel.add(Box.createVerticalStrut(STRUT_SIZE));
    return panel;
}
Also used : JPanel(javax.swing.JPanel) MouseEvent(java.awt.event.MouseEvent) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) JLabel(javax.swing.JLabel) JTextField(javax.swing.JTextField) MouseMotionListener(java.awt.event.MouseMotionListener)

Example 7 with MouseMotionListener

use of java.awt.event.MouseMotionListener in project JMRI by JMRI.

the class DrawRoundRect method makeParamsPanel.

@Override
protected JPanel makeParamsPanel(PositionableShape ps) {
    JPanel panel = super.makeParamsPanel(ps);
    JPanel p = new JPanel();
    p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
    JPanel pp = new JPanel();
    _radiusText = new JTextField(6);
    _radiusText.setText(Integer.toString(((PositionableRoundRect) ps).getCornerRadius()));
    _radiusText.setHorizontalAlignment(JTextField.RIGHT);
    pp.add(_radiusText);
    _radiusText.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            ((PositionableRoundRect) _shape).setCornerRadius(Integer.parseInt(_radiusText.getText()));
            updateShape();
        }
    });
    _radiusText.addMouseMotionListener(new MouseMotionListener() {

        @Override
        public void mouseDragged(MouseEvent e) {
            updateShape();
        }

        @Override
        public void mouseMoved(MouseEvent e) {
            ((PositionableRoundRect) _shape).setCornerRadius(Integer.parseInt(_radiusText.getText()));
            updateShape();
        }
    });
    pp.add(new JLabel(Bundle.getMessage("cornerRadius")));
    p.add(pp);
    panel.add(p);
    panel.add(Box.createVerticalStrut(STRUT_SIZE));
    return panel;
}
Also used : JPanel(javax.swing.JPanel) MouseEvent(java.awt.event.MouseEvent) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) JLabel(javax.swing.JLabel) JTextField(javax.swing.JTextField) MouseMotionListener(java.awt.event.MouseMotionListener)

Example 8 with MouseMotionListener

use of java.awt.event.MouseMotionListener in project Purus-Pasta by puruscor.

the class HavenPanel method init.

public void init() {
    setFocusTraversalKeysEnabled(false);
    newui(null);
    addKeyListener(new KeyAdapter() {

        public void keyTyped(KeyEvent e) {
            synchronized (events) {
                events.add(e);
                events.notifyAll();
            }
        }

        public void keyPressed(KeyEvent e) {
            synchronized (events) {
                events.add(e);
                events.notifyAll();
            }
        }

        public void keyReleased(KeyEvent e) {
            synchronized (events) {
                events.add(e);
                events.notifyAll();
            }
        }
    });
    addMouseListener(new MouseAdapter() {

        public void mousePressed(MouseEvent e) {
            synchronized (events) {
                events.add(e);
                events.notifyAll();
            }
        }

        public void mouseReleased(MouseEvent e) {
            synchronized (events) {
                events.add(e);
                events.notifyAll();
            }
        }
    });
    addMouseMotionListener(new MouseMotionListener() {

        public void mouseDragged(MouseEvent e) {
            synchronized (events) {
                mousemv = e;
            }
        }

        public void mouseMoved(MouseEvent e) {
            synchronized (events) {
                mousemv = e;
            }
        }
    });
    addMouseWheelListener(new MouseWheelListener() {

        public void mouseWheelMoved(MouseWheelEvent e) {
            synchronized (events) {
                events.add(e);
                events.notifyAll();
            }
        }
    });
    inited = true;
}
Also used : KeyEvent(java.awt.event.KeyEvent) MouseEvent(java.awt.event.MouseEvent) MouseWheelEvent(java.awt.event.MouseWheelEvent) KeyAdapter(java.awt.event.KeyAdapter) MouseAdapter(java.awt.event.MouseAdapter) MouseWheelListener(java.awt.event.MouseWheelListener) MouseMotionListener(java.awt.event.MouseMotionListener)

Example 9 with MouseMotionListener

use of java.awt.event.MouseMotionListener in project com.revolsys.open by revolsys.

the class MouseOverlay method mouseMoved.

@Override
public void mouseMoved(final MouseEvent event) {
    updateEventPoint(event);
    try {
        requestFocusInWindow();
        this.mapPanel.mouseMovedCloseSelected(event);
        for (final Component overlay : getOverlays()) {
            if (overlay instanceof MouseMotionListener) {
                final MouseMotionListener listener = (MouseMotionListener) overlay;
                listener.mouseMoved(event);
                if (event.isConsumed()) {
                    return;
                }
            }
        }
    } catch (final RuntimeException e) {
        Logs.error(this, "Mouse move error", e);
    }
}
Also used : JComponent(javax.swing.JComponent) Component(java.awt.Component) MouseMotionListener(java.awt.event.MouseMotionListener)

Example 10 with MouseMotionListener

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

the class VMWizardModel method configStepList.

public void configStepList(JList list, int step) {
    list.setListData(getStepTitleList());
    list.setSelectedIndex(step);
    list.setBorder(new EmptyBorder(10, 0, 10, 0));
    list.setCellRenderer(new DefaultListCellRenderer() {

        @Override
        public Component getListCellRendererComponent(JList mylist, Object o, int i, boolean b, boolean b1) {
            return super.getListCellRendererComponent(mylist, "  " + o.toString(), i, b, b1);
        }
    });
    for (MouseListener mouseListener : list.getMouseListeners()) {
        list.removeMouseListener(mouseListener);
    }
    for (MouseMotionListener mouseMotionListener : list.getMouseMotionListeners()) {
        list.removeMouseMotionListener(mouseMotionListener);
    }
    list.setBackground(JBColor.background());
}
Also used : MouseListener(java.awt.event.MouseListener) EmptyBorder(javax.swing.border.EmptyBorder) MouseMotionListener(java.awt.event.MouseMotionListener)

Aggregations

MouseMotionListener (java.awt.event.MouseMotionListener)30 MouseEvent (java.awt.event.MouseEvent)18 MouseListener (java.awt.event.MouseListener)11 ActionEvent (java.awt.event.ActionEvent)8 ActionListener (java.awt.event.ActionListener)8 MouseAdapter (java.awt.event.MouseAdapter)8 JPanel (javax.swing.JPanel)6 Point (java.awt.Point)4 BoxLayout (javax.swing.BoxLayout)4 JComponent (javax.swing.JComponent)4 JLabel (javax.swing.JLabel)4 Dimension (java.awt.Dimension)3 KeyAdapter (java.awt.event.KeyAdapter)3 KeyEvent (java.awt.event.KeyEvent)3 MouseMotionAdapter (java.awt.event.MouseMotionAdapter)3 JScrollPane (javax.swing.JScrollPane)3 Component (java.awt.Component)2 DropTarget (java.awt.dnd.DropTarget)2 MouseWheelEvent (java.awt.event.MouseWheelEvent)2 MouseWheelListener (java.awt.event.MouseWheelListener)2