Can java applet be as big as the browser window

  • Java
  • Thread starter Ulysees
  • Start date
  • Tags
    Java Window
In summary, there is a java applet available that visually demonstrates the electric field of a moving charge, although it may not be completely accurate. It is possible to resize the applet to fit the browser window, but it may be difficult to do so. Alternatively, the applet can be run in full-screen using Java's appletviewer program. It is also possible to dynamically write the applet's tag onto the page using Javascript to adjust the dimensions based on the window size.
  • #1
Ulysees
516
0
Here's a java applet that shows the electric field of a moving charge (it's actually incorrect, it only gives a rough idea how motion and acceleration affect electric field).

http://www.cco.caltech.edu/~phys1/java/phys1/MovingCharge/MovingCharge.html

Can a java applet like this be the same size as the browser window at all times?
 
Technology news on Phys.org
  • #2
It might be a little tricky to get resizing working properly, but yes, it should be possible. If you intend to run it full-screen, though, you might as well run it with Java's appletviewer program instead.

- Warren
 
  • #3
Try using 100% for the width and height on the applet's html tag.

It's also possible to dynamically write a Java applet's tag onto the page using Javascript. So you can obtain the window dimensions in javascript, and then write the applet's tag with the appropriate width/height (you'd need to update the dimensions on page resize, using onresize) - not ideal but it's an option.
 
Last edited:

Related to Can java applet be as big as the browser window

1. Can a Java applet be as big as the browser window?

Yes, a Java applet can be as big as the browser window. This can be achieved by setting the applet's width and height attributes to 100% in the HTML code.

2. How can I make my Java applet fill the entire browser window?

To make a Java applet fill the entire browser window, you can set the applet's width and height attributes to 100% in the HTML code. This will allow the applet to adjust its size according to the size of the browser window.

3. Is it possible to make a Java applet resize with the browser window?

Yes, it is possible to make a Java applet resize with the browser window. This can be achieved by using a combination of HTML and JavaScript to dynamically change the applet's size based on the size of the browser window.

4. Can I set a minimum and maximum size for my Java applet?

Yes, you can set a minimum and maximum size for your Java applet. This can be done by using the applet's minimum and maximum size attributes in the HTML code. This will ensure that the applet does not exceed or go below the specified size.

5. How can I center my Java applet in the browser window?

To center a Java applet in the browser window, you can use the align attribute in the HTML code and set its value to center. You can also use CSS to center the applet by setting its margin property to auto.

Similar threads

  • Programming and Computer Science
Replies
4
Views
4K
  • Programming and Computer Science
Replies
8
Views
11K
  • Programming and Computer Science
Replies
6
Views
2K
  • Programming and Computer Science
Replies
4
Views
3K
  • Programming and Computer Science
Replies
2
Views
2K
  • Introductory Physics Homework Help
Replies
1
Views
3K
Replies
6
Views
2K
  • Special and General Relativity
Replies
20
Views
1K
  • Other Physics Topics
Replies
34
Views
52K
Replies
0
Views
422
Back
Top