use of java.awt.event.MouseMotionListener in project android by JetBrains.
the class LayoutTestUtilities method moveMouse.
public static void moveMouse(InteractionManager manager, int x1, int y1, int x2, int y2, int modifiers) {
Object listener = manager.getListener();
assertTrue(listener instanceof MouseMotionListener);
MouseMotionListener mouseListener = (MouseMotionListener) listener;
int frames = 5;
double x = x1;
double y = y1;
double xSlope = (x2 - x) / frames;
double ySlope = (y2 - y) / frames;
JComponent layeredPane = manager.getSurface().getLayeredPane();
for (int i = 0; i < frames + 1; i++) {
MouseEvent event = new MouseEventBuilder((int) x, (int) y).withSource(layeredPane).withMask(modifiers).build();
mouseListener.mouseMoved(event);
x += xSlope;
y += ySlope;
}
}
use of java.awt.event.MouseMotionListener in project intellij-community by JetBrains.
the class MavenRepositoriesConfigurable method configControls.
private void configControls() {
myServiceList.setModel(myModel);
myServiceList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
myAddButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final String value = (String) myServiceList.getSelectedValue();
final String text = Messages.showInputDialog("Artifactory or Nexus Service URL", "Add Service URL", Messages.getQuestionIcon(), value == null ? "http://" : value, new URLInputVaslidator());
if (StringUtil.isNotEmpty(text)) {
myModel.add(text);
myServiceList.setSelectedValue(text, true);
}
}
});
myEditButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final int index = myServiceList.getSelectedIndex();
final String text = Messages.showInputDialog("Artifactory or Nexus Service URL", "Edit Service URL", Messages.getQuestionIcon(), myModel.getElementAt(index), new URLInputVaslidator());
if (StringUtil.isNotEmpty(text)) {
myModel.setElementAt(text, index);
}
}
});
ListUtil.addRemoveListener(myRemoveButton, myServiceList);
ListUtil.disableWhenNoSelection(myTestButton, myServiceList);
ListUtil.disableWhenNoSelection(myEditButton, myServiceList);
myTestButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final String value = (String) myServiceList.getSelectedValue();
if (value != null) {
testServiceConnection(value);
}
}
});
myUpdateButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
doUpdateIndex();
}
});
myIndicesTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
updateButtonsState();
}
});
myIndicesTable.addMouseMotionListener(new MouseMotionListener() {
public void mouseDragged(MouseEvent e) {
}
public void mouseMoved(MouseEvent e) {
int row = myIndicesTable.rowAtPoint(e.getPoint());
if (row == -1)
return;
updateIndexHint(row);
}
});
myIndicesTable.setDefaultRenderer(Object.class, new MyCellRenderer());
myIndicesTable.setDefaultRenderer(MavenIndicesManager.IndexUpdatingState.class, new MyIconCellRenderer());
myServiceList.getEmptyText().setText("No services");
myIndicesTable.getEmptyText().setText("No remote repositories");
updateButtonsState();
}
use of java.awt.event.MouseMotionListener in project azure-tools-for-java by Microsoft.
the class VMWizardModel method configStepList.
public void configStepList(JList jList, int step) {
jList.setListData(getStepTitleList());
jList.setSelectedIndex(step);
jList.setBorder(new EmptyBorder(10, 0, 10, 0));
jList.setCellRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList jList, Object o, int i, boolean b, boolean b1) {
return super.getListCellRendererComponent(jList, " " + o.toString(), i, b, b1);
}
});
for (MouseListener mouseListener : jList.getMouseListeners()) {
jList.removeMouseListener(mouseListener);
}
for (MouseMotionListener mouseMotionListener : jList.getMouseMotionListeners()) {
jList.removeMouseMotionListener(mouseMotionListener);
}
jList.setBackground(JBColor.background());
}
use of java.awt.event.MouseMotionListener in project JMRI by JMRI.
the class DrawFrame method makeSensorPanel.
protected JPanel makeSensorPanel() {
JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
JPanel p = new JPanel();
JPanel p0 = new JPanel();
p0.add(new JLabel(Bundle.getMessage("SensorMsg")));
panel.add(p0);
p.add(new JLabel(Bundle.getMessage("VisibleSensor") + ":"));
p.add(_sensorName);
_sensorName.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String msg = _shape.setControlSensor(_sensorName.getText(), _hideShape.isSelected(), _shape.getChangeLevel());
if (msg != null) {
// NOI18N
JOptionPane.showMessageDialog(null, msg, Bundle.getMessage("MakeLabel", Bundle.getMessage("ErrorSensor")), JOptionPane.INFORMATION_MESSAGE);
_sensorName.setText("");
}
}
});
_sensorName.addMouseMotionListener(new MouseMotionListener() {
@Override
public void mouseDragged(MouseEvent e) {
updateShape();
}
@Override
public void mouseMoved(MouseEvent e) {
String msg = _shape.setControlSensor(_sensorName.getText(), _hideShape.isSelected(), _shape.getChangeLevel());
if (msg != null) {
// NOI18N
JOptionPane.showMessageDialog(null, msg, Bundle.getMessage("MakeLabel", Bundle.getMessage("ErrorSensor")), JOptionPane.INFORMATION_MESSAGE);
_sensorName.setText("");
}
}
});
panel.add(p);
JPanel p1 = new JPanel();
p1.setLayout(new BoxLayout(p1, BoxLayout.Y_AXIS));
_hideShape = new JRadioButton(Bundle.getMessage("HideOnSensor"));
_changeLevel = new JRadioButton(Bundle.getMessage("ChangeLevel"));
ButtonGroup bg = new ButtonGroup();
bg.add(_hideShape);
bg.add(_changeLevel);
_levelComboBox = new JComboBox<String>();
_levelComboBox.addItem(Bundle.getMessage("SameLevel"));
for (int i = 1; i < 11; i++) {
_levelComboBox.addItem(Bundle.getMessage("Level") + " " + Integer.valueOf(i));
}
_levelComboBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
int level = _levelComboBox.getSelectedIndex();
_shape.setChangeLevel(level);
}
});
_hideShape.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent a) {
_levelComboBox.setEnabled(false);
}
});
_changeLevel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent a) {
_levelComboBox.setEnabled(true);
}
});
p1.add(_hideShape);
p1.add(_changeLevel);
JPanel p2 = new JPanel();
p2.setLayout(new BoxLayout(p2, BoxLayout.Y_AXIS));
JPanel p3 = new JPanel();
// p3.add(Box.createRigidArea(_levelComboBox.getPreferredSize()));
p2.add(p3);
JPanel p4 = new JPanel();
p4.add(_levelComboBox);
p2.add(p4);
p0 = new JPanel();
p0.setLayout(new BoxLayout(p0, BoxLayout.X_AXIS));
p0.add(Box.createHorizontalGlue());
p0.add(p1);
p0.add(p2);
p0.add(Box.createHorizontalGlue());
panel.add(p0);
return panel;
}
use of java.awt.event.MouseMotionListener in project JMRI by JMRI.
the class DrawCircle method makeParamsPanel.
/**
* Create a new PositionableShape
*/
@Override
protected JPanel makeParamsPanel(PositionableShape ps) {
JPanel panel = super.makeParamsPanel(ps);
JPanel p = new JPanel();
p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
p.add(new JLabel(Bundle.getMessage("Circle")));
JPanel pp = new JPanel();
_diameterText = new JTextField(6);
_diameterText.setText(Integer.toString(_shape.getWidth()));
_diameterText.setHorizontalAlignment(JTextField.RIGHT);
pp.add(_diameterText);
_diameterText.addMouseMotionListener(new MouseMotionListener() {
@Override
public void mouseDragged(MouseEvent e) {
updateShape();
}
@Override
public void mouseMoved(MouseEvent e) {
_shape.setWidth(Integer.parseInt(_diameterText.getText()));
updateShape();
}
});
_diameterText.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
_shape.setWidth(Integer.parseInt(_diameterText.getText()));
updateShape();
}
});
pp.add(new JLabel(Bundle.getMessage("circleRadius")));
p.add(pp);
panel.add(p);
panel.add(Box.createVerticalStrut(STRUT_SIZE));
return panel;
}
Aggregations