Im trying to use data form input boxes ( integers) and draw a triangle with the numbers received. I can get the numbers fine but I can seem to grab them form the static class.
what am I doing wrong ...
Code:
import java.awt.*;
import java.applet.*;
import javax.swing.*;
public class Triangle
{
int a;
int b;
int c;
public static int main (String[] args)
{
int perimeter;
int sa;
String SA;
SA = JOptionPane.showInputDialog("Enther the legenth of side A :");
sa =Integer.parseInt(SA);
int sb;
String SB;
SB = JOptionPane.showInputDialog("Enter the legenth of side B: ");
sb = Integer.parseInt(SB);
int sc;
String SC;
SC = JOptionPane.showInputDialog("Enter the legenth of side C: ");
sc = Integer.parseInt(SC);
perimeter = sa + sb + sc ;
JOptionPane.showMessageDialog( null,"The Permeter of you triangle is " + perimeter);
//a= sc;
//b= sb;
//c=sc;
Triangle da = new Triangle();
System.exit(0);
}
public static int paint(Graphics canvas)
{
canvas.drawLine( 100,100, 150,sa);
canvas.drawLine(100,100,150,sb);
canvas.drawLine(100,100,50,sc);
}
}
Comment