KickJava   Java API By Example, From Geeks To Geeks.

Java > Java SE, EE, ME > java > beans > PropertyEditor

java.beans
Interface PropertyEditor

All Known Implementing Classes:
PropertyEditorSupport
See Also:
Top Examples, Source Code

void addPropertyChangeListener(PropertyChangeListener listener)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


String getAsText()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


Component getCustomEditor()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


String getJavaInitializationString()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


String[] getTags()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


Object getValue()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1773]
By Anonymous on 2006/06/05 12:25:04  Rate
// Write comments for programmer identification and to describe  
 // what the program does. 
   
 import java.util.Scanner;  
 import java.lang.Math;  
 public class CalcAge  
  
  
  {   
   static Scanner console = new Scanner ( System.in ) ;  
   public static void main ( String [  ]  args )   
    {   
     int currentYear = 0, currentMonth = 0, year, month, age; String line;  
     char again = 'y';  
     System.out.println ( "This program asks you to enter today's " + "year in 4-digits.\n"  
     + "Then it asks you to enter today's month number.\n\n" + "In the next step you will be asked to enter "  
     + "the 4-digit year of your birth.\n"  
     + "Then you will be asked to enter the month number " + "of your birth.\n\n"  
     + "The program will calculate and display how old you " + " are in years and months.\n\n" ) ;  
     while  ( currentYear  <  2006 || currentMonth  <  1 || currentMonth  >  12 )   
      {   
       // Call the method getValue with the String argument,  
       // "Enter today's 4-digit year: "  
       currentYear = getValue; 
       if  ( currentYear  <  2006 )   
         System.out.println ( "You did not enter current year.\n" ) ;  
       else  
        {   
       // Call the method getValue with the String argument,   
       // "Enter today's month number: "  
         currentMonth = getValue; 
         if  ( currentMonth  <  1 || currentMonth  >  12 )   
           System.out.println ( "You did not enter a month" + "between 1 and 12.\n" ) ;  
        }   
      }   
     while  ( again == 'y' )   
      {   
       // Call the method getValue with the String argument,  
       // "Enter the 4-digit year of your birth: "  
       year = getValue; 
       if  ( year >  currentYear || year  <  1 )   {   
         System.out.println ( "You did not enter a valid year.\n" ) ;  
         continue;  
        }   
       // Call the method getValue with the String argument, 
       // "Enter the month number of your birth: "  
       month = getKetter; 
       if  ( month  <  1 || month >  12 )   {   
         System.out.println ( "You did not enter a valid" + "month. \n" ) ;  
         continue;  
        }   
        
       if  ( currentMonth  >  month )   {   
         age = currentYear - year;  
         month = currentMonth - month;  
        }   
        
       else if  ( currentMonth == month )   {   
         age = currentYear - year;  
         month = 0;  
        }   
        
       else  {  //currentMonth  <  month  
           age = currentYear - year - 1;  
           month = 12 - month + currentMonth;  
        }   
       if  (   ( age  <  0 || age >  120 )  ||  ( age == 0 && month  <  0 )   )   
        {   
         System.out.println ( "You did not enter valid dates.\n" ) ;  
         continue;  
        }   
       System.out.println ( "You are " + age + " years and " + month + " months old. \n"  )  ;  
       // Call the method getLetter with the String argument,  
       // "Do you want to enter more data? y/n "  
       again = getLetter; 
      }  // end while  
    }  //end of main  
  
  
   // Write the heading for the value-returning method  
   // getValue, which has a String formal parameter  
   // named message.  
    {   
     int value;  
     System.out.print ( message ) ;  
     System.out.flush (  ) ;  
     value = console.nextInt (  ) ;  
     return value;  
    }  //end of getValue  
   // Write the heading for the value-returning method  
   // getLetter, which has a String formal parameter  
   // named message.  
    {   
     char letter;  
     String line;  
     System.out.print ( message ) ;  
     System.out.flush (  ) ;  
     line = console.next (  ) ;  
     letter = line.charAt ( 0 ) ;  
     return letter;  
    }  // end of getLetter  
  }  // end of class 


boolean isPaintable()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void paintValue(Graphics gfx,
                Rectangle box)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void removePropertyChangeListener(PropertyChangeListener listener)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void setAsText(String text)
               throws IllegalArgumentException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void setValue(Object value)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


boolean supportsCustomEditor()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  

Popular Tags