Problem resizing applet frame

K

Kevin Holmes

I can't seem to get this darn frame to resize (or setsize) when the applet
is launched. All I get is a little frame window which I can then maximize
and see my applet. I think I have tried ever possible combination of the
Frame methods. Could someone please lend a helping hand.

Here is my watered down code.

import java.awt.*;

public class test extends java.applet.Applet implements Runnable {
static volatile Image currentimg;
static volatile Graphics currentGraphics;
Thread runner;
Frame myframe;
static Dimension d;

public void start() {
if (runner == null) {
runner = new Thread(this);
runner.start();
}
}
public void stop() {
if (runner != null) {
runner.stop();
runner = null;
}
}

public void init() {
myframe = new Frame("Test Applet");
d = Toolkit.getDefaultToolkit().getScreenSize();
myframe.setSize(d.width, d.height);
myframe.add(this);
myframe.setVisible(true);
myframe.pack();
myframe.show();
currentGraphics = getGraphics();
paint(currentGraphics);
}

public void run() {
}

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

public void paint(Graphics g) {
g.drawString("hello world",10,20);
}
}
 
S

ScoobyCed

Kevin Holmes said:
I can't seem to get this darn frame to resize (or setsize) when the applet
is launched. All I get is a little frame window which I can then maximize
and see my applet. I think I have tried ever possible combination of the
Frame methods. Could someone please lend a helping hand.

The problem is not in the Java code, that's why you don't see it they way
you want. You have to precise the stuff in the HTML <applet> code and in the
code that open the browser windows.
For the first case, use the parameters width='' and height='', this will
tell the browser what size the applet is using within the web page.
For the second thing, you have to do something like:
window.open("applet.html","text","width=640,height=480");
check the javascript code for window.open() method.
or use the myWindow.resize(640,480); method on a window JS object.

Scooby-Ced
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top