Solved

Spawing an applet in a window of a certain size.

Posted on 2004-08-17
12
296 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
 
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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
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…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

707 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

16 Experts available now in Live!

Get 1:1 Help Now