try {
// cmdOut.write("x,3,\n".getBytes());
model.addElement(cmdIn.readLine());
} catch (Exception ex) {
}
leftMotor.setValue(STOP-50);
rightMotor.setValue(STOP+50);
}
});
gbc.gridx = 1;
gbc.gridy = 3;
gbc.gridheight = 4;
gbc.ipadx = 20;
gbc.ipady = 20;
gbl.setConstraints(leftturn, gbc);
butt.add(leftturn);
//RIGHT TURN BUTTON
JButton rightturn = new JButton("Right Turn");
rightturn.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent ev) {
try {
// cmdOut.write("x,3,\n".getBytes());
model.addElement(cmdIn.readLine());
} catch (Exception ex) {
}
leftMotor.setValue(STOP+50);
rightMotor.setValue(STOP-50);
}
});
gbc.gridx = 5;
gbc.gridy = 3;
gbc.gridheight = 4;
gbc.ipadx = 20;
gbc.ipady = 20;
gbl.setConstraints(rightturn, gbc);
butt.add(rightturn);
//REVERSE BUTTON
JButton backward = new JButton("Reverse");
backward.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent ev) {
try {
// cmdOut.write("x,3,\n".getBytes());
model.addElement(cmdIn.readLine());
} catch (Exception ex) {
}
leftMotor.setValue(REVERSE);
rightMotor.setValue(REVERSE);
bothMotor.setValue(REVERSE);
}
});
Komentarze do niniejszej Instrukcji