Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Java Applets and Init()?

Name: Anonymous 2007-10-09 21:29

I'm having an issue passing variables from init() and paint() in a Java Applet- what's the rules on those again? I'm trying to pass variables from a user input window to a graphics display thing in paint(), but I can't get them to pass, the values are lost from init() to paint(). Ideas?

Name: Anonymous 2007-10-09 21:30

>>1

That's debatable...

Name: Anonymous 2007-10-09 21:31

I know it's fucking ridiculous, I know Java is a shit language- but I have to take it before I get into C++ and the like. I'm a poor boy from the land of PERL and PHP, this shit annoys me to no end. The code looks like this (uncommented):

public class tester extends JApplet
{
public double dx1;
    String x1, x2, x3, y1, y2, y3;
    triangle tri;
    double area, perim, angleA, angleB, angleC;

    public void init()
    {
    }
    public void start()
    {
   
        String x1 = JOptionPane.showInputDialog("Point 1 X?");
        String y1 = JOptionPane.showInputDialog("Point 1 Y?");
        String x2 = JOptionPane.showInputDialog("Point 2 X?");
        String y2 = JOptionPane.showInputDialog("Point 2 Y?");
        String x3 = JOptionPane.showInputDialog("Point 3 X?");
        String y3 = JOptionPane.showInputDialog("Point 3 Y?");
       
        double dx1 = Double.parseDouble(x1);
        double dy1 = Double.parseDouble(y1);
        double dx2 = Double.parseDouble(x2);
        double dy2 = Double.parseDouble(y2);
        double dx3 = Double.parseDouble(x3);
        double dy3 = Double.parseDouble(y3);
       
        Point2D p1 = new Point2D.Double(dx1,dy1);
        Point2D p2 = new Point2D.Double(dx2,dy2);
        Point2D p3 = new Point2D.Double(dx3,dy3);
        triangle tri = new triangle(p1, p2, p3);
        }
    public void stop()
    {}
    public void paint(Graphics g)
    {
        double perim = tri.getPerimeter(tri.getLength(1),tri.getLength(2),tri.getLength(3));
        JOptionPane.showMessageDialog(null,perim);
        double area = tri.getArea(tri.getLength(1),tri.getLength(2),tri.getLength(3));
        double angleA = tri.getAngle(tri.getLength(1),tri.getLength(2),tri.getLength(3));
        double angleB = tri.getAngle(tri.getLength(2),tri.getLength(3),tri.getLength(1));
        double angleC = tri.getAngle(tri.getLength(3),tri.getLength(1),tri.getLength(2));
        Graphics2D g2 = (Graphics2D) g;
       
        tri.drawtriangle(g2);

        g2.drawString("Area: " + area,400,485);
        g2.drawString("Perim:" + perim,400,495);
        g2.drawString("A1: " + Math.toDegrees(angleA),400,455);
        g2.drawString("A2: " + Math.toDegrees(angleB),400,465);
        g2.drawString("A3: " + Math.toDegrees(angleC),400,475);
    }
    public void destroy()
    {}
}

Name: Anonymous 2007-10-09 21:50

You're sort of an idiot.

Name: Anonymous 2007-10-10 2:20

Keep using perl

and static variables

Name: Anonymous 2007-10-10 3:10

You are creating new x1, y1, x2, y2, x3, y3 variables in the scope of only the method start().

Try:

 x1 = JOptionPane.showInputDialog("Point 1 X?");


Rather than

String x1 = JOptionPane.showInputDialog("Point 1 X?");

Name: Anonymous 2007-10-10 9:10

>>3
Typical Java hater, doesn't know shit about programming.

Name: Anonymous 2009-03-06 8:40


The C compiler IHBT?

Name: test 2010-02-20 17:48

test1 <=> test2

Name: test 2010-02-20 17:49

Name: test 2010-02-20 17:50

Name: test 2010-02-20 17:50

Name: test 2010-02-20 17:50

Name: test 2010-02-20 17:52

Name: test 2010-02-20 17:54

Name: test 2010-02-20 17:55

[url]tettst[/url]

Name: test 2010-02-20 17:55

http://tettst
http://test

Name: test 2010-02-20 17:57

Name: test 2010-02-20 17:58

Name: test 2010-02-20 17:58

Name: test 2010-02-20 17:59

Name: test 2010-02-20 18:00

Name: test 2010-02-20 18:01

Name: test 2010-02-20 18:02

Name: test 2010-02-20 18:02

http://h<p://<>http://http:<>//h<<;;;"<<<<ttp://http://<><;

Name: test 2010-02-20 18:05

http://h<p://<>http://http:<>//h<<;;;"<<<<ttp://http://<><;
http://goo"gle.com

Name: test 2010-02-20 18:05

http://h<p://<>http://http:<>//h<<;;;"<<<<ttp://http://<><;
http://goo"gle.com

Name: test 2010-02-20 18:07

http://h<p://<>http://http:<>//h<<;;;"<<<<ttp://http://<><;
http://goo[a]"<><http://[/a]gle.com

Name: test 2010-02-20 18:07

http://h<p://<>http://http:<>//h<<;;;"<<<<ttp://http://<><;
http://goo"<><http://gle.com

Name: test 2010-02-20 18:10

Name: test 2010-02-20 18:12

http://h<p://<>http://http:<>//h<<;;;"<<<<ttp://http://<><;
http://goo[quote]"<><http://[/quote]gle.com

Name: test 2010-02-20 18:14

http://h<p://<>http://http:<>//h<<;;;"<<<<ttp://http://<><;
http://goo[quote]"<><http://gle.co"m

Name: test 2010-02-20 18:15

http://h<p://<>http://http:<>//h<<;;<<<<t;;;;;;;;";;;;tp://http://<><;
http://goo[quote]"<><http://gle.co"m

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List