You're welcome. Keep on coding!
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
You're welcome. Keep on coding!
Do you know of a way to make these center in the screen when they are first loaded?
There probably is a method to call that will do it.
The old way was to get the screensize and the size of the window and compute where the left corner should go and use setLocation.
I looked and I found CENTER_ALIGNMENT
here: JDialog (Java Platform SE 6)
well it says this anyway:
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
But I don't know where I could include them in my code?
I'm actually kind of thinking its not what I want. I'm guessing that this is for things actually inside the dialog box?
I think those refer to alignment of a component within a container. Not to the location of a window.
Try some and see what happens
I found it
.setLocationRelativeTo(null);
Makes it centered.
That looks like it. The API doc is where you find all sorts of stuff. Read on.
@Hallowed - I would recommend that you keep to the Java Naming conventions (class names start with uppercase letter, method and variable names start with a lowercase letter). That way, it is less confusing for people reading your code. It also helps to put a brief description of what a class does in front of the class declaration, and comment non-obvious code to clarify what is happening. That way, people reading your code have some idea what's going on.