Author Topic: Insets and finding titlebar width  (Read 3353 times)

Offline FraX

  • byte
  • *
  • Posts: 1
    • View Profile
Insets and finding titlebar width
« on: November 12, 2003, 02:03:14 am »
I saw your "Help me" comment in the fps demo about finding the width of the title bar. I though I would help.

Code: [Select]

// SimpleInsets.java

import java.awt.*;
import java.awt.event.*;

class SimpleInsets {
public static void main(String args[]) {

// Basic AWT Frame Stuff
Frame wind = new Frame();

// Need to pack the frame to get the proper insets
wind.pack();

// Get insets for the frame
Insets is = wind.getInsets();

// is.top = Top border (title bar)
// is.bottom = Bottom border
// is.left = left border
// is.right = right border

System.out.println("Top Border: "  + is.top);
System.out.println("Bottom Border: "  + is.bottom);
System.out.println("Left Border: "  + is.left);
System.out.println("Right Border: "  + is.right);

// Gives you a nice frame with exactly 400x400 pixels of space.
wind.setSize((400 + is.left + is.right), (400 + is.top + is.bottom));

wind.show();
}
}


Hope that helps. jPCT looks pretty nice, and I'm considering making a game with it once I figure it out. Good job.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11771
    • View Profile
    • http://www.jpct.net
Insets and finding titlebar width
« Reply #1 on: November 12, 2003, 05:47:02 pm »
Thank you for that...i wasn't aware of this possibility and i'll add it to the next release.

Edit: Added!