Results 1 to 3 of 3
  1. #1
    Krooger is offline Member
    Join Date
    Nov 2008
    Posts
    43
    Rep Power
    0

    Question Full Screen Frame Resolution Problem

    Hello, I am working on a project where I use a full size undecorated frame for my GUI.
    My problem is that everything looks perfect on my laptop that I work on (I don't know the resolution because I'm at school) As I was testing cross platform issues I discovered that my GUI will mess up under certain resolutions.

    This is my Frame
    Java Code:
    Toolkit toolkit =  Toolkit.getDefaultToolkit ();
    Dimension screenDimension = toolkit.getScreenSize();
    tableFrame.setSize(screenDimension);
    tableFrame.setUndecorated(true);
    tableFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Within my frame I add various layers of Panels for different sections of the GUI, they are added either by:
    Java Code:
    leftPanel.setPreferredSize(new Dimension((int)(tableFrame.getWidth()*(infoBarSizePercent)), tableFrame.getHeight()));
    leftPanel.setSize(new Dimension((int)(tableFrame.getWidth()*(infoBarSizePercent)), tableFrame.getHeight()));
    mainPanel.add(leftPanel);
    Where the size of the Panel is directly related to the Frame size, OR
    Java Code:
    topPlayerDeckCount.setPreferredSize(new Dimension(topPlayerCardCount.getWidth(), (topPlayerCardCount.getHeight()/5)));
    topPlayerCardCount.add(topPlayerDeckCount);
    Where the size of the Panel is directly related to the size of another Panel.

    All Panels and the Frame have a FlowLayout set to have no spacing between objects

    When the panel does not span the entire section it is in it is either divided by a number that corresponds to how many panels will be added there (they will all be the same size) or it will be a percent of the total space available with slight compensation. An example would be the top half will be height*0.2 and the bottom half would be height*0.81.

    Okay so there are two problems: The first is that under certain resolutions everything is perfect where as under most others there are spaces between the panels as can be seen in the following example at 1280X1024:
    h???ttp://darkwater-mtg.googlecode.com/files/1280-1024-Example.png
    (remove the ???, it wont let me post links)

    I have just colored all the panels so you can see where they are.
    Note that on the Left side there is a section of small boxes that look somewhat like a rainbow, when using the resolution 1400-1050 (and other resolutions) There may also be spaces between panels but more importantly that group of rainbow boxes are not even present as can be seen in the following example:
    h???ttp://darkwater-mtg.googlecode.com/files/1400-1050-Example.png

    This problem is my main concern.

    The entire class can be found here if I have left something out:
    h???ttp://code.google.com/p/darkwater-mtg/source/browse/trunk/darkwater-mtg/src/mtgGUI/Table.java

    Any advice on why this is happening and how to fix it would be greatly appreciated.

  2. #2
    Krooger is offline Member
    Join Date
    Nov 2008
    Posts
    43
    Rep Power
    0

    Default

    Never Mind I solved it.

    The problem was that I was taking a variable size and using only a percent of it and casting that to an Int so in some(most) cases I lost precision leaving a small gap that was unaccounted for. As for the Rainbow area disappearing that was because that panel is set to use a Flow Layout and because of this lose of precision it would somtimes not have the room it wanted to put the rainbow frame right next to it so it tried to put it under it, where it was not visable and appeared as if it was just not drawing it.

    Anyways my solution was just to use the ceiling values whenever I used only a percent of a Height or Width. Hope that can help anyone else with similar problems.

    Still it seems as if my approach isnt the best...

    Anyone ever try to make a frame full screen and thought of a better way to have the panels inside resize according to resolution? Would love to know what you did.

  3. #3
    zweibieren is offline Senior Member
    Join Date
    Aug 2009
    Location
    Pittsburgh, PA
    Posts
    284
    Rep Power
    5

    Default

    In this sort of case I eventually am forced to resort to writing my own LayoutManager.
    It is actually quite easy. All the sizing arithmetic is done directly.
    No mickeymouse indirect negotiations with min/max/preferredSize.
    And if I want two cells to butt against each other, I do it:
    xOneOnTheRight = xOneOnTheLeft + widthOneOnTheLeft;
    y ditto ditto ditto

Similar Threads

  1. Screen Resolution Problems
    By RicKaufman in forum AWT / Swing
    Replies: 1
    Last Post: 10-04-2009, 06:07 PM
  2. Prob. with screen resolution and Frame size??
    By SANDY_INDIA in forum AWT / Swing
    Replies: 1
    Last Post: 08-16-2008, 12:51 PM
  3. Full screen test
    By Java Tip in forum java.awt
    Replies: 0
    Last Post: 06-23-2008, 11:24 PM
  4. how to set full screen dimensions
    By valery in forum New To Java
    Replies: 1
    Last Post: 08-03-2007, 06:08 PM
  5. Full screen
    By Jack in forum Advanced Java
    Replies: 2
    Last Post: 07-02-2007, 05:49 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
  •