how do Java handle JFrames from applet..


J

JTapio

Hei!

i have a simple applet..
my applet only creates one JFrame with Canvas on nothing else..

my problem is that my applet and JFrame both work just fine on my netbeans
IDE applet viewer..
but, when i browse my homesite with opera9 i end up resulting 'applet
crashed'..

so my question is, is there somekind of a rule for opening JFrames from
webpages or why my applet crashes..

:: my 'very simple' code ::

import java.applet.Applet;
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Toolkit;
import javax.swing.JFrame;


public class NewApplet extends Applet
{
JFrame frame;

public void init()
{
frame.setDefaultLookAndFeelDecorated(true);
frame = new JFrame("my very first frame..");

BSMCanvas region = new BSMCanvas();

frame.add(region);
frame.setSize(Toolkit.getDefaultToolkit().getScreenSize());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);

}

public void stop ()
{}
public void destroy ()
{}

public void run ()
{

}
}

class BSMCanvas extends Canvas
{
public BSMCanvas ()
{
setSize(800, 800);
setBackground(Color.blue);
}

public void paint(Graphics g){
update(g);
}

public void update(Graphics g){
Graphics2D g2 = (Graphics2D)g;
}
}


Yours : JariTapio
Homepage : www.EuroJari.net
EMail : (e-mail address removed)
 
Ad

Advertisements

A

Andrew Thompson

JTapio wrote:
.....
i have a simple applet..
my applet only creates one JFrame with Canvas on nothing else..

You seem to have an obsession with canvas's, despite
that an AWT canvas does not sit well in a Swing JFrame
(go on - try some menus - I dare you)
my problem is that my applet and JFrame both work just fine on my netbeans
IDE applet viewer..
but, when i browse my homesite with opera9 i end up resulting 'applet
crashed'..

Please be specific and clear with all errors and exceptions.
Copy/paste at least the first few lines of them.
so my question is, is there somekind of a rule for opening JFrames from
webpages or why my applet crashes..

Rule 1 wold be 'read and understand the exception
in the console'

java.security.AccessControlException: access denied
(java.lang.RuntimePermission exitVM)
......
at NewApplet.init(NewApplet.java:26)

Andrew T.
 

Top