Hi, i've got a component that displays two JSpinners with a JOptionPane but the JSpinners are stretched across the dialog window. Does anyone know how i can format the JSpinners so they're smaller?
Here's some of the code
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.text.*;
public class TComponent
{
private SpinnerNumberModel spinnerModel1;
private SpinnerNumberModel spinnerModel2;
private JSpinner spinner1;
private JSpinner spinner2;
private JOptionPane optionPane;
private JDialog dialog;
private JFrame frame;
public TComponent(JFrame frame)
{
this.frame = frame;
spinnerModel1 = new SpinnerNumberModel(5, 1, 30, 1);
spinnerModel2 = new SpinnerNumberModel(5, 1, 30, 1);
spinner1 = new JSpinner(spinnerModel1);
spinner2 = new JSpinner(spinnerModel2);
Object[] message = {"Spinner 1: ", spinner1,
"Spinner 2: ", spinner2};
Object[] options = {"OK", "Cancel"};
optionPane = new JOptionPane(message,
JOptionPane.PLAIN_MESSAGE,
JOptionPane.OK_CANCEL_OPTION,
null, options);
dialog = optionPane.createDialog(frame, "Spinners");
dialog.show();
}
public static void main(String[] args)
{
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(600, 500);
frame.setLocation(300, 300);
frame.setVisible(true);
TComponent op = new TComponent(frame);
}
}