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.

Page 2 of 2 FirstFirst 12
Results 26 to 33 of 33

Thread: Newbish Question...(s)

  1. #26
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Newbish Question...(s)

    You're welcome. Keep on coding!

  2. #27
    Member
    Join Date
    Jan 2011
    Posts
    78
    My Mood
    Confused
    Thanks
    23
    Thanked 1 Time in 1 Post

    Default Re: Newbish Question...(s)

    Do you know of a way to make these center in the screen when they are first loaded?

  3. #28
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Newbish Question...(s)

    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.

  4. #29
    Member
    Join Date
    Jan 2011
    Posts
    78
    My Mood
    Confused
    Thanks
    23
    Thanked 1 Time in 1 Post

    Default Re: Newbish Question...(s)

    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?

  5. #30
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Newbish Question...(s)

    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

  6. #31
    Member
    Join Date
    Jan 2011
    Posts
    78
    My Mood
    Confused
    Thanks
    23
    Thanked 1 Time in 1 Post

    Default Re: Newbish Question...(s)

    I found it

    .setLocationRelativeTo(null);

    Makes it centered.

  7. #32
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Newbish Question...(s)

    That looks like it. The API doc is where you find all sorts of stuff. Read on.

  8. #33
    Forum old-timer
    Join Date
    Nov 2008
    Location
    Faversham, Kent, UK
    Posts
    472
    My Mood
    Mellow
    Thanks
    4
    Thanked 58 Times in 54 Posts

    Default Re: Newbish Question...(s)

    @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.

Page 2 of 2 FirstFirst 12