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.


>> REGISTER NOW TO START POSTING


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

Results 1 to 5 of 5

Thread: Adjust screen size and button arrangement for any computer screen

  1. #1
    Junior Member
    Join Date
    Jan 2014
    Posts
    11
    Thanks
    2
    Thanked 1 Time in 1 Post

    Default Adjust screen size and button arrangement for any computer screen

    Hello,
    I have a java GUI code that opens a frame having 5 buttons arranged at the 4 corners and center of the screen. I have manually entered the size of the frame and the position of the buttons, however when i use it on different computers the entire frame is not visible on smaller screens. How would i be able to program this code to automatically adjust to the screen size and place the buttons (of fixed size) at the corners and center of the screen for any system?


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Adjust screen size and button arrangement for any computer screen

    What did you find when you Googled "java screen size" or similar?

  3. #3
    Junior Member
    Join Date
    Jan 2014
    Posts
    11
    Thanks
    2
    Thanked 1 Time in 1 Post

    Default Re: Adjust screen size and button arrangement for any computer screen

    Quote Originally Posted by GregBrannon View Post
    What did you find when you Googled "java screen size" or similar?
    I had found this code to maximize frame to screen size
    frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
    frame.setVisible(true);

    i could not get information regarding if the button positions would be affected by this process on different screen sizes. I need the positions to be at the corners and centers irrespective of screen size.

  4. #4
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Adjust screen size and button arrangement for any computer screen

    Okay, so what you found was not helpful, but there should have been results from that search that showed you how to obtain the size of the screen (or the resolution) of the host computer on which your application is running. Knowing that, you can programmatically adjust the size of your application's main window or frame and the location(s) of the components placed in it.

    Try the search again and look for the results that will allow your application to determine the size of the host computer's screen.

  5. #5
    Junior Member
    Join Date
    Jan 2014
    Posts
    11
    Thanks
    2
    Thanked 1 Time in 1 Post

    Default Re: Adjust screen size and button arrangement for any computer screen

    Quote Originally Posted by GregBrannon View Post
    Okay, so what you found was not helpful, but there should have been results from that search that showed you how to obtain the size of the screen (or the resolution) of the host computer on which your application is running. Knowing that, you can programmatically adjust the size of your application's main window or frame and the location(s) of the components placed in it.

    Try the search again and look for the results that will allow your application to determine the size of the host computer's screen.
    Thank you...i searched in detail and finally found one function
    Toolkit toolkit = Toolkit.getDefaultToolkit ();
    Dimension dim = toolkit.getScreenSize();
    i could obtain screen dimensions and manipulate them to position the buttons

Similar Threads

  1. button doesnt shows up on the screen
    By poldz123 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 20th, 2013, 07:35 AM
  2. Trying to add a button to my Title Screen...
    By Jnk1296 in forum AWT / Java Swing
    Replies: 5
    Last Post: January 25th, 2013, 11:51 AM
  3. Jpanel preffered size exceed the nactual screen size
    By manish.ctae@gmail.com in forum AWT / Java Swing
    Replies: 2
    Last Post: October 31st, 2012, 01:29 AM
  4. Replies: 9
    Last Post: December 31st, 2011, 01:22 AM
  5. How to get screen size in Applet
    By anm_brr in forum Java Applets
    Replies: 2
    Last Post: August 10th, 2011, 09:21 PM