Solved

Spawing an applet in a window of a certain size.

Posted on 2004-08-17
12
327 Views
Last Modified: 2008-03-10
Hi there experts, well I am trying to popup a new Java applet that is in a webpage, but I would like to limit the browser window to be a specific size with no File menu, explorer bars, address bars or anything.  Just a generic browser window with my applet in it?  Is that possible from Java?  Right now I can call

         try
         {
            getAppletContext().showDocument(new URL(URL_ac),"HTML frame ID");
         }
         catch (MalformedURLException ex)
         {
         }

but that displays a full sized window with all the toolbars.  Thanks in advance.
0
Comment
Question by:kesea
12 Comments
 
LVL 92

Expert Comment

by:objects
ID: 11827657
you need to use javascript
0
 
LVL 92

Expert Comment

by:objects
ID: 11827712
eg.

window.open('page.html','popupPage','width=500,height=500,resizable=no,scrollbars=no,menubar=no,toolbar=no,directories=no,location=no,status=no')
0
 
LVL 7

Expert Comment

by:JugglerW
ID: 11827934
Change your page with the applet in:

<html>
...
<body onLoad="window.resizeTo(640,480)" >
    <applet width="100%" height="100%">
    ...
   </applet>
</body>

This resizes the window to 640 x 480
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 35

Expert Comment

by:girionis
ID: 11827953
I do not think you can do it from inside your applet. What you could do would be to follow objects' suggestion and add a few more code that it will make it look like your are only creating one window.

 try
         {
            getAppletContext().showDocument(new URL("myfile.html"),"HTML frame ID");
         }
         catch (MalformedURLException ex)
         {
         }

myfile.html

<html>
   <head>
   <script language="JavaScript">
   function showApplet()
   {
       appletWindow = window.open('page.html','popupPage','width=500,height=500,resizable=no,scrollbars=no,
                                  menubar=no,toolbar=no,directories=no,location=no,status=no');
       window.close();
   }
   </script>
   </head>
   <body onLoad="showApplet();">
   </body>
</html>

page.html

<html>
   <body>
      <applet.....>
   </body>
</html>

So you basically you load up an HTML file, from inside this file you popup another window with the properties you want and which have the applet and then you close the parent window.
0
 
LVL 92

Expert Comment

by:objects
ID: 11827974
try using showDocument to display:

URL_ac = "javascript:window.open('page.html','popupPage','width=500,height=500,resizable=no,scrollbars=no,menubar=no,toolbar=no,directories=no,location=no,status=no'";
0
 
LVL 35

Accepted Solution

by:
girionis earned 150 total points
ID: 11827993
0
 

Author Comment

by:kesea
ID: 11833569
Ok, I tried using the
URL_ac = "javascript:window.open('page.html','popupPage','width=500,height=500,resizable=no,scrollbars=no,menubar=no,toolbar=no,directories=no,location=no,status=no'";

But it didn't work.  Do I have to do something to enable Javascript?
0
 
LVL 35

Expert Comment

by:girionis
ID: 11833789
Look at the link I posted above. It shows you how you can call javascript from within an applet.
0
 
LVL 1

Assisted Solution

by:vishalbhando
vishalbhando earned 150 total points
ID: 11835653
Another way is to create an applet .. make a width of 0 and height of 0 .. so that it is hidden from your actual screen.

and from within this Applet class you can create an instance of a Frame and make it with the size 500x500.. Program all functionality within this frame class.
0
 
LVL 92

Assisted Solution

by:objects
objects earned 200 total points
ID: 11836424
> Do I have to do something to enable Javascript?

yes you need to add mayscript to your applet tag
0
 
LVL 92

Expert Comment

by:objects
ID: 11838013
0
 
LVL 35

Expert Comment

by:girionis
ID: 11838471
:)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

679 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