Solved

Spawing an applet in a window of a certain size.

Posted on 2004-08-17
12
306 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Unable to start eclipse ? 17 128
eclipse formatting 6 70
Groovy:unable to resolve class error 2 66
map related example 6 30
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…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
The viewer will learn how to implement Singleton Design Pattern in Java.
This video teaches viewers about errors in exception handling.

919 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

14 Experts available now in Live!

Get 1:1 Help Now