[1] | 1 | package genius.gui.panels;
|
---|
| 2 |
|
---|
| 3 | import java.awt.BorderLayout;
|
---|
| 4 | import java.awt.Component;
|
---|
| 5 | import java.awt.Dimension;
|
---|
| 6 |
|
---|
| 7 | import javax.swing.JLabel;
|
---|
| 8 | import javax.swing.JPanel;
|
---|
| 9 | import javax.swing.JSpinner;
|
---|
| 10 | import javax.swing.SpinnerModel;
|
---|
| 11 |
|
---|
| 12 | /**
|
---|
| 13 | * Spinner but with text label.
|
---|
| 14 | *
|
---|
| 15 | */
|
---|
| 16 | @SuppressWarnings("serial")
|
---|
| 17 | public class SpinnerPanel extends JPanel {
|
---|
| 18 |
|
---|
[8] | 19 | public SpinnerPanel(String labeltext, SpinnerModel model) {
|
---|
[1] | 20 | setLayout(new BorderLayout());
|
---|
[8] | 21 | JLabel label = new JLabel(labeltext);
|
---|
| 22 | add(label, BorderLayout.WEST);
|
---|
| 23 | label.setPreferredSize(new Dimension(120, 10));
|
---|
| 24 |
|
---|
[1] | 25 | JSpinner spinner = new JSpinner(model);
|
---|
| 26 | spinner.setMaximumSize(new Dimension(300, 30));
|
---|
| 27 | add(spinner, BorderLayout.CENTER);
|
---|
| 28 | // aligns the RIGHT side of the panel with the center of the parent.
|
---|
| 29 | // This limits the total width
|
---|
| 30 | setAlignmentX(Component.RIGHT_ALIGNMENT);
|
---|
| 31 | setMaximumSize(new Dimension(3000000, 30));
|
---|
| 32 | }
|
---|
| 33 |
|
---|
| 34 | }
|
---|