Results 1 to 9 of 9
  1. #1
    krimen_sp is offline Member
    Join Date
    Dec 2010
    Posts
    6
    Rep Power
    0

    Default The dialog initiates with height=0 and width=0

    Hello everyone!

    I'm developing some software for my final degree (i'm not an informatic...)

    well the thing is that I am continuing the software of another guy, and I found the connect dialog quite unusable, thats why I deleted it and started another with the same name and basic functions from scratch (maybe a bad idea...)

    the thing is that the main GUI calls the class "ShowConnectDialog" which is supposed to call the dialog panel "ConnectDialog"

    THE PROBLEM: the ConnectDialog starts ok, but with no dimensions (width=0 and height=0) and i have to resize it manually...by now


    the ShowConnectDialog class:

    public class ShowConnectDialog extends Command
    {
    private static final String name = "show connect dialog";

    private JFrame parent;

    public ShowConnectDialog(JFrame parentFrame)
    {
    super(name);
    parent = parentFrame;
    }

    public void execute()
    {
    new ConnectDialog(parent, ClientApp.getIP(), ClientApp.getPort()).setVisible(true);
    }

    }


    Thanks in advance ;)

    PS: I use Netbeans

  2. #2
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

    Default

    Try setting component.setPreferredSize()?

  3. #3
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,874
    Rep Power
    8

    Default

    You don't really show us enough of the code to tell you what's going on. I recommend you provide an SSCCE that demonstrates what you're doing.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  4. #4
    krimen_sp is offline Member
    Join Date
    Dec 2010
    Posts
    6
    Rep Power
    0

    Default

    Well I don't know if to put [SOLVED] because I actually solved it
    but I don't like it too much...

    I put:

    setSize(190,300);

    in the ConnectDialog constructor, because the size on start was (0,0) ...
    why was it (0,0)? by now thats a mystery to me.

    @quad64bit: no the setPreferredSize() didn't work.
    @KevinWorkman: As I design the form non programatically, I don't think more code will illustrate the problem, I think it is one of those shits related to some Jform property or something...



    thanks anyway ;)
    Last edited by krimen_sp; 01-24-2011 at 07:11 PM.

  5. #5
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,874
    Rep Power
    8

    Default

    Why don't you like that? And why would you not mark it solved if it has been solved? Otherwise, people will continue reading this, which is a waste of time if you aren't looking for a solution.

    But again, we don't know what you're doing, so we can't really comment on what's happening. For example, what kind of layout are you using? How are you displaying the dialog?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  6. #6
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

    Default

    After you called setPreferredSize(), did you call pack() on the outer component?

  7. #7
    krimen_sp is offline Member
    Join Date
    Dec 2010
    Posts
    6
    Rep Power
    0

    Default

    If you look at my first intervention, you'll find how do I display the dialog, to sum up i do:

    I have a main GUI with a button called CONNECT
    when I press CONNECT, the button calls ShowConnectDialog.execute()
    then ShowConnectDialog.execute() defines a new ConnectDialog

    this new ConnectDialog should have the default dimensions without me having to specify them again in the constructor of ConnectDialog, again doing so solves the problem.

    but why do I have to specify the dimensions again, if I don't do it in any other JPanel, and this JPanel was created from scratch, like the others?

    This solution is just papering over the cracks it does not solve the main problem underlying.

    PS: the layout was BorderLayout, and no, no other layout solved the problem.

  8. #8
    krimen_sp is offline Member
    Join Date
    Dec 2010
    Posts
    6
    Rep Power
    0

    Default

    @quad64bit: mmm I'll try that...

  9. #9
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,874
    Rep Power
    8

    Default

    Have you tried calling pack() as was suggested?

    Edit- Nevermind, I didn't see your most recent post.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Setting text width and height in PDFBox
    By svenskmand in forum Advanced Java
    Replies: 0
    Last Post: 12-21-2010, 12:23 AM
  2. Width (-1) and height (-1) cannot be <= 0
    By LovJava in forum AWT / Swing
    Replies: 5
    Last Post: 04-24-2010, 12:16 AM
  3. I want set HEIGHT, WIDTH for Button
    By manhtungtnk28@gmail.com in forum AWT / Swing
    Replies: 3
    Last Post: 11-16-2009, 07:26 AM
  4. Using setBounds (x.y,width,height) constructor
    By hitmen in forum AWT / Swing
    Replies: 3
    Last Post: 03-06-2009, 12:12 PM
  5. Get Image Height and Width
    By neeraj.singh in forum AWT / Swing
    Replies: 10
    Last Post: 02-18-2009, 01:09 PM

Tags for this Thread

Posting Permissions

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