Home Tutorialhelp Comment area of a triangle

 
 

Comment

red
area of a triangle,
March 15, 2010 at 5:19 PM

import java.awt.*;
import java.awt.event.*;
public class triangle extends Frame implements ActionListener{
private static final int xpos=150;
private static final int ypos=150;
private static final int length=300;
private static final int width=200;

public static String input,NUM,input1;
public static double num;
public static int i,i1;


Button btnclear=new Button("CLEAR");
Button btncompute=new Button("COMPUTE");

TextField txtsname=new TextField("");
TextField txttf=new TextField("");
Label lblave1=new Label("");
Label lbltf1=new Label("");
TextField txtave=new TextField("");

public triangle(){
setSize(length,width);
setLocation(xpos,ypos);
setTitle("TRIANGLE AREA");
setResizable(false);
setLayout(null);
setBackground(Color.BLACK);
setForeground(Color.YELLOW);

Label lblsname=new Label("Base");
lblsname.setBounds(5,50,120,20);
add(lblsname);
txtsname.setBounds(150,50,100,20);
txtsname.setBackground(Color.RED);
add(txtsname);

Label lblave=new Label("Height:");
lblave.setBounds(5,80,120,20);
add(lblave);
txtave.setBounds(150,80,100,20);
txtave.setBackground(Color.RED);
add(txtave);

Label lbltf=new Label("Area of Triangle:");
lbltf.setBounds(5,110,120,20);
add(lbltf);
lbltf1.setBounds(150,110,100,20);
lbltf1.setBackground(Color.RED);
add(lbltf1);


btncompute.setBounds(100,150,70,20);
add(btncompute);
btncompute.addActionListener(this);
btncompute.setForeground(Color.BLACK);

btnclear.setBounds(190,150,70,20);
add(btnclear);
btnclear.addActionListener(this);
btnclear.setForeground(Color.BLACK);


show();
}
public void actionPerformed(ActionEvent event){
Button clickedButton=(Button)event.getSource();
if(clickedButton==btncompute){
input=txtsname.getText();
i=Integer.parseInt(input);

input1=txtave.getText();
i1=Integer.parseInt(input1);

num=.5*(i*i1);
NUM=Double.toString(num);
lbltf1.setText(NUM);
}
if(clickedButton==btnclear){
txtsname.setText("");
txtave.setText("");
lbltf1.setText("");

}
}
}










View All Comments | View Tutorial
Advertisement
Related Tutorial and Articles
General

How to calculate area of triangle
; In this section we will learn how to calculate area of triangle. We... the area of triangle define the method triangle which will calculate the area... .style1 { margin-right: 0px; } How to Calculate 

General

How to calculate area of rectangle
How to Calculate Area of Rectangle       In this section we will learn how to calculate area... rectangle method which takes two parameters of type integer. To calculate the area 

Java Tips and Examples

Write a program to calculate area and perimeter of a circle
Write a program to calculate area and perimeter of a circle... example will teach you the method for preparing a program to calculate the area...; under Java I/O package and define and integer r=o, which is the radius 

Java Beginners

area of a circle - Java Beginners
area of a circle  Write a class circle which consists of functions getdata() and area(), and also write a main program to create a circle object and to find the area by calling the function area () in circle class and display 

SQL Tutorial

MySQL Area
MySQL Area       This example illustrates how to find the area of rectangle in MySQL. In this example... ; Run Procedure to calculate area: You can run MySQL stored procedure by using 

General

How to calculate area of Circle
How to Calculate Area of Circle   ... of calculating  the area of circle. In this program you will be taught each and every... below. Description of program: In this section we will learn how to use of static 

Java Beginners

BlueJ (area of circle)
BlueJ (area of circle)  How does one write a program to calculate the area of a circle in BlueJ? Note that the user will have to provide the radius.   A simple program to calculate the area of a circle. radius provided 

General

How to Create Text Area In Java
How to Create Text Area In Java       In this section, you will learn how to create Text Area in Java... and a text area is also created on the panel by using JTextArea class 

JavaScript Questions

Text Area
Text Area  how to browse an image in text area instead of giving url of particular image 

Java Server Faces Questions

Generate area for map from backing bean - Java Server Faces Questions
Generate area for map from backing bean  I need to populate the map in my page, and the coordinates should come from the backing bean.. How could I do 

Java Beginners

accepts the area of a square and will calculate its perimeter.
accepts the area of a square and will calculate its perimeter.  Develop a program that accepts the area of a square and will calculate its perimeter... input=new Scanner(System.in); System.out.println("Enter Area of Square 

Java Beginners

Method which returns area of circle - Java Beginners
Method which returns area of circle  Need simple Java Method example that returns area of circle  Java Example CodeWith the help of given Java code you can return the area of a circle and give the radius 

MySQL

MySQL Area
MySQL Area  This example illustrates how to find the area of rectangle in MySQL. In this example we create a procedure to find the area of rectangle. In the query below we declare two integer type variable w and h with default 

SQL Question

bean area - SQL
bean area  how to print bean area in excel sheet from oracle forms 

Java Tips and Examples

A Program to find area and perimeter of Rectangle
to understand the concepts. We will write a program, which calculate the area... with the dot operator, invoking the method area(), which calculate the area and perimeter...A Program to find area and perimeter of Rectangle In this section we 

Java Beginners

how to perform a equqlity triangle in java
how to perform a equqlity triangle in java  below the output 1 2 3 4 6 5 7 9 10 8 

General

Clip Area
Clip Area       This section illustrates you how to show the clipping of Area. A Clip... shows the clipping of area. In the given example, we have defined two buttons 

Development process Questions

hello Deepak -how to highlight the area in image
hello Deepak -how to highlight the area in image  how to highlight the specific area in image,when the cursor is at corresponding field's textbox. Here webpage consist of a jpeg image on the top and below that manual fields(text 

Java Beginners

java
. * A method naned getArea() that returns the area of this triangl...java  design a class named triangle that extends geometricobject.the... with default values 1.0 to denote three sides of the triangle. * A no-arg constructor 

Java Beginners

How to create an area chart using jfreecharts?
How to create an area chart using jfreecharts?  i want to create an area chart that represents ip addresses of top countries. i have gone thru the area chart example using jfreechart but i am still not clear with its method. If u 

Java Beginners

how to perform a equqlity triangle in java
how to perform a equqlity triangle in java  below the output 1 2 3 4 6 5 7 9 10 8   Here is an example of pattern like 1 2 3 4 5 6 7 8 9 10 Example : public class NumberTriangleClass{ public static void 

Java Tips and Examples

Write a program to construct a triangle with the ?*?
'*'. First of all make a class named 'triangle' under the Java I/O package... Write a program to construct a triangle with the ?*?       This lesson in Java 

Java Beginners

java conversion
java conversion  how do i convert String date="Aug 31, 2012 19:23:17.907339000 IST" to long value 

Java Beginners

Find Cylinder area By inputting value from user
Find Cylinder area By inputting value from user  Hello Sir I need the code for calculating the area of a cylinder in which it asks radius value from user and then calculate area using this radius value. Please provide me 

HTML5

Rel attribute in area tag, Use of rel attribute in area tag.
Rel attribute in area tag, Use of rel attribute in area tag. In this tutorial, you will see the use of rel attribute of area tag and how to implement... : Declaration syntax of rel attribute in area tag.      

JavaScript Questions

Auto grow Text Area using jQuery plug-in
Auto grow Text Area using jQuery plug-in  Hi sir How can we make a textarea auto grow ? What is the name of the plug-in used for auto grow text area. Please mention code with your reply 

Java Code Examples

Java create triangle pattern
Java create triangle pattern In this tutorial, you will learn how to create a triangle shape. For this, user is allowed to enter number of lines to display the triangle of that length and a symbol to show the triangle in a particular 

Java Beginners

Java draw triangle draw method?
Java draw triangle draw method?  hi how would i construct the draw method for an triangle using the 'public void draw (graphics g ) method? im unsure how to use the g.fillPolygon and g.drawPolygon? i have this for drawing 

JavaScript Questions

java script to replace words starting and ending with tild(~) symbol in a text area with the word highlighted yellow.
java script to replace words starting and ending with tild(~) symbol in a text area with the word highlighted yellow.  Hi, I have an issue with highlighting text in a text area. I am designing a page to send email. currently 

HTML Questions

triangle
triangle  how to draw triangle numbers with stars in html with the help of javascript 

Java Beginners

Java Conversion Question - Java Beginners
Java Conversion Question   Hello sir ,How i can Convert Java Code to Vb.net ,Plz Help Me 

Development process Questions

How to use Bean Area in Oracle Forms 9i with Sample code ?
How to use Bean Area in Oracle Forms 9i with Sample code ?  Hi friend.I posted a query,but I didn't get the answer for it.Help me to resolve including a bean area in oracle forms 9i and using it in forms.Thanks in advance.Help me 

Java Beginners

Calculate sum and Average in java
Calculate sum and Average in java  How to calculate sum and average in java program?   Example:- import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class AvarageTest 

Java-Tutorials

Java Program Floyd's Triangle
Java Program Floyd's Triangle In this section you will read about how to write a Java program to print Floyd's triangle. This tutorial is about printing a Floyd's triangle in Java. Here you will learn about all the steps 

Java Beginners

Triangle program
Triangle program  1 121 12321 1234321 123454321 kindly give the code 4 this program in java    1 121 12321 1234321 write a program for this triangle    1 121 12321 1234321 write a program 

Java Beginners

image conversion tools
image conversion tools  how many tools are available in image conversion at particularlly in java 

Java Beginners

Type Conversion - Java Beginners
Type Conversion   Hai, rajanikanth, Please explain how to convert from integer value to a string value .In a database operation i want to convert... for conversion 

HTML5

Area Tag in html5, Definition of <area> tag in HTML5.
Area Tag in html5, Definition of  <area> tag in html5... in the html document. The <area> tag is used for creating an area...: The syntax for the <area> tag is as follows: <area 

Programming Tutorials

Auto grow Text Area using jQuery plug-in
Auto grow Text Area using jQuery plug-in In this section, you will learn how to create a text area which auto grow on increment of the content using jQuery Plug-in. We fixed the height of text area to 70 pixels .The size of the window 

Java Beginners

form to java script conversion
form to java script conversion  I am using a form one more form cotain a piece of code . how to convert it to java script to function it properly? code is shown below <form action="http://www.google.com" id="cse-search 

RUP Questions

how to calculate max and min - RUP
how to calculate max and min  hye!i'm a new for the java and i want to ask a question . Could anyone help me to teach how to calculate the maximum and minimum using java language.  Hi friend, In Math class having two 

Chart and Graphs

Create area chart in JSP page using JFreeChart
Create area chart in JSP page using JFreeChart       This Example shows you how to create a area chart in JSP page using JFreeChart. Code given below creates a area 

Java Beginners

conversion - Java Beginners
conversion  how to convertor .xl to .pdf and .pdf to .xl and .mp4 to .mp3  Hi Friend, Try the following code: 1)xls to pdf: import java.io.*; import java.util.*; import com.lowagie.text.*; import 

Java Beginners

Java To Vb.Net Conversion - Java Beginners
Java To Vb.Net Conversion  How to convert Java Code To VB.net,which Software is useful to convert java to vb.net,plz Help Me 

Java Beginners

how to calculate max and min in the loop - Java Beginners
how to calculate max and min in the loop  thanks coz giving me the answer for my question. i want to know is there possible calculation for the max... this array values into integer.   Hi friend, Import the java input 

Java Tips and Examples

Change the user input to integer
a method parseInt(). In this program we are going to calculate a area... in the method show() and the area will be calculated by calculate() method.... In the first class we have used two methods, show(int x, int y) and calculate(). First 

Java-Tutorials

Area Chart
Area Chart       In this section we are providing you an example to create a Area Chart. Description of Program For creating a Area Chart we use the object 

Development process Questions

Conversion - Development process
Conversion  Why is there a need to convert from Java to .NET? What is the theory of conversion from java to .NET? How it is done?   Hi... Conversion Assistant (JLCA). Code that calls Java APIs can convert to comparable C# code 

Java Tips and Examples

Write a program for calculating area and perimeter of a rectangle
Write a program for calculating area and perimeter of a rectangle... are a newbie in Java programming then our tutorials and examples will be helpful in understanding Java programming in the most simplest way. Here after reading 

HTML5

HTML5 <area> href, hreflang attribute of area tag.
;area> tag in html5. href: The href attribute specifies the URL link for the area... are as follow: href_attribute_of_area_tag.html <!DOCTYPE  

Date Calendar

Java Date conversion - Date Calendar
Java Date conversion  How do I convert 'Mon Mar 28 00:00:00 IST 1983' which is a java.util.Date or String to yyyy/MM/dd date format in sql 

HTML Tutorial

Text Area in HTML
Text Area in HTML       Text  Area in HTML is used to write unlimited number of text in it. Understand with Example The Tutorial illustrate an example from Text Area 

General

Calculate Company's Sale using Java
Calculate Company's Sales Using Java In this section, you will learn how to calculate Company's sale. A company sales 3 items at different rates and details of sales ( total amount) of each item are stored on weekly basis i.e. from Monday 

Java Beginners

how to write a program in java to print numbers in equalateral triangle
how to write a program in java to print numbers in equalateral triangle  the output must be 1 324 76589   Here is an example of pattern 1 2 3 4 5 6 7 8 9 Example: public class NumberTriangle{ public 

Java Beginners

Week calculate start from friday
Week calculate start from friday  My problem is to calculate how many weeks have a month. Note that my weeks have to start on Friday! I have three..., because the week starts on Friday. Can anyone help me,...PLEASE? (Java 

Java Beginners

calculate average
calculate average   Design and write a java program to determine all three digit numbers such that the sum of the cubes of the digits is equal... and write a program and calculate your final average in this course. The details 

General

Add Area of Two Figures
Add Area of Two Figures       This section illustrates you how to add area of two specified figures... rectangle and oval respectively. Object of class Area is created to pass 

Java Beginners

Java
Java   1Wap to find the area of square and circle using switch statement 2 Wap to find the area of triangle whose sides are a,b,c which are not in equal lenght 

Java Beginners

pdf to xml conversion
pdf to xml conversion  i want to convert pdf file into xml file.. where i am having a table in pdf file with some headers and some data into it. i want the headers to be the tag of xml file. how can i do that using java? please 

Java Interview Questions

how can i calculate loan - Java Interview Questions
how can i calculate loan  negotiating a consumer loan is not always.... the program should then calculate the face value required in order for the consumer to receive the amount needed. it should also calculate the monthly payment 

Java Beginners

object conversion - Java Beginners
/java-conversion/ObjectToDouble.shtml Thanks... sandeep kumar suman...object conversion   Hi, Can anybody tell me the object conversion in java.   Hi sandeep Can u please tell me in details about your 

Applet Questions

conversion Applet
conversion Applet  I am a java beginner.................. strong texthow to create JApplet that prompts the user to enter a distance in miles in a JTextField and then converts mile to kilometers and display the result as XX.XX 

General

Java example to calculate the execution time
Java example to calculate the execution time  ... will describe you the way that how one can calculate or get the execution time of a method or program in java. This can be done by subtracting the starting time 

Java Beginners

Conversion from color to Gray Image - Java Beginners
Conversion from color to Gray Image  Hi... Sakthi here.. i am new to java. and i haven't try this so far How to convert the color image to gray scale image in java? could u plz help me out to start the process 

General

Java Conversion
Java Conversion      ..., you will learn how to convert  binary number  into decimal... In this section, you will learn how to convert a char into a string type data 

General

Calculate the Sum of three Numbers
. In this section you will learn how to calculate the sum of three numbers by using three... how to calculate three integer number . First of all define class name "... Calculate the Sum of Three Numbers    

Java Beginners

calculate size of array
calculate size of array  Is it possible to calculate the size of array using pointers in Java 

Swing AWT

hybrid chart(Stacked Area and Line ) - Swing AWT
hybrid chart(Stacked Area and Line )  hello i have a problem... different chart stacked area chart and line chart both in a single frame... to display hybrid graph (Stacked Area and Line ).combination of stacked area chart 

Java Beginners

html2xml conversion
html2xml conversion  java code to convert html file to xml 

Java Beginners

Language Conversion
Language Conversion  write a java program to convert "Hello World" in spanish 

Java Beginners

scanner problem - Java Beginners
are providing you a code that will calculate the area of triangle having base and height...(); double area=b*h*1/2; System.out.println("Area of Triangle =" +area...scanner problem  the program that enters sides of the triangle using 

Java Beginners

Code to calculate hair density
Code to calculate hair density  Hello, Would you please give me a code to calculate the hair density on scalp from image in java 

JSP Servlet Questions

spell cheking in text area - JSP-Servlet
spell cheking in text area   Hi Good Morning. I am developing web application. Now i am in one JSP page. in this page i have 1 text area. i want spell check functionality by pressing right click in this text area.but i don't 

Java Beginners

A Program To Print A Equilateral Triangle
A Program To Print A Equilateral Triangle  Write A program to Print Following In Java : 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 

General

Subtract Area between two Figures
Subtract Area between two Figures       This section illustrates you how to subtract the area between... provides the rectangle and oval shape respectively. Object of class Area 

UML Questions

hexadecimal conversion java compilation - UML
hexadecimal conversion java compilation  write a simple program..., Please visit the following links: http://www.roseindia.net/java/java-conversion/BinaryToHexa.shtml http://www.roseindia.net/java/java-conversion 

Java Beginners

Distance conversion - Java Beginners
Distance conversion  Write an application that reads a distance in metres. The program will then present a user menu of conversion types, converting the distance to kilometres, feet and inches, according to the user?s selection 

Java Beginners

TRIANGLE OF *S AT THE BOTTOM RIGHT!!! - Java Beginners
TRIANGLE OF *S AT THE BOTTOM RIGHT!!!  My Question is to : "Write a program that inputs one integer m and outputs an m-line high triangle of *'s... to make the triangle at the right side but couldn't do so. Can you please solve 

General

Java get Heap Size
Java get Heap Size       In this section, we are going to illustrates you how to obtain the heap size. The heap is the area in the memory used for memory storage during 

General

Calculate sum of even and odd numbers in Java
Calculate sum of even and odd numbers In this section, you will learn how to read the file that contains even and odd numbers and calculate their sum... numbers from the file and then calculate their sum. Here is the code 

Java Beginners

ascii to thai language conversion - Java Beginners
ascii to thai language conversion  I have a string in ascii format like \u0042\u00072 ..., It was converted from thai language. How can i convert it to thai language. I would be more thankful if I get some example or some 

General

Calculate Age using current date and date of birth
Calculate Age using current date and date of birth In this section you will learn how to calculate the age. For this purpose, through the code, we have prompted the user to enter current date and date of birth in a specified format. Now 

Java Beginners

Excel conversion tool. - Java Beginners
Excel conversion tool.  Hi, I need a conversion tool which can convert .xls(Excel 2003) to .xlsx (Excel 2007) and vice-versa. Please suggest any links ro tools. Thank You 

Date Calendar

how can you calculate you your age in daies??
how can you calculate you your age in daies??  **hi, I am beginner in java! can any one help me to write programm to calculate age in daies???**   Hi Friend, Try the following code: import java.util.*; public 

Development process Questions

Triangle pgm
Triangle pgm  how to write code fa this??? 1 222 33333 4444444 55555555 666666666 

Struts Questions

jsp to struts 2 action conversion problem - Struts
jsp to struts 2 action conversion problem  i have one jsp page that includes 3 other jsp pages(using RequestDispactcher).how to convert that jsp...(i.e no java code is involved).remaining pages involve java code.  Hi 

Web Services

Security in Web Service
Develop a web service program for Square   area calculation... as area with return type String Click on add to add parameter... of operation area.      Figure 12 

Programming Tutorials

Calculate total number of elements remaining in the buffer.
Calculate total number of elements remaining in the buffer. In this tutorial, we will discuss how to calculate total number of elements remaining... C:\>java RemainElement Current position of buffer:0 Current 

J2ME

Draw Clip Area Using Canvas
Draw Clip Area Using Canvas       This Example is going to draw a clip with SOLID line. In this picture only solid line show the clipping area. To draw a solid line, we have 

Java Beginners

Triangle problem
Triangle problem  what's the logic for create pattern program how can i create any pattern program with in minute. like this 1 2 5 3 6 8 4 7 9 10 

Java Beginners

java program - Java Beginners
triangle or a scalene triangle. b)Then it calculates and prints the area...java program  what is the program the a simple program in Java... of the triangle and then the program; a)First determines whether the 3 integers entered 

Java Beginners

calculate a list of products
calculate a list of products  Hi can you help me with this java program. This program should allow the user to order from a small catalogue of three items displayed on the screen, then calculate the user's final bill, including 

Java Technology Tutorials

Calculate Sales Tax using Java Program
Calculate Sales Tax using Java Program In this section, you will learn how to calculate the sales tax and print out the receipt details for the purchased items. To evaluate this, we have taken the following things into considerations: 1 

Java Beginners

how to calculate addition of two distances in feets and inches using objects as functions arguments
how to calculate addition of two distances in feets and inches using objects as functions arguments  how to calculate addition of two distances in feets and inches using objects as functions arguments in java 

Java Beginners

Need a Code to calculate hair density in java
Need a Code to calculate hair density in java  Hello, Would you please give me a code to calculate the hair density on scalp from image in java 

General

Find in Array - Calculate Occurrences of Elements in Array
to calculate occurrences of elements in an array. Occurrences means, the how many...;javac OccurancesInArray.java C:\chandan>java OccurancesInArray How many... Find in Array - Calculate Occurrences of Elements in Array 

Java Beginners

String to Date Conversion - Java Beginners
)); For read more information : http://www.roseindia.net/java/java-conversion...  Hi friend, For conversion in this format : 11/SEP/2008 07:07:32 

Applet Questions

Adding text in to text area of jframe at new line with different background colour
Adding text in to text area of jframe at new line with different background... that text in to text area of jframe.But i am reading line by line from file and i want to write that text every time at new line in text area with different background 

Java Beginners

Another distance conversion - Java Beginners
a method for each conversion ? toKilometres(), toFeet(), and toInches 

HTML5

HTML5 type attribute, Definition of type attribute in <area> tag.
of the linked resources. Declaration syntax: <area href=" 

Advertisements Advertisements
 

 

 

DMCA.com