Forum Stats

  • 3,722,440 Users
  • 2,244,312 Discussions
  • 7,849,837 Comments

Discussions

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

AWT GUI frames differ widely in size between PC screen sizes

Java Neophyte
Java Neophyte Member Posts: 7

I just finished a Java AWT class at the local college where the professor stayed away from the GUI frame layout code. As a student I went with his assignments and didn't give this another thought. I then wrote a small app that uses Java GUI and it works great on one PC (24" screen)  but on a smaller screened PC (14")  the frames are very small, too small. I thought that defining GUI frames and their components in pixels would take care of this but apparently not. Here is a small snippet of a frame def:

// FRAME components

    

  this.setSize(800,400);                   // <-- Frame size

  this.setLayout(null);

  this.setVisible(true);

  this.setTitle("GPMain");

  this.setBackground(Color.LIGHT_GRAY);

Is there a straightforward way to port apps over to other PC's whose screens are much smaller (24" down to 14") and have the frames compensate for the difference in screen size? The smaller screen's frames are way to small to be useful.

Many thanks from a newbie...

Answers

  • morgalr
    morgalr Member Posts: 457
    edited January 2019

    In the Toolkit API there is a call, getScreenResolution, which returns an integer value representing the dots per inch of your monitor; this may be applicable to your needs.

    please note: Toolkit tk=Toolkit.getDefaultToolkit() with get the specifics of the Toolkit object in effect during your session.

Sign In or Register to comment.