final UIFrame optionsFrame = new UIFrame("Controls", EnumSet.noneOf(FrameButtons.class));
final UIPanel basePanel = optionsFrame.getContentPanel();
basePanel.setLayout(new AnchorLayout());
runWalkButton = new UIButton("Start running...");
runWalkButton.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, basePanel, Alignment.TOP_LEFT, 5, -5));
runWalkButton.addActionListener(new ActionListener() {
boolean walk = true;
public void actionPerformed(final ActionEvent event) {
if (!walk) {
if (manager.getBaseAnimationLayer().doTransition("walk")) {
runWalkButton.setButtonText("Start running...");
walk = true;
}
} else {
if (manager.getBaseAnimationLayer().doTransition("run")) {
runWalkButton.setButtonText("Start walking...");
walk = false;
}
}
}
});
basePanel.add(runWalkButton);
punchButton = new UIButton("PUNCH!");
punchButton
.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, runWalkButton, Alignment.BOTTOM_LEFT, 0, -5));
punchButton.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent event) {
manager.findAnimationLayer("punch").setCurrentState("punch_right", true);
punchButton.setEnabled(false);
}
});
basePanel.add(punchButton);
playPauseButton = new UIButton("Pause");
playPauseButton.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, punchButton, Alignment.BOTTOM_LEFT, 0,
-5));
playPauseButton.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent event) {
if (playPauseButton.getText().equals("Pause")) {
manager.pause();
playPauseButton.setButtonText("Play");
} else {
manager.play();
playPauseButton.setButtonText("Pause");
}
}
});
basePanel.add(playPauseButton);
stopButton = new UIButton("Stop");
stopButton
.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, playPauseButton, Alignment.BOTTOM_LEFT, 0, -5));
stopButton.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent event) {
manager.stop();