add a shell script to code & run
Signed-off-by: philippe lhardy <philippe@pavilionartlogiciel>
This commit is contained in:
@@ -106,7 +106,7 @@ public class Display extends JFrame
|
||||
goNorth();
|
||||
}
|
||||
};
|
||||
JButton north = addDirection("North", "UP", goNorth);
|
||||
JButton north = addDirection(this,"North", "UP", goNorth);
|
||||
|
||||
Action goEast = new AbstractAction() {
|
||||
public void actionPerformed(ActionEvent evt)
|
||||
@@ -116,7 +116,7 @@ public class Display extends JFrame
|
||||
goEast();
|
||||
}
|
||||
};
|
||||
JButton east = addDirection("East", "RIGHT", goEast);
|
||||
JButton east = addDirection(this,"East", "RIGHT", goEast);
|
||||
|
||||
|
||||
Action goWest = new AbstractAction() {
|
||||
@@ -127,7 +127,7 @@ public class Display extends JFrame
|
||||
goWest();
|
||||
}
|
||||
};
|
||||
JButton west = addDirection("West", "LEFT", goWest);
|
||||
JButton west = addDirection(this,"West", "LEFT", goWest);
|
||||
|
||||
Action goSouth = new AbstractAction() {
|
||||
public void actionPerformed(ActionEvent evt)
|
||||
@@ -137,7 +137,7 @@ public class Display extends JFrame
|
||||
goSouth();
|
||||
}
|
||||
};
|
||||
JButton south = addDirection("South", "DOWN", goSouth);
|
||||
JButton south = addDirection(this,"South", "DOWN", goSouth);
|
||||
|
||||
add(button,BorderLayout.CENTER);
|
||||
controlPanel.add(north,BorderLayout.NORTH);
|
||||
@@ -157,14 +157,14 @@ public class Display extends JFrame
|
||||
|
||||
}
|
||||
|
||||
private JButton addDirection(final String direction, String key, Action goAction)
|
||||
private JButton addDirection(final JPanel panel, final String direction, String key, Action goAction)
|
||||
{
|
||||
String actionName = "go" + direction;
|
||||
JButton button = new JButton(direction);
|
||||
button.addActionListener(goAction);
|
||||
KeyStroke keystroke=KeyStroke.getKeyStroke(key);
|
||||
//getInputMap().put(keystroke,actionName);
|
||||
//getActionMap().put(actionName,goAction);
|
||||
panel.getInputMap().put(keystroke,actionName);
|
||||
panel.getActionMap().put(actionName,goAction);
|
||||
controlPanel.getInputMap().put(keystroke,actionName);
|
||||
controlPanel.getActionMap().put(actionName,goAction);
|
||||
return button;
|
||||
|
||||
Reference in New Issue
Block a user