Results 1 to 16 of 16
  1. #1
    Ami
    Ami is offline Member
    Join Date
    Feb 2012
    Posts
    26
    Rep Power
    0

    Default How do I make my GUI look the same on all screen resolutions?

    Hi

    I am trying to make a GUI in Java.
    It currently looks different on different screen resolutions.
    Please can you let me know how I can make the GUI such that it looks the same on all screen resolutions. (e.g. I would want the proportions of all the components (e.g. text areas) to stay the same on all screen resolutions).
    Please can you help ASAP,

    Thanks!

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,941
    Rep Power
    8

    Default Re: How do I make my GUI look the same on all screen resolutions?

    Not really sure what you mean, since the proportions of the components should already be the same. The size of your window (in pixels) doesn't change based on resolution, so none of the components should change either. The only thing that changes is how many pixels the screen displays, which can make the window appear to be larger or smaller (in centimeters, but not in pixels), but the proportions of the components should all be the same.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Ami
    Ami is offline Member
    Join Date
    Feb 2012
    Posts
    26
    Rep Power
    0

    Default Re: How do I make my GUI look the same on all screen resolutions?

    Thnaks for your reply,
    sorry if I was not clear enough,
    What I mean is that I want my GUI to look the same on all computers it is displayed on. I am currently using
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    setBounds(0,0,screenSize.width, screenSize.height);
    to make the main frame compatible with all screen sizes. But I'm not sure what to do about the text areas within the frame. I think I have to specify the size of the text areas, right? This is a problem because they might be too big for the main frame (if a small screen is used), or too small (with respect to the main frame (JFrame) if a big screen is used)

    I hope this is clearer?

    Thanks

  4. #4
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,941
    Rep Power
    8

    Default Re: How do I make my GUI look the same on all screen resolutions?

    In that case, are you sure you really want your window taking up the entire screen?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  5. #5
    Ami
    Ami is offline Member
    Join Date
    Feb 2012
    Posts
    26
    Rep Power
    0

    Default Re: How do I make my GUI look the same on all screen resolutions?

    the window should be quite big...
    Thanks

  6. #6
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,941
    Rep Power
    8

    Default Re: How do I make my GUI look the same on all screen resolutions?

    What layout are you using? What does your window look like?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  7. #7
    Ami
    Ami is offline Member
    Join Date
    Feb 2012
    Posts
    26
    Rep Power
    0

    Default Re: How do I make my GUI look the same on all screen resolutions?

    I'm using GridLayout for some JPanels and FlowLayout for others.
    my window has a few tabs. each tab has 1 or more expandable text areas and a button panel,

    Thanks

  8. #8
    Ami
    Ami is offline Member
    Join Date
    Feb 2012
    Posts
    26
    Rep Power
    0

    Default Re: How do I make my GUI look the same on all screen resolutions?

    I tried using the method which gets the screen size and calculating the sizes of the text areas relative to this value. I then casted these values to ints and passed the calculated values as parameters to the
    JTextArea textArea = new JTextArea(int, int)
    method. But this didn't work, any thoughts? thanks

  9. #9
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: How do I make my GUI look the same on all screen resolutions?

    Myself, I just try to use layout managers intelligently, let the components find their own preferred size, and let the GUI size itself based on this. In other words let the layout managers do all the heavy lifting for you.

  10. #10
    Ami
    Ami is offline Member
    Join Date
    Feb 2012
    Posts
    26
    Rep Power
    0

    Default Re: How do I make my GUI look the same on all screen resolutions?

    thanks for your reply,
    so do you mean I shouldn't specify a size for the text areas?

  11. #11
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: How do I make my GUI look the same on all screen resolutions?

    Quote Originally Posted by Ami View Post
    thanks for your reply,
    so do you mean I shouldn't specify a size for the text areas?
    I avoid specifying the size, but if we're taking about a JTextArea, I do often specify the number of rows and columns that I want shown.

  12. #12
    Ami
    Ami is offline Member
    Join Date
    Feb 2012
    Posts
    26
    Rep Power
    0

    Default Re: How do I make my GUI look the same on all screen resolutions?

    thanks,
    but that still won't be screen size independent, do you understand what I mean?

  13. #13
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: How do I make my GUI look the same on all screen resolutions?

    Yes, but mostly I don't care that my applications look exactly alike on different screen resolutions and on different platforms. I just care that they look good whenever and wherever run.

  14. #14
    Ami
    Ami is offline Member
    Join Date
    Feb 2012
    Posts
    26
    Rep Power
    0

    Default Re: How do I make my GUI look the same on all screen resolutions?

    I understand what you mean, but I meant that in order for them to look good on different platforms, things have to be kept the same (so you don't get unpredictable layouts).


    I have another 2 questions but I don't know if I should put them in separate threads:

    1. How do I make a progress bar/ progress monitor work? how do I connect it to a task and make it behave accordingly?
    2.How do I set focus to a particular tab (for example, when a certain button is pressed, focus should be given to a particular tab)

    thanks

  15. #15
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: How do I make my GUI look the same on all screen resolutions?

    Quote Originally Posted by Ami View Post
    I understand what you mean, but I meant that in order for them to look good on different platforms, things have to be kept the same (so you don't get unpredictable layouts).
    Exactly -- and that's what the layout managers do for you if used correctly! I fear you're making things too difficult for yourself. Perhaps you might want to post a picture of your GUI as you want it, as you see it, and a small compilable runnable program that shows the GUI but without any of its functionality, an SSCCE.

    I have another 2 questions but I don't know if I should put them in separate threads:

    1. How do I make a progress bar/ progress monitor work? how do I connect it to a task and make it behave accordingly?
    2.How do I set focus to a particular tab (for example, when a certain button is pressed, focus should be given to a particular tab)

    thanks
    Since these are unrelated to the original question I recommend that they be asked in a new question.

  16. #16
    Ami
    Ami is offline Member
    Join Date
    Feb 2012
    Posts
    26
    Rep Power
    0

    Default Re: How do I make my GUI look the same on all screen resolutions?

    thanks,

Similar Threads

  1. How to make Jpanels and frame to fit every screen.
    By farhanz2009 in forum New To Java
    Replies: 3
    Last Post: 02-03-2012, 08:42 PM
  2. Replies: 8
    Last Post: 01-25-2012, 11:26 PM
  3. how to make screen locker in java??
    By javasabin in forum AWT / Swing
    Replies: 2
    Last Post: 12-27-2010, 08:50 PM
  4. Replies: 1
    Last Post: 01-25-2010, 01:21 PM
  5. How to make an icon in bottom-right of screen
    By hunterbdb in forum AWT / Swing
    Replies: 1
    Last Post: 08-13-2009, 08:28 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •