Results 1 to 2 of 2
  1. #1
    habiler is offline Member
    Join Date
    Sep 2016
    Posts
    44
    Rep Power
    0

    Default populate jTextField

    Hello everybody

    how can populate a jTextfield with the value of a result of a calculation.


    in this case :
    jTextFieldNbrMois.add(difInMonths);?

    Thanks

    Habiler

    Java Code:
                                  {
                                      Calendar sDate = Calendar.getInstance();
                                      Calendar eDate = Calendar.getInstance();
                                      sDate.setTime(jDateChooserFin.getDate());
                                      eDate.setTime(jDateChooserDebut.getDate());
                                      int difInMonths = sDate.get(Calendar.MONTH) - eDate.get(Calendar.MONTH);
                                      JOptionPane.showMessageDialog(null,""+difInMonths+" mois","Nombre de mois !!!",JOptionPane.PLAIN_MESSAGE);
                                      System.out.println("Nbr de mois :"+difInMonths+"");
                                      
                                      jTextFieldNbrMois.add(difInMonths);
                                  }

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    14

    Default Re: populate jTextField

    For help such as this, check out the Java API documentation. And when you do, make certain you look at the inherited methods.
    I believe what you want is the setText() method. It is inherited from JTextComponent.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

Similar Threads

  1. Replies: 1
    Last Post: 07-17-2014, 02:27 PM
  2. Replies: 3
    Last Post: 11-14-2011, 05:13 AM
  3. Replies: 0
    Last Post: 08-30-2011, 09:18 AM
  4. How to populate a List within a Map
    By elliotHenry in forum New To Java
    Replies: 14
    Last Post: 03-29-2011, 08:25 PM
  5. Replies: 1
    Last Post: 01-30-2009, 06:44 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •