gbc.gridx = 0;
gbc.gridwidth = 2;
gbc.gridy = 2;
gbc.gridheight = 2;
label = new JLabel("Right Motor");
gbl.setConstraints(label, gbc);
controls.add(label);
gbc.gridx = 2;
gbc.gridy = 2;
gbl.setConstraints(rightMotor, gbc);
controls.add(rightMotor);
//BOTH MOTOR SPEEDS
bothMotor = new JSlider(JSlider.HORIZONTAL, REVERSE, FORWARD, STOP);
bothMotor.addChangeListener(
new ChangeListener() {
public void stateChanged(ChangeEvent ev) {
int val = bothMotor.getValue();
leftMotor.setValue(val);
rightMotor.setValue(val);
try {
cmdOut.write(("x,2," + val + ",\n").getBytes());
for (int i = 0; i<100000;i++){}
model.addElement(cmdIn.readLine());
} catch (Exception ex) {
}
}
});
bothMotor.setMajorTickSpacing(10);
bothMotor.setMinorTickSpacing(5);
bothMotor.setSnapToTicks(true);
bothMotor.setPaintTicks(true);
//Create the label table
bothMotor.setLabelTable( labelTable );
bothMotor.setPaintLabels(true);
bothMotor.setBorder(BorderFactory.createEmptyBorder(0,0,10,0));
gbc.gridx = 0;
gbc.gridwidth = 2;
gbc.gridy = 4;
gbc.gridheight = 2;
label = new JLabel("Both Motors");
gbl.setConstraints(label, gbc);
controls.add(label);
gbc.gridx = 2;
gbc.gridy = 4;
gbl.setConstraints(bothMotor, gbc);
controls.add(bothMotor);
main.add(controls, BorderLayout.WEST);
/********************* CONTROL BUTTONS ************************/
//STOP BUTTON
Kommentare zu diesen Handbüchern