@Override protected JSpinner createSpinner(int b) { JSpinner spinner = new JSpinner(); SpinnerListModel model = new SpinnerListModel(_keyList); spinner.setModel(model); ((JSpinner.ListEditor) spinner.getEditor()).getTextField().setEditable(false); model.addChangeListener( new ChangeListener() { @Override public void stateChanged(ChangeEvent arg0) { update(); } }); Dimension d = new Dimension(40, spinner.getPreferredSize().height); spinner.setMinimumSize(d); spinner.setPreferredSize(d); return spinner; }
public SatelliteMultiViewerCorner() { layer = new SpinnerListModel(); layer.addChangeListener( new ChangeListener() { @SuppressWarnings("rawtypes") @Override public void stateChanged(ChangeEvent e) { // find viewer for satellite if (layer.getValue() instanceof LayerViewer) setViewer((LayerViewer) layer.getValue()); else setViewer(null); } }); spinner = new JSpinner(layer); // Workaround to fix the satellite jumping issue // caused by changeevent-setviewer-dolayout-setvalue-(layoutinvalid) spinner.setPreferredSize(new Dimension(105, 22)); getSatellite().getContentPane().add(spinner, BorderLayout.NORTH); // by default disabled setEnabled(false); }