Drawing Lines In An Applet

Hello....

I have this code below which I want to run in an applet....however when i run the applet..the line won't draw after i enter the variables...any idea why?

thx

hwrd

import java.*;

import javax.swing.*;

import java.awt.*;

publicclass LineDrawextends JApplet{

String xonestring, yonestring,xtwostring,ytwostring;

int xone, yone, xtwo, ytwo;

publicstaticvoid main(String args [])

{

LineDraw ld =new LineDraw();

//ld.VariablesEnter();

}

publicvoid paint(Graphics g)

{

xonestring = JOptionPane.showInputDialog(null,"Please enter x1");

yonestring = JOptionPane.showInputDialog(null,"Please enter y2");

xtwostring = JOptionPane.showInputDialog(null,"Please enter x2");

ytwostring = JOptionPane.showInputDialog(null,"Please enter y2");

xone = (Integer.parseInt(xonestring)*100);

yone = (Integer.parseInt(yonestring)*100);

xtwo = (Integer.parseInt(xtwostring)*100);

ytwo = (Integer.parseInt(ytwostring)*100);

super.paint(g);

g.drawLine(xone,yone,xtwo,ytwo);

FinalJava fj =new FinalJava();

//goes back to my original program

fj.Choice();

}

}

[2034 byte] By [hwrdrpknsa] at [2007-11-26 12:22:12]
# 1

Wow. You really have no concept of how painting works in AWT/Swing.

http://java.sun.com/products/jfc/tsc/articles/painting/

You should absolutely not be doing things like presenting dialogs from the paint method. The paint method will be called every time a component needs to paint itself. In your case chances are the only thing that should be in your paint method is the drawing of the line. Entering variables, showing dialogs, etc. should be elsewhere.

kablaira at 2007-7-7 15:15:04 > top of Java-index,Archived Forums,Socket Programming...
# 2

well the ronly reason i did that was because i didn't know how to call my void from the previous void i had.......i knew it had to be ld.paint(g) but i dindn't know how to define g and so i tried to do it the other way....but if anyone wants to tell me how to define g then i can move the panes into another void.

hwrdrpknsa at 2007-7-7 15:15:04 > top of Java-index,Archived Forums,Socket Programming...