I wanted to create a java applet to draw a tree.
the java code that i have is
Now, if the user enters one superkingdom, the name of the superkingdom and a line is drawn. If the user enters two or more superkingdom, then both he line and names are over written.
Suppose if two superkingdons are entered, then two lines should be drawn in a ' V ' shape. all the lines sgould have a common starting point. I donot know how to do this. Kindly help me.
Thanks in advance...
Janani
the java code that i have is
Code:
import java.awt.*;
import javax.swing.*;
import java.applet.*;
public class Tree extends JApplet
{
String nsk,nnsk;
int nsk1,i;
public void init()
{
nsk=JOptionPane.showInputDialog("No. of superkingdoms");
nsk1=Integer.parseInt(nsk);
}
public void paint(Graphics g)
{
super.paint(g);
for(int i=0;i<nsk1;i++)
{
nnsk=JOptionPane.showInputDialog("Name of the superkingdom");
g.drawLine(50, 50, 50, 30);
g.drawString(nnsk,40,40);
}
}
}
Suppose if two superkingdons are entered, then two lines should be drawn in a ' V ' shape. all the lines sgould have a common starting point. I donot know how to do this. Kindly help me.
Thanks in advance...
Janani
Comment