Results 1 to 5 of 5

Thread: Confused with JSpinner class

  1. #1
    Join Date
    Dec 2009
    Posts
    67

    Confused with JSpinner class

    Hi All,

    I need your help to solve one of my query related to the java classes. I am not able to understand the concept of 'JSpinner class'. Even I don't have any idea about it's use. I also want to be aware about methods and constructors of 'JSpinner class'. I have referred lots of java book, but nothing was helpful. If have knowledge about the 'JSpinner class' of java, then please let me know that. Your help would be greatly appreciated.

  2. #2
    Join Date
    Apr 2008
    Posts
    2,005

    Re: Confused with JSpinner class

    Hi,

    A JSpinner class comprises single line input field that lets the user select a number or an object value from an ordered sequence. Spinners typically provide a pair of tiny arrow buttons for stepping through the elements of the sequence. The keyboard up/down arrow keys also cycle through the elements. The user may also be allowed to type a (legal) value directly into the spinner. Although combo boxes provide similar functionality, spinners are sometimes preferred because they don't require a drop down list that can obscure important data.

  3. #3
    Join Date
    May 2008
    Posts
    2,297

    Re: Confused with JSpinner class

    Example of JSpinner class of java:
    Code:
    import javax.swing.JSpinner;
    import javax.swing.SpinnerDateModel;
    
    public class JSpinnerSample {
      public static void main(String[] argv) throws Exception {
        Calendar cal = new GregorianCalendar();
        cal.set(Cal.HOUR_OF_DAY, 13); // 1pm
    
        SpinnerDateModel dateModelp = new SpinnerDateModel(calendar.getTime(), null,
            null, Cal.HOUR_OF_DAY);
        JSpinner spinner = new JSpinner(dateModel);
    
        JFormattedTextField tfp = ((JSpinner.DefaultEditor) spinnerp.getEditor()).getTextField();
        DefaultFormatterFactory factoryp = (DefaultFormatterFactory) tfp.getFormatterFactory();
        DateFormatter formatterp = (DateFormatter) factoryp.getDefaultFormatter();
    
        
        formatterp.setFormat(new SimpleDateFormat("hh:00 a"));
        //formatterp.setFormat(new SimpleDateFormat("HH:00 a"));
      }
    }

  4. #4
    Join Date
    Oct 2005
    Posts
    2,393

    Re: Confused with JSpinner class

    Hello friend,

    There are number of methods are available with JSpinner class, please review following some of them methods
    • setValue(Object val)
    • setUI(SpinnerUI spui)
    • setModel(SpinnerModel mdl)
    • setEditor(JComponent edtr)
    • removeChangeListener(ChangeListener lstnr)
    • addChangeListener(ChangeListener lstnr)
    • createEditor(SpinnerModel mdl)

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

    Re: Confused with JSpinner class

    Below is very simple java example to know about the JSpinner class. A JSpinner class is taken from the package'import javax.swing.JSpinner;'.
    Code:
    import javax.swing.JSpinner;
    
    public class JSPR
    
    {
      public static void main(String[] argvj) throws Exception 
    
    {
        JSpinner spinnerT = new JSpinner();
        // Create a number spinner
    
        
        spinnerT.setValue(new Integer(200));
        // Set its value
      }
    }

Similar Threads

  1. Confused about Scrollbar class
    By Jagruti23 in forum Software Development
    Replies: 5
    Last Post: 06-03-2010, 04:18 PM
  2. Confused with DefaultListModel class
    By Khan Baba in forum Software Development
    Replies: 4
    Last Post: 19-02-2010, 12:29 PM
  3. Confused about JApplet class
    By ScarFace 01 in forum Software Development
    Replies: 5
    Last Post: 19-02-2010, 08:50 AM
  4. How to use JSpinner.DefaultEditor class?
    By ScarFace 01 in forum Software Development
    Replies: 5
    Last Post: 15-02-2010, 09:18 AM
  5. Confused with JToolTip class
    By opaper in forum Software Development
    Replies: 5
    Last Post: 13-02-2010, 08:53 AM

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,711,655,317.96267 seconds with 17 queries