Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Spring Framework | Web Services | BioInformatics | Java Server Faces | Jboss 3.0 tutorial | Hibernate 3.0 | XML

Tutorial Categories: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML


 

Java Tutorials


 

 

Struts Tutorials

Struts Resources

Visit Forum! Post Questions!
Jobs At RoseIndia.net!

Area Of A Triangle, Java Java Conversion How To Calculate Area Of Triangl

User Comments
Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl
  Blink   Furl   Simpy   Y! MyWeb 

;
 
Java Examples for Beginners
Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

1 comments so far (post your own) View All Comments Latest 10 Comments:

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("");

}
}
}









Posted by red on Monday, 03.15.10 @ 17:19pm | #95588

Ask programming questions?

 

 

Back to Tutorial
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification

Tell A Friend
Your Friend Name

 

 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright 2007. All rights reserved.