summaryrefslogtreecommitdiffstats
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
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
-rw-r--r--src/jrummikub/view/impl/PlayerPanel.java35
-rw-r--r--src/jrummikub/view/impl/View.java2
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();