panel.add(getRoboterMotorDistance(), "wrap");
}
private JSlider getRoboterMotorDistance() {
if (roboterMotorDistance == null) {
final Motor leftMotor = roboterComponent.getModelObject().getLeftMotor();
final Motor rightMotor = roboterComponent.getModelObject().getRightMotor();
roboterMotorDistance = new JSlider(JSlider.HORIZONTAL, 1, 180, (int) rightMotor.getDistanceX());
initJSlider(roboterMotorDistance);
roboterMotorDistance.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
JSlider source = (JSlider) e.getSource();
int value = source.getValue();
leftMotor.setDistanceX(-value);
rightMotor.setDistanceX(value);
}
});
}
return roboterMotorDistance;
}