Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: How to get screen size in Applet

  1. #1
    Junior Member
    Join Date
    Oct 2010
    Dhaka, Bangladesh
    Thanked 0 Times in 0 Posts

    Post How to get screen size in Applet

    Can anyone find me the way of getting screen size and make the Applet view full screened. I supposed to say that, I want to make a applet which will be used in a web page and the applet will be screen sized of user machine.
    If you have any question, great or stupid suggestion, feel free to ask me here or mail me and I'll probably feel free to ignore it. You can follow me on twitter or visit my homepage.

  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Thanked 833 Times in 772 Posts
    Blog Entries

    Default Re: How to get screen size in Applet

    An applet is embedded within a web browser, and thus by definition cannot be made screen size. If you actually mean screen size, use a Webstart app. If you mean browser size, this can change based upon what the user does so you may need to try to have your applet communicate with javascript.

  3. The Following User Says Thank You to copeg For This Useful Post:

    anm_brr (October 22nd, 2010)

  4. #3
    Join Date
    Aug 2011
    My Mood
    Thanked 4 Times in 4 Posts

    Default Re: How to get screen size in Applet

    Here is the code to make Applet's size always equals to browser size.

        <script type="text/javascript">
            window.onresize = doResize;
            function doResize() {
                if (navigator.appName == "Netscape") {
                    document.OptionsWindowApplet.width = window.innerWidth;
                    document.OptionsWindowApplet.height = window.innerHeight;
                if (navigator.appName.indexOf("Microsoft") != -1) {
                    document.OptionsWindowApplet.width = document.documentElement.clientWidth;
                    document.OptionsWindowApplet.height = document.documentElement.clientHeight;

    Where OptionsWindowApplet is your Applet name/id defined by <object /> tag or <applet /> tag.

    immutable objects
    Last edited by ha.minh.nam; December 4th, 2011 at 07:26 PM.

Similar Threads

  1. how to set my frame in the middle of the screen
    By chronoz13 in forum AWT / Java Swing
    Replies: 3
    Last Post: February 10th, 2012, 08:13 AM
  2. JTable is not fit to the screen width.
    By rajakumarjk in forum AWT / Java Swing
    Replies: 2
    Last Post: October 12th, 2010, 10:13 AM
  3. Limit File Size or Request Size
    By tarek.mostafa in forum Java Servlet
    Replies: 3
    Last Post: June 12th, 2010, 04:28 PM
  4. Limit File Size or Request Size
    By tarek.mostafa in forum JavaServer Pages: JSP & JSTL
    Replies: 3
    Last Post: June 11th, 2010, 07:21 AM
  5. clear screen.
    By chronoz13 in forum Java Theory & Questions
    Replies: 10
    Last Post: December 5th, 2009, 07:27 AM

Tags for this Thread