I 'm beginner of java.I typed following program that uses applet and awt components.As the button is clicked ,what is typed in textfield should be painted over the applet window.
This only happens when i minimize the applet window and again maximize it.can't it paint the contents of textfield into the applet as soon as button is clicked?
Any chang incode is reqd?
thanks.
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class ActionListener1 extends Applet implements ActionListener
{
Label l1;
Button b1;
TextField tf1;
String str;
public void init()
{
l1= new Label("Hello"
b1= new Button("Click"
tf1= new TextField(" ",20);
b1.addActionListener(this);
add(l1);
add(tf1);
add(b1);
}
public void actionPerformed(ActionEvent ae)
{
str=tf1.getText();
tf1.setText(" "
}
public void paint(Graphics g)
{
g.drawString(str,200,200);
}
}
---sap
This only happens when i minimize the applet window and again maximize it.can't it paint the contents of textfield into the applet as soon as button is clicked?
Any chang incode is reqd?
thanks.
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class ActionListener1 extends Applet implements ActionListener
{
Label l1;
Button b1;
TextField tf1;
String str;
public void init()
{
l1= new Label("Hello"
b1= new Button("Click"
tf1= new TextField(" ",20);
b1.addActionListener(this);
add(l1);
add(tf1);
add(b1);
}
public void actionPerformed(ActionEvent ae)
{
str=tf1.getText();
tf1.setText(" "
}
public void paint(Graphics g)
{
g.drawString(str,200,200);
}
}
---sap