Results 1 to 6 of 6

Thread: SpinnerModel interface of java

  1. #1
    Join Date
    Jan 2010
    Posts
    76

    SpinnerModel interface of java

    Hi All,

    I just started to learn java programming language. In which currently I am referring interface concepts of java programming. The 'SpinnerModel interface' seems to be very complex to understand. I have referred various website for this interface, but nothing was helpful. Do you have enough knowledge about the 'SpinnerModel interface' of java? If yes then please let me know the same. I am waiting for your reply.

  2. #2
    Join Date
    May 2008
    Posts
    2,389

    Re: SpinnerModel interface of java

    A SpinnerModel is model for a potentially unbounded sequence of object values. This model is similar to ListModel however there are some important differences:
    * The number of sequence elements isn't neccessarily bounded.
    * The model doesn't support indexed random access to sequence elements. Only three sequence values are accessible at a time: current, next and previous.
    * The current sequence element, can be set.

  3. #3
    Join Date
    Feb 2008
    Posts
    1,852

    Re: SpinnerModel interface of java

    Example of SpinnerModel interface of java:
    Code:
    import javax.swing.SpinnerModel;
    import javax.swing.event.ChangeEvent;
    
    public class SpinnerModelDM {
      public static void main(String[] adrgs) {
        JFrame FML = new JFrame();
    
        Calendar now1 = Calendar.getInstance();
        Calendar earliest = (Calendar) now1.clone();
        earliest.add(Calendar.MONTH, -6);
        Calendar latest = (Calendar) now.clone();
        latest.add(Calendar.MONTH, 6);
        SpinnerModel model01 = new SpinnerDateModel(now.getTime(), earliest.getTime(), latest.getTime(),
            Calendar.WEEK_OF_YEAR);
        final JSpinner spinner = new JSpinner(model01);
        model01.addChangeListener(new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            System.out.println(((SpinnerDateModel) e.getSource()).getDate());
          }    }
        FML.getContentPane().add("North", new JLabel("Choose a week"));
        FML.getContentPane().add("Center", spinner);
        FML.pack();
        FML.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        FML.setVisible(true);
      }
    }

  4. #4
    Join Date
    Jan 2008
    Posts
    1,521

    Re: SpinnerModel interface of java

    Hi friend,

    Before using properties of SpinnerModel interface, I suggest you to review following it's methods:
    • setValue(Object val)
    • getPreviousValue()
    • getValue()
    • removeChangeListener(ChangeListener chlstn)
    • addChangeListener(ChangeListener chlstn)
    • getNextValue()

  5. #5
    Join Date
    Apr 2008
    Posts
    1,948

    Re: SpinnerModel interface of java

    Hi,

    Please go through the below example of SpinnerModel interface along with different parameter list:
    Code:
    public SpinnerNumberModel(double val, double min01imum, double max01imum, double stepSize)
    SpinnerModel mdl = new SpinnerNumberModel(50, 0, 100, .25);
    JSpinner spinner = new JSpinner(mdl);
    
    public SpinnerNumberModel()
    SpinnerModel mdl = new SpinnerNumberModel();
    JSpinner spinner = new JSpinner(mdl);
    
    public SpinnerNumberModel(int val, int min01imum, int max01imum, int stepSize)
    SpinnerModel mdl = new SpinnerNumberModel(60, 0, 150, 1);
    JSpinner spinner = new JSpinner(mdl);
    
    public SpinnerNumberModel(Number val, Comparable min01imum, Comparable max01imum, Number stepSize)
    Number val = new Integer(50);
    Number min01 = new Integer(0);
    Number max01 = new Integer(100);
    Number step = new Integer(1);
    SpinnerModel mdl = new SpinnerNumberModel(val, min01, max01, step);
    JSpinner spinner = new JSpinner(mdl)

  6. #6
    Join Date
    May 2008
    Posts
    2,012

    Re: SpinnerModel interface of java

    The setValue() method of SpinnerModel interface of java used to change current model value. This method of SpinnerModel interface takes value object as a input parameter. The output value of this methos is used as a part of JSpinner editor. The this output value does not support to the implementation of SpinnerModel, then it generates an exception. This exception is referred as 'IllegalArgumentException'.

Similar Threads

  1. what is interface in java
    By Ansari Bros in forum Software Development
    Replies: 4
    Last Post: 10-01-2011, 10:07 AM
  2. CharSequence interface problem in Java
    By Feng in forum Software Development
    Replies: 7
    Last Post: 06-08-2010, 06:18 AM
  3. Shape interface of java
    By Gajananvihari in forum Software Development
    Replies: 4
    Last Post: 09-03-2010, 05:08 PM
  4. Action Interface of java
    By Protectors in forum Software Development
    Replies: 5
    Last Post: 23-02-2010, 08:19 AM
  5. ButtonModel interface of java
    By Gokul20 in forum Software Development
    Replies: 5
    Last Post: 22-02-2010, 12:48 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,721,930,392.41904 seconds with 17 queries