use clearer method names, clear the contentPanel when action button is clicked

master
melvin 2013-06-29 18:48:37 +08:00
parent 71232f2cc9
commit 78b2820468
2 changed files with 9 additions and 8 deletions

View File

@ -159,6 +159,7 @@ public class GameController {
}
public void actionClicked() {
gameViewer.clearContentPanel();
actionClicked = true;
choiceClicked = MagicTargetNone.getInstance();
resume(false);
@ -370,7 +371,7 @@ public class GameController {
try {
final E content = func.call();
ref.set(content);
gameViewer.showComponent(content);
gameViewer.setContentPanel(content);
} catch (Exception ex) {
except.set(ex);
}

View File

@ -40,7 +40,6 @@ public class GameViewer extends TexturedPanel implements ActionListener {
private final JPanel actionPanel;
private final CardLayout actionCardLayout;
private final JPanel contentPanel;
private JComponent content;
private boolean actionEnabled;
public GameViewer(final MagicGame game,final GameController controller) {
@ -114,11 +113,12 @@ public class GameViewer extends TexturedPanel implements ActionListener {
titleBar.setIcon(game.getTurnPlayer() == game.getVisiblePlayer() ? IconImages.YOU : IconImages.OPPONENT);
}
public void showComponent(final JComponent newContent) {
if (content!=null) {
contentPanel.remove(content);
public void clearContentPanel() {
contentPanel.removeAll();
}
content=newContent;
public void setContentPanel(final JComponent newContent) {
clearContentPanel();
contentPanel.add(newContent,BorderLayout.CENTER);
revalidate();
repaint();
@ -126,7 +126,7 @@ public class GameViewer extends TexturedPanel implements ActionListener {
public void showMessage(final String message) {
final TextLabel messageLabel=new TextLabel(message,TEXT_WIDTH,true);
showComponent(messageLabel);
setContentPanel(messageLabel);
}
public MagicGame getGame() {