Painting images in a Frame created by an applet
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Michael_Patrick
Posted On:   Friday, April 5, 2002 01:12 PM

Here's a short, terse version, I somehow lost the pretty version (apparently, Hal wouldn't let me do it --forum error message) I want to draw images in a Frame that is opened by an Applet. I'm overriding a label's paint() method to try to do this, but it's giving me access errors in the console. Exception occurred during event dispatching: java.security.AccessControlException: access denied (java.net.SocketPermission www-personal.engin.umich.edu resolve) at java.security.AccessControlContext.checkPermission(AccessControlContext.java:272) at java.security.AccessController.checkPermission(AccessController.java:399) at java.lang.SecurityManager.checkPermission(SecurityManager.java:5   More>>

Here's a short, terse version, I somehow lost the pretty version (apparently, Hal wouldn't let me do it --forum error message)


I want to draw images in a Frame that is opened by an Applet. I'm overriding a label's paint() method to try to do this, but it's giving me access errors in the console.


			
Exception occurred during event dispatching:
java.security.AccessControlException: access denied (java.net.SocketPermission www-personal.engin.umich.edu resolve)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:272)
at java.security.AccessController.checkPermission(AccessController.java:399)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:545)
at java.lang.SecurityManager.checkConnect(SecurityManager.java:1042)
at sun.awt.SunToolkit.getImageFromHash(SunToolkit.java:241)
at sun.awt.SunToolkit.getImage(SunToolkit.java:284)
at BaseConverterApplet$2.paint(BaseConverterApplet.java:172)
at sun.awt.RepaintArea.paint(RepaintArea.java:298)
at sun.awt.motif.MComponentPeer.handleEvent(MComponentPeer.java:349)
at java.awt.Component.dispatchEventImpl(Component.java:2663)
at java.awt.Component.dispatchEvent(Component.java:2497)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:339)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:131)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:98)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:85)


The Frame is declared as follows:


			
public class BaseConverterApplet extends Frame implements ActionListener, ItemListener
{
.
.
.
Label filler = new Label(" ") {
public void paint(Graphics g){
try {
Image smile = Toolkit.getDefaultToolkit().getImage(new URL("http://www-personal.engin.umich.edu/~mjpatric/285/smile.gif"));
g.drawImage(smile,0,0,this);}
catch ( MalformedURLException e ) {}
}
};
.
.
.
}


Two last points: it must be 100% AWT; it can't use swing (it's a school project) and to see all the source code (in case you're curious or it will help) please visit:


http://www-personal.engin.umich.edu/~mjpatric/285/


The files you'll be interested in are bca.html, AppletButton.java, & BaseConverterApplet.java (I know its stupid code, but hey, I'm just learning. ;) )

   <<Less

Re: Painting images in a Frame created by an applet

Posted By:   Michael_Patrick  
Posted On:   Friday, April 5, 2002 05:27 PM

Okay, I understand now that this is a stupid idea when I could simply pass the Images in as parameters in the constructors.
About | Sitemap | Contact