Solved

Width and height of java applet

Posted on 2007-11-29
5
1,456 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
Comment Utility
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
Comment Utility
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
Comment Utility
you can use javascript to resize the applet
0
 
LVL 92

Expert Comment

by:objects
Comment Utility
0
 
LVL 5

Expert Comment

by:ebertk
Comment Utility
Objects - assume!  Had no idea.  Links were great.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

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 is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
The viewer will learn how to implement Singleton Design Pattern in Java.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now