• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Add Component (Label ...) dynamically at runtime to an applet ?

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
how to add a Component (Label ...) dynamically at runtime to an applet ? I've tried various possibilities, but I haven't had any success.
Thanks, Felicitas
 
Ranch Hand
Posts: 396
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi felicitas,
after adding the component at run time u need to invalidate() and validate() the applet.
here is a working code which u can run and see
------------------------------------------------------------
java file
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class DynApplet extends Applet
{
Button b = new Button("Label Generater");
public DynApplet()
{
add(b);
b.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae)
{
DynApplet.this.add(new Label("Nascent Label"));
System.out.println("label Added");
DynApplet.this.invalidate();
DynApplet.this.validate();

}
});
}

}
html file
html
applet
code = DynApplet.class
width = 300
height = 200
applet
/html
------------------------------------------------------------
regards
deekasha
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic