Action Listener have a utility to listen every action performed on a particular component.
For Example (Purpose: Result=Operator1+Operator2):
Result of source code:
Source Code
import java.util.Scanner;
public class Pyramid {
public static void main(String[] args) {
int _heightpiramid = 1;
Scanner sc = new Scanner(System.in);
System.out.println("Tutorial make pyramid in Java");
System.out.println("-----------------------------");
System.out.print("Entry height of pyramid : ");
_heightpiramid = sc.nextInt();
System.out.println("Result : ");
for (int x = 0; x < _heightpiramid; x++) {
for (int z = (_heightpiramid - 1) - x; z > 0; z--) {
System.out.print(" ");
}
for (int y = 0; y <= x; y++) {
System.out.print("*");
}
for (int y = 1; y <= x; y++) {
System.out.print("*");
}
System.out.print("\n");
}
}
}
Note :
1. Entry a Operator 1 and Operator 2 Field
I hope this tutorial can help you..^^
Sunday, January 23, 2011
How to add Action Listener in Java
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment