Topic
No replies
Dineshkumar_for_u
Dineshkumar_for_u
1 Post
ACCEPTED ANSWER

Pinned topic Applet without paint

‏2012-09-14T11:51:27Z |
Hi, for an applet program i've not used paint method. but i've added components based on events and to view the modified contents it needs resizing my applet. so it gets updated. but without resizing how can i view my modified contents (like repaint if i've used paint method).

here's a sample piece of code that explains the problem.




import java.awt.Button; 

import java.awt.FlowLayout; 

import java.awt.Label; 

import java.awt.event.ActionEvent; 

import java.awt.event.ActionListener; 

import javax.swing.JApplet;   

public 

class Appl 

extends JApplet 

implements ActionListener
{   Button b = 

new Button(); 

public 

void init() 
{ setLayout(

new FlowLayout()); setSize(300,300); setVisible(

true); add(b); b.addActionListener(

this); 
}       

public 

void actionPerformed(ActionEvent e) 
{ 

if(e.getSource()==b) 
{ add(

new Label(
"Button clicked")); repaint(); 
} 
} 
}