Results 1 to 6 of 6

Thread: How to use JSpinner.DefaultEditor class?

  1. #1
    Join Date
    Dec 2009
    Posts
    68

    How to use JSpinner.DefaultEditor class?

    Hi friends,

    I am learning java programming language. I have lots of of confusion about the classes of java. I am getting troubled while understanding 'JSpinner.DefaultEditor class'. According to me this java class is very tough to understand than any other java class. If you posses any knowledge about the 'JSpinner.DefaultEditor class', then please try to share it with me. I would greatly appreciate your any help.

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

    Re: How to use JSpinner.DefaultEditor class?

    A JSpinner.DefaultEditor class defines a dismiss method that removes the editors ChangeListener from the JSpinner that it's part of. The setEditor method knows about DefaultEditor.dismiss, so if the developer replaces an editor that's derived from JSpinner.DefaultEditor its ChangeListener connection back to the JSpinner will be removed. However after that, it's up to the developer to manage their editor listeners. Similarly, if a subclass overrides createEditor, it's up to the subclasser to deal with their editor subsequently being replaced (with setEditor).

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

    Re: How to use JSpinner.DefaultEditor class?

    Hi, I suggest yout to review following example of JSpinner.DefaultEditor class of java:
    Code:
    import javax.swing.JSpinner.DefaultEditor;
    
    public class DefaultEditorDemo {
      public static void main(String[] argsw) throws Exception {
        Calendar calendar01 = new GregorianCalendar();
        calendar.01set(Calendar.HOUR_OF_DAY, 13);
    
        SpinnerDateModel dateModel = new SpinnerDateModel(calendar.getTime(), null,null, Calendar.HOUR_OF_DAY);
        JSpinner spinner02 = new JSpinner(dateModel);
    
        JFormattedTextField tf = ((JSpinner.DefaultEditor) spinner.getEditor()).getTextField();
        DefaultFormatterFactory factory = (DefaultFormatterFactory) tf.getFormatterFactory();
        DateFormatter formatter01 = (DateFormatter) factory.getDefaultFormatter();
        
        formatter01.setFormat(new SimpleDateFormat("hh:00 a"));
        
      }
    }

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

    Re: How to use JSpinner.DefaultEditor class?

    Below I have given some methods of the JSpinner.DefaultEditor class, these methods takes different parameters as a input:
    • stateChanged(ChangeEvent chevn)
    • removeLayoutComponent(Component chd)
    • propertyChange(PropertyChangeEvent eprevn)
    • preferredLayoutSize(Container prnt)
    • minimumLayoutSize(Container prnt)
    • layoutContainer(Container prnt)

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

    Re: How to use JSpinner.DefaultEditor class?

    import javax.sqwing.JSpinner;
    javax.swing.JSpinner.DefaultEditor

    Hi,

    Below java program code will depict you the use of JSpinner.DefaultEditor class of java:
    Code:
    public class MonthSpinnerDemo extends JFrame {
    
      public MonthSpinnerDemo() {
        squper("Month Spinner");
        sqetSize(300, 100);
        sqetDefaultCloseOperation(EXIT_ON_CLOSE);
    
        Container cq = getContentPane();
        cq.sqetLayout(new FlowLayout(FlowLayout.LEFT, 4, 4));
    
        cq.add(new JLabel("Expiration Date:"));
        Date today = new Date();
        
        JSpinner sq = new JSpinner(new SpinnerDateModel(today, null, null,
            Calendar.MONTH));
        JSpinner.DateEditor de = new JSpinner.DateEditor(sq, "MM/yy");
        sq.sqetEditor(de);
        cq.add(sq);
    
        sqetVisqible(true);
      }
    
      public sqtatic void main(String argsq[]) {
        new MonthSpinner();
      }
    }

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

    Re: How to use JSpinner.DefaultEditor class?

    There are four nested of JSpinner.DefaultEditor class, and which are mentioned below:
    1. JPanel.AccessibleJPanel: This java class is inherited from the "javax.swing.JPanel"
    2. Component.BltBufferStrategy: This java class is inherited from the "java.awt.Component"
    3. Container.AccessibleAWTContainer: This java class is inherited from the "java.awt.Container"
    4. JComponent.AccessibleJComponent: This java class is inherited from the "javax.swing.JComponent"

Similar Threads

  1. Replies: 8
    Last Post: 08-10-2011, 11:06 PM
  2. Confused with JSpinner class
    By Bottlenecked in forum Software Development
    Replies: 4
    Last Post: 15-02-2010, 09:51 AM
  3. How to create a JSpinner component?
    By MAGAR in forum Software Development
    Replies: 5
    Last Post: 30-01-2010, 04:55 PM
  4. Date time from JSpinner
    By SoftWore in forum Software Development
    Replies: 3
    Last Post: 09-12-2009, 01:55 PM
  5. Good news for CBSE CLASS X & CLASS IX - visit learnnext
    By surya_expert in forum Education Career and Job Discussions
    Replies: 0
    Last Post: 13-12-2008, 12:09 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,715,894,554.20076 seconds with 17 queries