JButton stop = new JButton("Stop");
stop.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);
rightMotor.setValue(STOP);
bothMotor.setValue(STOP);
}
});
gbc.gridx = 3;
gbc.gridy = 3;
gbc.gridwidth = 2;
gbc.gridheight = 2;
gbc.ipadx = 10;
gbc.ipady = 10;
gbc.insets = new Insets(10,0,0,0);
gbl.setConstraints(stop, gbc);
butt.add(stop);
//FORWARD BUTTON
JButton forward = new JButton("Forward");
forward.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent ev) {
try {
cmdOut.write("x,2,200,\n".getBytes());
model.addElement(cmdIn.readLine());
} catch (Exception ex) {
}
leftMotor.setValue(STOP+50);
rightMotor.setValue(STOP+50);
bothMotor.setValue(STOP+50);
}
});
gbc.gridx = 3;
gbc.gridy = 1;
gbc.gridwidth = 2;
gbc.gridheight = 1;
gbc.ipadx = 20;
gbc.ipady = 20;
gbc.insets = new Insets(5,5,5,5);
gbl.setConstraints(forward, gbc);
butt.add(forward);
//LEFT TURN BUTTON
JButton leftturn = new JButton("Left Turn");
leftturn.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent ev) {
Kommentare zu diesen Handbüchern