www.jpct.net

General => Feedback => Topic started by: FraX on November 12, 2003, 02:03:14 am

Title: Insets and finding titlebar width
Post by: FraX 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.
Title: Insets and finding titlebar width
Post by: EgonOlsen 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!