diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/jrummikub/view/impl/PlayerPanel.java | 35 | ||||
-rw-r--r-- | src/jrummikub/view/impl/View.java | 2 |
2 files changed, 27 insertions, 10 deletions
diff --git a/src/jrummikub/view/impl/PlayerPanel.java b/src/jrummikub/view/impl/PlayerPanel.java index ef8b4f6..6bc3d09 100644 --- a/src/jrummikub/view/impl/PlayerPanel.java +++ b/src/jrummikub/view/impl/PlayerPanel.java @@ -25,6 +25,7 @@ class PlayerPanel extends JPanel implements IPlayerPanel { private final static int SIDE_PANEL_SEPARATOR = 10; private final static float SIDE_PANEL_FIRST_LINE_HEIGHT = 0.375f; private final static int SIDE_PANEL_MAX_WIDTH = 180; + private final static float MAX_BUTTON_FONT_SIZE = 12; private final static DecimalFormat secondFormat = new DecimalFormat("00"); @@ -88,7 +89,7 @@ class PlayerPanel extends JPanel implements IPlayerPanel { currentPlayerNameLabel.setVerticalTextPosition(JLabel.CENTER); leftPanel.add(currentPlayerNameLabel); - sortByNumberButton = new JButton("<html><center>Sort by<br>number"); + sortByNumberButton = new JButton("<html><center>Sort by number"); sortByNumberButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { @@ -97,7 +98,7 @@ class PlayerPanel extends JPanel implements IPlayerPanel { }); leftPanel.add(sortByNumberButton); - sortByColorButton = new JButton("<html><center>Sort by<br>color"); + sortByColorButton = new JButton("<html><center>Sort by color"); sortByColorButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { @@ -121,14 +122,23 @@ class PlayerPanel extends JPanel implements IPlayerPanel { int firstLineHeight = (int) ((height - SIDE_PANEL_SEPARATOR) * SIDE_PANEL_FIRST_LINE_HEIGHT); int buttonWidth = (width - SIDE_PANEL_SEPARATOR) / 2; + int buttonHeight = height - SIDE_PANEL_SEPARATOR - firstLineHeight; + float fontSize = (float) Math.sqrt(buttonWidth * buttonHeight) / 5; + if (fontSize > MAX_BUTTON_FONT_SIZE) + fontSize = MAX_BUTTON_FONT_SIZE; currentPlayerNameLabel.setBounds(x, y, width, firstLineHeight); sortByNumberButton.setBounds(x, y + firstLineHeight - + SIDE_PANEL_SEPARATOR, buttonWidth, height - SIDE_PANEL_SEPARATOR - - firstLineHeight); - sortByColorButton.setBounds(x + buttonWidth + SIDE_PANEL_SEPARATOR, y - + firstLineHeight + SIDE_PANEL_SEPARATOR, buttonWidth, height - - SIDE_PANEL_SEPARATOR - firstLineHeight); + + SIDE_PANEL_SEPARATOR, buttonWidth, buttonHeight); + sortByColorButton + .setBounds(x + buttonWidth + SIDE_PANEL_SEPARATOR, y + + firstLineHeight + SIDE_PANEL_SEPARATOR, buttonWidth, + buttonHeight); + + sortByNumberButton.setFont(sortByNumberButton.getFont().deriveFont( + fontSize)); + sortByColorButton.setFont(sortByColorButton.getFont().deriveFont( + fontSize)); } }); } @@ -168,10 +178,17 @@ class PlayerPanel extends JPanel implements IPlayerPanel { } int firstLineHeight = (int) ((height - SIDE_PANEL_SEPARATOR) * SIDE_PANEL_FIRST_LINE_HEIGHT); - + int buttonWidth = width; + int buttonHeight = height - SIDE_PANEL_SEPARATOR - firstLineHeight; + float fontSize = (float) Math.sqrt(buttonWidth * buttonHeight) / 5; + if (fontSize > MAX_BUTTON_FONT_SIZE) + fontSize = MAX_BUTTON_FONT_SIZE; + timeBar.setBounds(x, y, width, firstLineHeight); endTurnButton.setBounds(x, y + firstLineHeight + SIDE_PANEL_SEPARATOR, - width, height - SIDE_PANEL_SEPARATOR - firstLineHeight); + buttonWidth, buttonHeight); + endTurnButton.setFont(endTurnButton.getFont().deriveFont( + fontSize)); } }); } diff --git a/src/jrummikub/view/impl/View.java b/src/jrummikub/view/impl/View.java index a23e5e2..0eabd43 100644 --- a/src/jrummikub/view/impl/View.java +++ b/src/jrummikub/view/impl/View.java @@ -38,7 +38,7 @@ public class View extends JFrame implements IView { super("JRummikub"); setLayout(null); - setSize(1000, 700); + setSize(800, 600); setDefaultCloseOperation(EXIT_ON_CLOSE); table = new Table(); |