| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
package com.timjohnstondev.unitconverter.view; |
| 12 | |
|
| 13 | |
import java.awt.Color; |
| 14 | |
import java.awt.Component; |
| 15 | |
import java.awt.Dimension; |
| 16 | |
import java.util.ResourceBundle; |
| 17 | |
import javax.swing.BorderFactory; |
| 18 | |
import javax.swing.Box; |
| 19 | |
import javax.swing.BoxLayout; |
| 20 | |
import javax.swing.JLabel; |
| 21 | |
import javax.swing.JPanel; |
| 22 | |
|
| 23 | |
|
| 24 | |
|
| 25 | |
|
| 26 | |
public class UnitLabelPanel extends JPanel implements Configuration |
| 27 | |
{ |
| 28 | |
|
| 29 | |
|
| 30 | |
|
| 31 | |
public UnitLabelPanel() |
| 32 | 0 | { |
| 33 | 0 | setPreferredSize(new Dimension(500, 20)); |
| 34 | 0 | setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS)); |
| 35 | 0 | setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 10)); |
| 36 | |
|
| 37 | 0 | final ResourceBundle resources = ResourceBundle.getBundle("com.timjohnstondev.unitconverter.view.View"); |
| 38 | 0 | final JLabel properties = new JLabel(resources.getString("UnitLabelPanel.properties")); |
| 39 | 0 | final JLabel fromUnits = new JLabel(resources.getString("UnitLabelPanel.fromUnits")); |
| 40 | 0 | final JLabel toUnits = new JLabel(resources.getString("UnitLabelPanel.toUnits")); |
| 41 | |
|
| 42 | 0 | properties.setPreferredSize(new Dimension(170, 20)); |
| 43 | 0 | properties.setMaximumSize(new Dimension(170, 20)); |
| 44 | 0 | fromUnits.setPreferredSize(new Dimension(110, 20)); |
| 45 | 0 | fromUnits.setMaximumSize(new Dimension(110, 20)); |
| 46 | 0 | toUnits.setPreferredSize(new Dimension(110, 20)); |
| 47 | 0 | toUnits.setMaximumSize(new Dimension(110, 20)); |
| 48 | |
|
| 49 | 0 | add(properties); |
| 50 | 0 | add(fromUnits); |
| 51 | 0 | add(toUnits); |
| 52 | 0 | add(Box.createHorizontalGlue()); |
| 53 | 0 | } |
| 54 | |
|
| 55 | |
@Override |
| 56 | |
public final void setBackgroundColor(final Color color) |
| 57 | |
{ |
| 58 | 0 | setBackground(color); |
| 59 | 0 | } |
| 60 | |
|
| 61 | |
@Override |
| 62 | |
public final void setFontSize(final float fontSize) |
| 63 | |
{ |
| 64 | 0 | setFont(getFont().deriveFont(fontSize)); |
| 65 | 0 | final Component[] children = getComponents(); |
| 66 | 0 | for (Component child : children) |
| 67 | |
{ |
| 68 | 0 | child.setFont(child.getFont().deriveFont(fontSize)); |
| 69 | |
} |
| 70 | 0 | } |
| 71 | |
|
| 72 | |
@Override |
| 73 | |
public final void setForegroundColor(final Color color) |
| 74 | |
{ |
| 75 | 0 | setForeground(color); |
| 76 | 0 | final Component[] children = getComponents(); |
| 77 | 0 | for (Component child : children) |
| 78 | |
{ |
| 79 | 0 | child.setForeground(color); |
| 80 | |
} |
| 81 | 0 | } |
| 82 | |
} |