pulupul
asked on
Make an applet fill the browser window
I have an applet, and I want it to fill all the browser window. To do this, I have this HTML, which works fine (note the 100%):
<applet
width = "100%"
height = "100%"
codebase = "."
code = "servidor.AppletWrapper.cl ass"
archive = "servidor.jar"
name = "TestApplet"
>
But, although the applet area of the web page fills the browser window, the actual window inside it, my app's window, does not fill all the area, and I don't know why.
The only thing my applet class does is to crate an instance of a JPanel derived class and add it to itself. This is done in the constructor of the applet:
MyPanel panel = new MyPanel();
public AppletWrapper()
{
add(panel);
}
The JPanel derived class contains all the controls, and has BorderLayout.
If you need more info please ask.
<applet
width = "100%"
height = "100%"
codebase = "."
code = "servidor.AppletWrapper.cl
archive = "servidor.jar"
name = "TestApplet"
>
But, although the applet area of the web page fills the browser window, the actual window inside it, my app's window, does not fill all the area, and I don't know why.
The only thing my applet class does is to crate an instance of a JPanel derived class and add it to itself. This is done in the constructor of the applet:
MyPanel panel = new MyPanel();
public AppletWrapper()
{
add(panel);
}
The JPanel derived class contains all the controls, and has BorderLayout.
If you need more info please ask.
ASKER
Thanks for the answer, but I'm starting to suspect that the problem has nothing to do with applets or browsers, because I have created an application wrapper for the applet (in order to run it standalone) and I have the same problem, when I maximize the window, the JPanel doesn't fill all of it.
ASKER
Forget it, I solved it by using a BorderLayout
try something like this:
MyPanel panel = new MyPanel();
public AppletWrapper implements ComponentListener()
{
add(panel);
addComponentListener(this) ;
}
public void componentResized(Component Event e){
panel.resize(this.getWidth (),this.ge tHeight()) ;
}
...leave other methods empty
MyPanel panel = new MyPanel();
public AppletWrapper implements ComponentListener()
{
add(panel);
addComponentListener(this)
}
public void componentResized(Component
panel.resize(this.getWidth
}
...leave other methods empty
ok :)
ASKER
It was not an applet or browser issue, as I had first suspected. I solved it by using a BorderLayout layout manager in the JPanel, and putting everything in the center of it. Thanks for your time.
do proceed...no problem
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://www.javaworld.com/javaworld/javatips/jw-javatip80.html
Javascript plays important part here.