Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7868647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:04:05+00:00 2026-06-03T01:04:05+00:00

I wish to use the value created called spinnerModel but cannot seem to do

  • 0

I wish to use the value created called spinnerModel but cannot seem to do so, I believe I have to declare it as a certain type which I am not sure. I want to make it into a double as it will be used later in the program.
I have the following as it stands,

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;

 public class UI  {

 //Need to use the spinnerModel here but cannot :(

private void weightSpinnerMetricStateChanged(ChangeEvent e) {
    JSpinner weightSpinnerMetric = (JSpinner) e.getSource();
    SpinnerModel spinnerModel = weightSpinnerMetric.getModel();
    System.out.println(spinnerModel.getValue());
}
    stonesSpinnerImperial = new JSpinner(); //Spinner created here.

stonesSpinnerImperial.setModel(new SpinnerNumberModel(3, 3, 31, 1));
            stonesSpinnerImperial.addChangeListener(new ChangeListener() {
                @Override
                public void stateChanged(ChangeEvent e) {
                    stonesSpinnerStateChanged(e);
                    stonesSpinnerImperialStateChanged(e);
                }
            });
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T01:04:06+00:00Added an answer on June 3, 2026 at 1:04 am

    You should retrieve the value from the spinner model, and not trying to save the event.

    This is all explained in the Swing tutorial about spinners. A small copy paste of the code from that turial

    public void stateChanged(ChangeEvent e) {
            SpinnerModel dateModel = dateSpinner.getModel();
            if (dateModel instanceof SpinnerDateModel) {
                setSeasonalColor(((SpinnerDateModel)dateModel).getDate());
    }
    

    Of course you will need to adjust this code to match your current setup (e.g. change the cast to SpinnerDataModel to your spinner model)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two stored procedures I wish to use in my stored procedure, but
I wish to use the Translator classes of Zend framework in my app, but
I wish to use a jQuery .load(oracle apex url) query. I have a main
I am writing an XSLT transformation in which I wish to use the Replace
I have a dictionary of 10000 Product/Colour/Size combinations which I have created with something
I created a hierarchical custom post type called films. It is hierarchical so it
I have a font that I wish to use on a website, and I
I wish to use the method with the following signature: exec(String command, String[] envp,
I wish to use Spring MVC to provide a REST web service. However, running
I wish to use a COM dll in my C++ library. The way I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.