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,
                          null, options);

        dialog = optionPane.createDialog(frame, "Spinners");

    public static void main(String[] args)
        JFrame frame = new JFrame();
        frame.setSize(600, 500);
        frame.setLocation(300, 300);
        TComponent op = new TComponent(frame);

Nobody got a solution?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.