Results 1 to 11 of 11

Thread: Extended state

  1. #1
    captain alge is offline Member
    Join Date
    Mar 2011
    Posts
    25
    Rep Power
    0

    Default Extended state

    Greetings!

    Just a quick question, I have a JFrame that I'm trying to start up maximised, but it won't. I've tried setting extended state to 4 (which I believe equals MAXIMIZED_BOTH) and setting it to MAXIMIZED_BOTH, but nothing happens.

    My main suspicion is that another property overrides extended state, are there any???

    cheers!

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,189
    Rep Power
    19

    Default

    To get better help sooner, post a SSCCE (Short, Self Contained, Compilable and Executable) example that demonstrates the problem.

    Use code tags to post codes -- [code]CODE[/code] will display as
    Java Code:
    CODE
    And in any case, don't use magic numbers. Use the class constants.

    db

  3. #3
    captain alge is offline Member
    Join Date
    Mar 2011
    Posts
    25
    Rep Power
    0

    Default

    Not really sure what you are looking for

    This is the code relevant to the issue:
    Java Code:
    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
                setTitle("myTitle");
                setBounds(new java.awt.Rectangle(200, 100, 0, 0));
                setExtendedState(MAXIMIZED_BOTH);
                setName("myName");
    any better?

    and by magic numbers are you referring to using '4' instead of 'MAXIMISED_BOTH'???

  4. #4
    ozzyman's Avatar
    ozzyman is offline Senior Member
    Join Date
    Mar 2011
    Location
    London, UK
    Posts
    797
    Blog Entries
    2
    Rep Power
    4

    Default

    Ok, the magic number thing is referring to this:

    MAXIMIZED_BOTH

    setExtendedState(java.awt.Frame.MAXIMIZED_BOTH);
    Last edited by ozzyman; 04-02-2011 at 07:03 PM.

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,189
    Rep Power
    19

    Default

    Quote Originally Posted by captain alge View Post
    Not really sure what you are looking for
    Too much reoule to go through the linked page, huh?

    Quote Originally Posted by captain alge View Post
    This is the code relevant to the issue:
    Obviously not.

    Quote Originally Posted by captain alge View Post
    and by magic numbers are you referring to using '4' instead of 'MAXIMISED_BOTH'???
    Yes.

    db

  6. #6
    ozzyman's Avatar
    ozzyman is offline Senior Member
    Join Date
    Mar 2011
    Location
    London, UK
    Posts
    797
    Blog Entries
    2
    Rep Power
    4

    Default

    Sorry, I couldn't think why MAXIMISED_BOTH would work without invoking Frame but obviously Frame has been imported already so the constant is there.

  7. #7
    captain alge is offline Member
    Join Date
    Mar 2011
    Posts
    25
    Rep Power
    0

    Default

    Quote Originally Posted by Darryl.Burke View Post
    Too much reoule to go through the linked page, huh?


    Obviously not.


    Yes.

    db
    I followed your link actually, but I have no intention of distributing any of my files, however small. I fail to see which part I should give you anyway, after all, I have no idea which part of the project is causing the issue, and in pruning the program down I may very well remove the issue without even realising it...

    All I'm asking is if anything could potentially overwrite the setExtendedState method, or conflict with it. I don't see why you're more interested in arguing rather than giving me an answer...

  8. #8
    ozzyman's Avatar
    ozzyman is offline Senior Member
    Join Date
    Mar 2011
    Location
    London, UK
    Posts
    797
    Blog Entries
    2
    Rep Power
    4

    Default

    actually there is Frame.pack().

    if pack() is invoked after maximising the Frame will go back to its preferred size.

  9. #9
    captain alge is offline Member
    Join Date
    Mar 2011
    Posts
    25
    Rep Power
    0

    Default

    Thank you ozzyman, I think you may have found my problem!

    I found that at the end of my generated script (I use an IDE) it finishes with pack();

    Now I just have to think up a fix, cheers!

  10. #10
    captain alge is offline Member
    Join Date
    Mar 2011
    Posts
    25
    Rep Power
    0

    Default

    Got It!

    For those using NetBeanse IDE, there is a property called Form Size Policy, under code. If you which to start the frame maximised, its value can not be set to Generate Pack()

    Cheers again for helping!

  11. #11
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,189
    Rep Power
    19

    Default

    I found that at the end of my generated script (I use an IDE) it finishes with pack();
    Which is why I said the code posted earlier was obviously not relevant to the issue.

    db

Similar Threads

  1. Only one extended JPanel showing up
    By TheGoodDoctor in forum AWT / Swing
    Replies: 7
    Last Post: 03-13-2011, 03:10 AM
  2. Replies: 2
    Last Post: 02-14-2011, 02:27 PM
  3. jdbc and extended ascii
    By hopfensp in forum JDBC
    Replies: 3
    Last Post: 11-24-2010, 07:17 AM
  4. extended essay Survey
    By FF764 in forum New To Java
    Replies: 0
    Last Post: 08-18-2009, 08:44 AM
  5. Survey for the extended essay
    By FF764 in forum Advanced Java
    Replies: 0
    Last Post: 08-17-2009, 02:02 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •