/* Copyright (c) SEMM NL All rights reserved.
Author : Paul Hamaker. Part of JavaLessons.com
This code is for educational purposes only. Use at own risk.*/

1. import java.awt.* ; 

2. import java.applet.* ; 

3. import java.awt.event.*; 

4.  

5. public class Numlimits 

6.     extends Applet 

7.     implements ActionListener 

8.

9.   Button btn , btn2, btn3, btn4 ; 

10.   TextField tf, tf2 ; 

11.  

12.   byte byteuno = 126

13.   short shortuno =   32766

14.  

15.   public Numlimits ( ) 

16.   { 

17.     btn = new Button ( "+" ) ; 

18.     btn2 = new Button ( "-" ) ; 

19.     btn3 = new Button ( "+" ) ; 

20.     btn4 = new Button ( "-" ) ; 

21.  

22.     tf = new TextField ( 10 ) ; 

23.     tf2 = new TextField ( 10 ) ; 

24.   } 

25.   public void init ( ) 

26.   { 

27.     btn.addActionListener ( this ) ; 

28.     btn2.addActionListener ( this ) ; 

29.     btn3.addActionListener ( this ) ; 

30.     btn4.addActionListener ( this ) ; 

31.  

32.     add ( btn ) ; 

33.     add ( btn2 ) ; 

34.     add (tf); 

35.  

36.     add ( btn3 ) ; 

37.     add ( btn4 ) ; 

38.     add (tf2); 

39.     setBackground ( Color.orange ) ; 

40.  

41.     tf.setText ( byteuno + "" ); 

42.     tf2.setText ( shortuno + "" ); 

43.     validate() ; 

44.   } 

45.  

46.   public void actionPerformed( ActionEvent ev ) 

47.   { 

48.     if ( ev.getSource() == btn ) 

49.     { 

50.       ++byteuno ; 

51.       tf.setText ( byteuno + "" ) ; 

52.       return

53.     } 

54.     if ( ev.getSource() == btn2 ) 

55.     { 

56.       --byteuno ; 

57.       tf.setText ( byteuno + "" ) ; 

58.       return

59.     } 

60.     if ( ev.getSource() == btn3 ) 

61.     { 

62.       ++shortuno ; 

63.       tf2.setText ( shortuno + "" ) ; 

64.       return

65.     } 

66.     if ( ev.getSource() == btn4 ) 

67.     { 

68.       --shortuno ; 

69.       tf2.setText ( shortuno + "" ) ; 

70.       return

71.     } 

72.   } 

73.

74. /*=====  fundamental data types  =========== 

75. byte   -128 through +127 

76.  short   -32768 through +32767 

77.   int     -2,147,483,648 through +2,147,483,647 

78.    long     -9223372036854775808 

79.             through +9223372036854775807 

80.  

81. float     1.40239846E-45  through  +3.40282347E38 

82.  double      4.94065645841246544E-324 

83.             through 1.7976931348623157E308 

84.  

85. char   {  'k'  '@'  '\n'  '\\'  '\u00fc' }  2bytes, Unicode 

86.                     LF     \       

87.  

88. boolean   {  true  false  } 

89. */ 

90.