summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/view/impl/PlayerPanel.java
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2011-05-02 01:08:44 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2011-05-02 01:08:44 +0200
commitebd0707133d6c2023ee7e608b7661640f993e2f8 (patch)
tree7b65e80201c0e3de124512d0e3a5af262d08a783 /src/jrummikub/view/impl/PlayerPanel.java
parentc241d98ed977d1b8eefa3faa10f5171cefbee84d (diff)
downloadJRummikub-ebd0707133d6c2023ee7e608b7661640f993e2f8.tar
JRummikub-ebd0707133d6c2023ee7e608b7661640f993e2f8.zip
Use small font sizes for small buttons :D
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@57 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub/view/impl/PlayerPanel.java')
-rw-r--r--src/jrummikub/view/impl/PlayerPanel.java35
1 files changed, 26 insertions, 9 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));
}
});
}