• 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
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

adding Frame to Applet

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for taking time to read this
I am trying to add a frame to an Applet
see below
import java.applet.*;
import java.awt.*;
public class BioApplet extends Applet {
public void init() {
Frame f=new Frame("f");
f.setBackground(Color.yellow);
add(f);
}
public void paint(Graphics g) {}
}
compile error code
java.lang.IllegalArgumentException: adding a window to a container
at java.awt.Container.addImpl(Container.java:336)
at java.awt.Container.add(Container.java:228)
at BioApplet.init(BioApplet.java:10)
at sun.applet.AppletPanel.run(AppletPanel.java:344)
at java.lang.Thread.run(Thread.java:484)
 
Ranch Hand
Posts: 347
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Simcel,
I don't think you can add a frame to an applet. A frame is its own window, with title bar, icon, etc. What was the goal here? Perhaps we can find you a better way to achieve it. Please let us know.
Stephanie
[This message has been edited by Stephanie Grasson (edited March 30, 2001).]
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
try to put a button that opens a frame as a new container instead of creating a frame on applet..
 
Ranch Hand
Posts: 424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hava a look at http://www.math.utwente.nl/~gragert/Live_Math/TaylorError.html

There is a green button (an applet) wich launches (or destroys) a frame.
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Simcel,
You do not need to add the frame to the applet... simply remove the call :

and replace it with the following to have your frame pop up when the applet is loaded :

As others have mentioned in this thread... it's a good idea to have some action on the users part control the opening of the frame... automatic pop up windows are annoying...
HTH,
-Nate
 
Peter Gragert
Ranch Hand
Posts: 424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have the same feeling as Nathan about 'automatic' popup windows. ;-)
 
I love a woman who dresses in stainless steel ... and carries tiny ads:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic