Solved

Width and height of java applet

Posted on 2007-11-29
5
1,458 Views
Last Modified: 2012-06-27
Hi,

When I embed a java applet into a webpage, I use:

    <applet code=whatever.class width=402 height=402>

Inside the java applet class, I can get the bounds by doing:

    bounds().width;
    bounds().height;

Is there anyway to override the size of the applet as rendered in the html page? I mean if in my applet class, I want my applet to really be 500 x 500, can I do something like:

    bounds().setNewWidth(500);

or is it just static after you've loaded the page and you're stuck?

Thanks
0
Comment
Question by:DJ_AM_Juicebox
  • 2
  • 2
5 Comments
 
LVL 8

Expert Comment

by:malfunction84
ID: 20375940
The browser determines the size of embedded elements, including applets.  If you did want to change the size, you'd have to do it external to the applet, in the HTML itself.

I doubt very much that DHTML (Javascript, etc) would work, but if your HTML is generated by PHP, JSP, ASP, etc., it can be done by generating HTML with different height and width attributes for the applet element.
0
 
LVL 5

Accepted Solution

by:
ebertk earned 500 total points
ID: 20376783
Nope, you are stuck.  You can, however, create an additional panel inside the applet and change the size of that panel.  To the HTML page you would still have the same sized applet, but the applet itself could be drawn in the small space.

You can, in fact, use javascript to create the Java applet section of your HTML document and then use the javascript to control the size you with to appear.  The key to making this work is to make sure you use javascript to generate the entire applet tag and all of its parts.  If you try to use javascript to only change the height and width attributes it won't work.

Good luck!
0
 
LVL 92

Expert Comment

by:objects
ID: 20377887
you can use javascript to resize the applet
0
 
LVL 92

Expert Comment

by:objects
ID: 20377930
0
 
LVL 5

Expert Comment

by:ebertk
ID: 20379648
Objects - assume!  Had no idea.  Links were great.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question