use clearer method names, clear the contentPanel when action button is clicked
parent
71232f2cc9
commit
78b2820468
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
content=newContent;
|
||||
public void clearContentPanel() {
|
||||
contentPanel.removeAll();
|
||||
}
|
||||
|
||||
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() {
|
||||
|
|
Loading…
Reference in New Issue