Java Code Examples for javax.swing.JSpinner#setModel()

The following examples show how to use javax.swing.JSpinner#setModel() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JResizerPanel.java    From MtgDesktopCompanion with GNU General Public License v3.0 6 votes vote down vote up
private void init() {
	setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5));
	spinner = new JSpinner();
	spinner.setPreferredSize(new Dimension(60, 20));
	spinner.setModel(new SpinnerNumberModel(0, null, null, 1));
	add(spinner);
	lblDimension = new JLabel("");
	add(lblDimension);
	
	update();
	spinner.addChangeListener(ce-> {
		Number val = (Number)spinner.getValue();
		int w = (int) (dimension.getWidth()+val.intValue());
		int h = (int) (w*MTGConstants.CARD_PICS_RATIO);
		dimension.setSize(w, h);
		update();
	});
}
 
Example 2
Source File: bug6463712.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public bug6463712() {
    SpinnerNumberModel m1 = new SpinnerNumberModel();
    JSpinner s = new JSpinner(m1);
    s.addChangeListener(this);
    SpinnerDateModel m2 = new SpinnerDateModel();
    s.setModel(m2);

    // m1 is no longer linked to the JSpinner (it has been replaced by m2), so
    // the following should not trigger a call to our stateChanged() method...
    m1.setValue(new Integer(1));
}
 
Example 3
Source File: bug6463712.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public bug6463712() {
    SpinnerNumberModel m1 = new SpinnerNumberModel();
    JSpinner s = new JSpinner(m1);
    s.addChangeListener(this);
    SpinnerDateModel m2 = new SpinnerDateModel();
    s.setModel(m2);

    // m1 is no longer linked to the JSpinner (it has been replaced by m2), so
    // the following should not trigger a call to our stateChanged() method...
    m1.setValue(new Integer(1));
}
 
Example 4
Source File: bug6463712.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public bug6463712() {
    SpinnerNumberModel m1 = new SpinnerNumberModel();
    JSpinner s = new JSpinner(m1);
    s.addChangeListener(this);
    SpinnerDateModel m2 = new SpinnerDateModel();
    s.setModel(m2);

    // m1 is no longer linked to the JSpinner (it has been replaced by m2), so
    // the following should not trigger a call to our stateChanged() method...
    m1.setValue(new Integer(1));
}
 
Example 5
Source File: bug6463712.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public bug6463712() {
    SpinnerNumberModel m1 = new SpinnerNumberModel();
    JSpinner s = new JSpinner(m1);
    s.addChangeListener(this);
    SpinnerDateModel m2 = new SpinnerDateModel();
    s.setModel(m2);

    // m1 is no longer linked to the JSpinner (it has been replaced by m2), so
    // the following should not trigger a call to our stateChanged() method...
    m1.setValue(new Integer(1));
}
 
Example 6
Source File: bug6463712.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public bug6463712() {
    SpinnerNumberModel m1 = new SpinnerNumberModel();
    JSpinner s = new JSpinner(m1);
    s.addChangeListener(this);
    SpinnerDateModel m2 = new SpinnerDateModel();
    s.setModel(m2);

    // m1 is no longer linked to the JSpinner (it has been replaced by m2), so
    // the following should not trigger a call to our stateChanged() method...
    m1.setValue(new Integer(1));
}
 
Example 7
Source File: BoosterQtyPanel.java    From MtgDesktopCompanion with GNU General Public License v3.0 5 votes vote down vote up
private void initGUI() {
	setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
	cboEditions = UITools.createComboboxEditions();
	add(cboEditions);

	spinner = new JSpinner();
	spinner.setModel(new SpinnerNumberModel(6, 0, null, 1));
	add(spinner);

}
 
Example 8
Source File: GlyphBoard.java    From libreveris with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Convenient method to allocate a glyph-based spinner
 *
 * @param nest      the underlying glyph nest
 * @param predicate a related glyph predicate, if any
 * @return the spinner built
 */
protected JSpinner makeGlyphSpinner (Nest nest,
                                     Predicate<Glyph> predicate)
{
    JSpinner spinner = new JSpinner();
    spinner.setModel(new SpinnerGlyphModel(nest, predicate));
    spinner.addChangeListener(this);
    SpinnerUtil.setRightAlignment(spinner);
    SpinnerUtil.setEditable(spinner, true);

    return spinner;
}
 
Example 9
Source File: bug8008657.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
static void createNumberSpinner() {
    Calendar calendar = Calendar.getInstance();
    calendar.add(Calendar.YEAR, -1);
    calendar.add(Calendar.YEAR, 1);
    int currentYear = calendar.get(Calendar.YEAR);
    SpinnerModel yearModel = new SpinnerNumberModel(currentYear, //initial value
            currentYear - 1, //min
            currentYear + 2, //max
            1);                //step
    spinner = new JSpinner();
    spinner.setModel(yearModel);
}
 
Example 10
Source File: bug8008657.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
static void createDateSpinner() {
    Calendar calendar = Calendar.getInstance();
    Date initDate = calendar.getTime();
    calendar.add(Calendar.YEAR, -1);
    Date earliestDate = calendar.getTime();
    calendar.add(Calendar.YEAR, 1);
    Date latestDate = calendar.getTime();
    SpinnerModel dateModel = new SpinnerDateModel(initDate,
            earliestDate,
            latestDate,
            Calendar.YEAR);
    spinner = new JSpinner();
    spinner.setModel(dateModel);
}
 
Example 11
Source File: bug6463712.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public bug6463712() {
    SpinnerNumberModel m1 = new SpinnerNumberModel();
    JSpinner s = new JSpinner(m1);
    s.addChangeListener(this);
    SpinnerDateModel m2 = new SpinnerDateModel();
    s.setModel(m2);

    // m1 is no longer linked to the JSpinner (it has been replaced by m2), so
    // the following should not trigger a call to our stateChanged() method...
    m1.setValue(new Integer(1));
}
 
Example 12
Source File: PlanManager.java    From cropplanning with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void buildContentsPanel() {
   
   cmboPlanList = new JComboBox();
   cmboPlanList.setEditable(true);
   cmboPlanList.addActionListener(this);
   
   spnYear = new JSpinner();
   SpinnerDateModel spnMod = new SpinnerDateModel();
   spnMod.setCalendarField( Calendar.YEAR );
   spnYear.setModel( spnMod );
   spnYear.setEditor( new JSpinner.DateEditor( spnYear, "yyyy" ) );

   spnYear.setPreferredSize( new Dimension( 70, 
                                            spnYear.getPreferredSize().height ));
   tfldDesc = new JTextField( 20 );
   
   JPanel jplCont = new JPanel( new MigLayout( "gapy 0px!, insets 2px", "[align right][]") );
     
   jplCont.add( new JLabel( "Plan:" ) );
   jplCont.add( cmboPlanList, "wrap" );
   jplCont.add( new JLabel( "Year:" ) );
   jplCont.add( spnYear, "wrap" );
   jplCont.add( new JLabel( "Description:" ) );
   jplCont.add( tfldDesc, "wrap" );
   
   jplCont.setBorder( BorderFactory.createEmptyBorder( 10, 10, 0, 10));

   contentsPanelBuilt = true;
   add( jplCont );
   
}
 
Example 13
Source File: bug6463712.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public bug6463712() {
    SpinnerNumberModel m1 = new SpinnerNumberModel();
    JSpinner s = new JSpinner(m1);
    s.addChangeListener(this);
    SpinnerDateModel m2 = new SpinnerDateModel();
    s.setModel(m2);

    // m1 is no longer linked to the JSpinner (it has been replaced by m2), so
    // the following should not trigger a call to our stateChanged() method...
    m1.setValue(new Integer(1));
}
 
Example 14
Source File: bug6463712.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public bug6463712() {
    SpinnerNumberModel m1 = new SpinnerNumberModel();
    JSpinner s = new JSpinner(m1);
    s.addChangeListener(this);
    SpinnerDateModel m2 = new SpinnerDateModel();
    s.setModel(m2);

    // m1 is no longer linked to the JSpinner (it has been replaced by m2), so
    // the following should not trigger a call to our stateChanged() method...
    m1.setValue(new Integer(1));
}
 
Example 15
Source File: bug6463712.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public bug6463712() {
    SpinnerNumberModel m1 = new SpinnerNumberModel();
    JSpinner s = new JSpinner(m1);
    s.addChangeListener(this);
    SpinnerDateModel m2 = new SpinnerDateModel();
    s.setModel(m2);

    // m1 is no longer linked to the JSpinner (it has been replaced by m2), so
    // the following should not trigger a call to our stateChanged() method...
    m1.setValue(new Integer(1));
}
 
Example 16
Source File: ManaPoolPanel.java    From MtgDesktopCompanion with GNU General Public License v3.0 4 votes vote down vote up
public ManaPoolPanel() {

		spinW = new JSpinner();
		spinW.addChangeListener(ce -> player.setMana("{W}", (int) spinW.getValue()));
		setLayout(new GridLayout(0, 2, 0, 0));

		ManaPanel panelW = new ManaPanel();
		FlowLayout flowLayout5 = (FlowLayout) panelW.getLayout();
		flowLayout5.setAlignment(FlowLayout.CENTER);
		panelW.setManaCost("{W}");
		add(panelW);
		spinW.setModel(new SpinnerNumberModel(0, 0, null, 1));
		add(spinW);

		ManaPanel panelU = new ManaPanel();
		FlowLayout flowLayout2 = (FlowLayout) panelU.getLayout();
		flowLayout2.setAlignment(FlowLayout.CENTER);
		panelU.setManaCost("{U}");
		add(panelU);

		spinU = new JSpinner();
		spinU.addChangeListener(ce -> player.setMana("{U}", (int) spinU.getValue()));

		spinU.setModel(new SpinnerNumberModel(0, 0, null, 1));
		add(spinU);

		ManaPanel panelB = new ManaPanel();
		FlowLayout flowLayout4 = (FlowLayout) panelB.getLayout();
		flowLayout4.setAlignment(FlowLayout.CENTER);
		panelB.setManaCost("{B}");
		add(panelB);

		spinB = new JSpinner();
		spinB.addChangeListener(ce -> player.setMana("{B}", (int) spinB.getValue()));

		spinB.setModel(new SpinnerNumberModel(0, 0, null, 1));
		add(spinB);

		ManaPanel panelR = new ManaPanel();
		FlowLayout flowLayout1 = (FlowLayout) panelR.getLayout();
		flowLayout1.setAlignment(FlowLayout.CENTER);
		panelR.setManaCost("{R}");
		add(panelR);

		spinR = new JSpinner();
		spinR.addChangeListener(ce -> player.setMana("{R}", (int) spinR.getValue()));

		spinR.setModel(new SpinnerNumberModel(0, 0, null, 1));
		add(spinR);

		ManaPanel panelG = new ManaPanel();
		FlowLayout flowLayout3 = (FlowLayout) panelG.getLayout();
		flowLayout3.setAlignment(FlowLayout.CENTER);
		panelG.setManaCost("{G}");
		add(panelG);

		spinG = new JSpinner();
		spinG.addChangeListener(ce -> player.setMana("{G}", (int) spinG.getValue()));

		spinG.setModel(new SpinnerNumberModel(0, 0, null, 1));
		add(spinG);

		ManaPanel panelC = new ManaPanel();
		FlowLayout flowLayout = (FlowLayout) panelC.getLayout();
		flowLayout.setAlignment(FlowLayout.CENTER);
		panelC.setManaCost("{C}");
		add(panelC);

		spinC = new JSpinner();
		spinC.addChangeListener(ce -> player.setMana("{C}", (int) spinC.getValue()));
		spinC.setModel(new SpinnerNumberModel(0, 0, null, 1));
		add(spinC);

		ManaPanel panelE = new ManaPanel();
		FlowLayout flowLayout6 = (FlowLayout) panelE.getLayout();
		flowLayout6.setAlignment(FlowLayout.CENTER);
		add(panelE);

		spinE = new JSpinner();
		panelE.setManaCost("{E}");

		spinE.addChangeListener(ce -> player.setMana("{E}", (int) spinE.getValue())

		);
		spinE.setModel(new SpinnerNumberModel(0, 0, null, 1));
		add(spinE);

	}
 
Example 17
Source File: ReservedCheckinWindow.java    From Hotel-Properties-Management-System with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create the dialog.
 */
public ReservedCheckinWindow(Room roomNumber) {

	this.ownInjectedRoom = roomNumber;
	
	loggingEngine = LoggingEngine.getInstance();
	loggingEngine.setMessage("User is : " + sessionBean.getNickName());
	
	setMinimumSize(new Dimension(750, 495));
	setPreferredSize(new Dimension(750, 495));
	setLocationRelativeTo(null);

	this.setIconImage(Toolkit.getDefaultToolkit().
			getImage(getClass().getResource(LOGOPATH)));

	getContentPane().setForeground(new Color(255, 99, 71));
	getContentPane().setFocusCycleRoot(true);
	getContentPane().setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
	getContentPane().setFont(new Font("Verdana", Font.BOLD, 12));
	setModalExclusionType(ModalExclusionType.APPLICATION_EXCLUDE);
	setDefaultCloseOperation(DISPOSE_ON_CLOSE);
	setModal(true);
	setResizable(false);

	this.setTitle("Coder HPMSA - [Checkin]");
	contentPanel.setAutoscrolls(true);
	contentPanel.setPreferredSize(new Dimension(10, 415));

	contentPanel.setBackground(Color.decode("#066d95"));
	contentPanel.setLayout(new BorderLayout(0, 0));
	getContentPane().add(contentPanel, BorderLayout.SOUTH);

	upperPanel = new JPanel();
	upperPanel.setBorder(new SoftBevelBorder(BevelBorder.RAISED, null, null, null, null));
	upperPanel.setBackground(new Color(135, 206, 235));
	upperPanel.setPreferredSize(new Dimension(10, 35));
	contentPanel.add(upperPanel, BorderLayout.NORTH);

	JLabel lblChangeRoomPerson = new JLabel("Change person count : ");
	lblChangeRoomPerson.setFont(new Font("Arial", Font.PLAIN, 15));
	upperPanel.add(lblChangeRoomPerson);

	spinner = new JSpinner();
	spinner.setModel(new SpinnerNumberModel(1, 1, 3, 1));
	spinner.setPreferredSize(new Dimension(40, 20));
	spinner.setMinimumSize(new Dimension(35, 20));
	spinner.addChangeListener(customerCounterListener());
	upperPanel.add(spinner);

	JPanel buttonPanel = new JPanel();
	buttonPanel.setBorder(new SoftBevelBorder(BevelBorder.RAISED, null, null, null, null));
	buttonPanel.setPreferredSize(new Dimension(10, 50));
	buttonPanel.setLayout(null);
	getContentPane().add(buttonPanel, BorderLayout.NORTH);

	JButton roomCheckinBtn = new JButton("Room checkin");
	roomCheckinBtn.addActionListener(this);
	roomCheckinBtn.setIcon(new ImageIcon(ReservedCheckinWindow.class
					.getResource("/com/coder/hms/icons/extra_checkin.png")));
	roomCheckinBtn.setBounds(7, 4, 130, 42);
	buttonPanel.add(roomCheckinBtn);

	final JSeparator separator = new JSeparator();
	separator.setBackground(Color.DARK_GRAY);
	separator.setBounds(149, 6, 10, 36);
	separator.setOrientation(SwingConstants.VERTICAL);
	separator.setFocusable(true);
	separator.setForeground(Color.DARK_GRAY);
	separator.setAutoscrolls(true);
	separator.setPreferredSize(new Dimension(10, 20));
	buttonPanel.add(separator);

	JLabel lblRoom = new JLabel("ROOM : ");
	lblRoom.setFont(new Font("Verdana", Font.BOLD, 15));
	lblRoom.setBounds(330, 8, 68, 33);
	buttonPanel.add(lblRoom);

	JLabel roomNumberLbl = new JLabel(ownInjectedRoom.getNumber());
	roomNumberLbl.setForeground(new Color(220, 20, 60));
	roomNumberLbl.setFont(new Font("Verdana", Font.BOLD, 17));
	roomNumberLbl.setBounds(406, 8, 103, 33);
	buttonPanel.add(roomNumberLbl);
	
	contentPanel.add(customerFormOne.setCustomerDetailPanel(), BorderLayout.WEST);
	prepareCustomerForms(ownInjectedRoom.getNumber());

}
 
Example 18
Source File: IntegerCellEditor.java    From MtgDesktopCompanion with GNU General Public License v3.0 4 votes vote down vote up
public IntegerCellEditor() {
	spinner = new JSpinner();
	SpinnerNumberModel model1 = new SpinnerNumberModel();
	model1.setMinimum(0);
	spinner.setModel(model1);
}
 
Example 19
Source File: DeskewTransformSettingsPanel.java    From swingsane with Apache License 2.0 4 votes vote down vote up
private void initComponents() {
  GridBagLayout gridBagLayout = new GridBagLayout();
  gridBagLayout.columnWidths = new int[] { 32, 0 };
  gridBagLayout.rowHeights = new int[] { 24, 0 };
  gridBagLayout.columnWeights = new double[] { 1.0, Double.MIN_VALUE };
  gridBagLayout.rowWeights = new double[] { 0.0, Double.MIN_VALUE };
  setLayout(gridBagLayout);

  JPanel containerPanel = new JPanel();
  containerPanel.setBorder(new CompoundBorder(new TitledBorder(Localizer
      .localize("DeskewSettingsBorderTitle")), new EmptyBorder(5, 5, 5, 5)));
  GridBagConstraints gbc_containerPanel = new GridBagConstraints();
  gbc_containerPanel.fill = GridBagConstraints.HORIZONTAL;
  gbc_containerPanel.anchor = GridBagConstraints.NORTH;
  gbc_containerPanel.gridx = 0;
  gbc_containerPanel.gridy = 0;
  add(containerPanel, gbc_containerPanel);
  GridBagLayout gbl_containerPanel = new GridBagLayout();
  gbl_containerPanel.columnWidths = new int[] { 0, 0, 0 };
  gbl_containerPanel.rowHeights = new int[] { 24, 0 };
  gbl_containerPanel.columnWeights = new double[] { 1.0, 1.0, Double.MIN_VALUE };
  gbl_containerPanel.rowWeights = new double[] { 0.0, Double.MIN_VALUE };
  containerPanel.setLayout(gbl_containerPanel);

  JLabel deskewThresholdLabel = new JLabel(Localizer.localize("DeskewThresholdLabelText"));
  deskewThresholdLabel.setFont(UIManager.getFont("Label.font"));
  GridBagConstraints gbc_deskewThresholdLabel = new GridBagConstraints();
  gbc_deskewThresholdLabel.insets = new Insets(0, 0, 0, 5);
  gbc_deskewThresholdLabel.anchor = GridBagConstraints.EAST;
  gbc_deskewThresholdLabel.gridx = 0;
  gbc_deskewThresholdLabel.gridy = 0;
  containerPanel.add(deskewThresholdLabel, gbc_deskewThresholdLabel);

  deskewThresholdSpinner = new JSpinner();
  deskewThresholdSpinner.addChangeListener(new ChangeListener() {
    @Override
    public void stateChanged(ChangeEvent e) {
      deskewThresholdStateChanged(e);
    }
  });
  deskewThresholdSpinner.setModel(new SpinnerNumberModel(2.0d, 0.0d, 180.0d, 0.1d));
  deskewThresholdSpinner.setFont(UIManager.getFont("Spinner.font"));
  GridBagConstraints gbc_deskewThresholdSpinner = new GridBagConstraints();
  gbc_deskewThresholdSpinner.anchor = GridBagConstraints.WEST;
  gbc_deskewThresholdSpinner.gridx = 1;
  gbc_deskewThresholdSpinner.gridy = 0;
  containerPanel.add(deskewThresholdSpinner, gbc_deskewThresholdSpinner);
}
 
Example 20
Source File: BinarizeTransformSettingsPanel.java    From swingsane with Apache License 2.0 4 votes vote down vote up
private void initComponents() {
  GridBagLayout gridBagLayout = new GridBagLayout();
  gridBagLayout.columnWidths = new int[] { 32, 0 };
  gridBagLayout.rowHeights = new int[] { 24, 0 };
  gridBagLayout.columnWeights = new double[] { 1.0, Double.MIN_VALUE };
  gridBagLayout.rowWeights = new double[] { 0.0, Double.MIN_VALUE };
  setLayout(gridBagLayout);

  JPanel containerPanel = new JPanel();
  containerPanel.setBorder(new CompoundBorder(new TitledBorder(Localizer
      .localize("LuminanceSettingsBorderTitle")), new EmptyBorder(5, 5, 5, 5)));
  GridBagConstraints gbc_containerPanel = new GridBagConstraints();
  gbc_containerPanel.fill = GridBagConstraints.HORIZONTAL;
  gbc_containerPanel.anchor = GridBagConstraints.NORTH;
  gbc_containerPanel.gridx = 0;
  gbc_containerPanel.gridy = 0;
  add(containerPanel, gbc_containerPanel);
  GridBagLayout gbl_containerPanel = new GridBagLayout();
  gbl_containerPanel.columnWidths = new int[] { 0, 0, 0 };
  gbl_containerPanel.rowHeights = new int[] { 24, 0 };
  gbl_containerPanel.columnWeights = new double[] { 1.0, 1.0, Double.MIN_VALUE };
  gbl_containerPanel.rowWeights = new double[] { 0.0, Double.MIN_VALUE };
  containerPanel.setLayout(gbl_containerPanel);

  JLabel luminanceLabel = new JLabel(Localizer.localize("LuminanceThresholdLabelText"));
  luminanceLabel.setFont(UIManager.getFont("Label.font"));
  GridBagConstraints gbc_luminanceLabel = new GridBagConstraints();
  gbc_luminanceLabel.insets = new Insets(0, 0, 0, 5);
  gbc_luminanceLabel.anchor = GridBagConstraints.EAST;
  gbc_luminanceLabel.gridx = 0;
  gbc_luminanceLabel.gridy = 0;
  containerPanel.add(luminanceLabel, gbc_luminanceLabel);

  luminanceSpinner = new JSpinner();
  luminanceSpinner.addChangeListener(new ChangeListener() {
    @Override
    public void stateChanged(ChangeEvent e) {
      luminanceStateChanged(e);
    }
  });
  luminanceSpinner.setModel(new SpinnerNumberModel(165, 0, 255, 1));
  luminanceSpinner.setFont(UIManager.getFont("Spinner.font"));
  GridBagConstraints gbc_luminanceSpinner = new GridBagConstraints();
  gbc_luminanceSpinner.anchor = GridBagConstraints.WEST;
  gbc_luminanceSpinner.gridx = 1;
  gbc_luminanceSpinner.gridy = 0;
  containerPanel.add(luminanceSpinner, gbc_luminanceSpinner);
}