I new to java's applet programming & there is a problem in my program
This is my program:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
/*<applet code=Rect height=600 width=800></applet>*/
public class Rect extends JApplet implements ActionListener
{
JLabel jl1,jl2,jl3,jl4;
JTextField jt1,jt2,jt3,jt4;
JButton jb;
int x1,x2,y1,y2;
public void init()
{
Container c=getContentPane();
c.setLayout(new FlowLayout());
jl1=new JLabel("x1 : ");
jl2=new JLabel("y1 : ");
jl3=new JLabel("x2 : ");
jl4=new JLabel("y2 : ");
jt1=new JTextField(5);
jt2=new JTextField(5);
jt3=new JTextField(5);
jt4=new JTextField(5);
jb=new JButton("Draw");
jb.addActionListener(this);
c.add(jl1);
c.add(jt1);
c.add(jl2);
c.add(jt2);
c.add(jl3);
c.add(jt3);
c.add(jl4);
c.add(jt4);
c.add(jb);
}
public void actionPerformed(ActionEvent ae)
{
String s=ae.getActionCommand();
x1=Integer.parseInt(jt1.getText());
y1=Integer.parseInt(jt2.getText());
x2=Integer.parseInt(jt3.getText());
y2=Integer.parseInt(jt4.getText());
repaint();
}
public void paint(Graphics g)
{
g.drawLine(x1,y1,x2,y2);
}
}
I have did everything perfect but it shows some imperfection by disappearing the labels, textfields & buttons
Is there anyone can help me with my problem?????