Solved

Width and height of java applet

Posted on 2007-11-29
5
1,465 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 5

Expert Comment

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

Featured Post

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

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

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Find out what you should include to make the best professional email signature for your organization.
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 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…

695 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