diff options
Diffstat (limited to 'src/jrummikub/view/impl/SidePanel.java')
-rw-r--r-- | src/jrummikub/view/impl/SidePanel.java | 65 |
1 files changed, 55 insertions, 10 deletions
diff --git a/src/jrummikub/view/impl/SidePanel.java b/src/jrummikub/view/impl/SidePanel.java index 9e83c91..b895701 100644 --- a/src/jrummikub/view/impl/SidePanel.java +++ b/src/jrummikub/view/impl/SidePanel.java @@ -22,9 +22,11 @@ import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; +import javax.swing.JProgressBar; import javax.swing.JScrollBar; import javax.swing.JViewport; import javax.swing.SwingConstants; +import javax.swing.border.CompoundBorder; import javax.swing.border.LineBorder; import javax.swing.border.MatteBorder; @@ -33,9 +35,9 @@ import jrummikub.view.ISidePanel; @SuppressWarnings("serial") class SidePanel extends JPanel implements ISidePanel { - InfoPanel infoPanel; - PlayerListPanel playerListPanel; - BottomScrollPane playerListScrollPane; + //private InfoPanel infoPanel; + private PlayerListPanel playerListPanel; + private BottomScrollPane playerListScrollPane; private JLabel initialMeldLabel; private JLabel setNumberLabel; private JLabel highestValueLabel; @@ -43,18 +45,19 @@ class SidePanel extends JPanel implements ISidePanel { private JLabel jokerLabel; private JLabel noLimitsLabel; private JLabel colorLabel; + private JProgressBar heapBar; public SidePanel() { setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); - infoPanel = new InfoPanel(createRuleInfoPanel()); + InfoPanel infoPanel = new InfoPanel(createGameInfoPanel(), createRuleInfoPanel()); c.gridx = 0; c.gridy = 0; c.weightx = 1; c.fill = GridBagConstraints.BOTH; - infoPanel.setBorder(new MatteBorder(0, 0, 1, 1, Color.BLACK)); + infoPanel.setBorder(new MatteBorder(0, 0, 1, 0, Color.GRAY)); add(infoPanel, c); playerListPanel = new PlayerListPanel(); @@ -65,8 +68,6 @@ class SidePanel extends JPanel implements ISidePanel { c.fill = GridBagConstraints.BOTH; playerListScrollPane = new BottomScrollPane(playerListPanel); - playerListScrollPane - .setBorder(new MatteBorder(0, 0, 0, 1, Color.BLACK)); add(playerListScrollPane, c); @@ -82,6 +83,43 @@ class SidePanel extends JPanel implements ISidePanel { colorLabel.setText("" + settings.getStoneColors().size()); noLimitsLabel.setVisible(settings.isNoLimits()); } + + @Override + public void setHeapCapacity(int capacity) { + heapBar.setMaximum(capacity); + } + + @Override + public void setHeapSize(int size) { + heapBar.setValue(size); + if (size > 0) { + heapBar.setString("" + size); + } else { + heapBar.setIndeterminate(true); + heapBar.setString("leer"); + } + } + + private JPanel createGameInfoPanel() { + JPanel panel = new JPanel(); + panel.setLayout(new GridBagLayout()); + + GridBagConstraints c = new GridBagConstraints(); + c.gridx = 0; + c.gridy = 0; + c.anchor = GridBagConstraints.WEST; + panel.add(new JLabel("Stapel: "), c); + c.gridx = 1; + c.weightx = 1; + c.fill = GridBagConstraints.HORIZONTAL; + heapBar = new JProgressBar(); + heapBar.setPreferredSize(new Dimension(16,16)); + panel.add(heapBar, c); + + heapBar.setStringPainted(true); + + return panel; + } private JPanel createRuleInfoPanel() { JPanel panel = new JPanel(); @@ -193,18 +231,25 @@ class SidePanel extends JPanel implements ISidePanel { static class InfoPanel extends JPanel { JPanel ruleInfoPanel; + JPanel gameInfoPanel; JCheckBox showRules; + JProgressBar heapBar; - public InfoPanel(JPanel ruleInfo) { + public InfoPanel(JPanel gameInfo, JPanel ruleInfo) { ruleInfoPanel = ruleInfo; + gameInfoPanel = gameInfo; setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); - showRules = new JCheckBox("Regeln"); - showRules.setSelected(true); c.gridx = 0; c.weightx = 1; c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.WEST; + + c.insets = new Insets(4, 8, 4, 8); + add(gameInfoPanel, c); + + showRules = new JCheckBox("Regeln"); + showRules.setSelected(true); setupTriangleIcons(showRules); c.insets = new Insets(0, 4, 0, 4); add(showRules, c); |