Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - FraX

Pages: [1]
1
Feedback / 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.

Pages: [1]