Problem to automatically adjust JDialog size

Hello all,

i have a form (JDialog) which consist of some jlabels and jtextfields.

There is a JLable on the top of the JDialog - which will be used to show hints or errors.

The user fill the form and press save.

If the validation was not succeeded, the JLable on the top shows text.

jlblText.setText("<html><body>Error. Please do this and that. </body></html>")

view.pack();

This text can have different length, so I put it in html tags for wrapping.

The problem is: top JLable changes its height so, that all buttons and some text fields below go down and are invisible. JDialog doesn't adjust it's size, after the height of the lable was changed.

The following code shows the same height of the jlable as it was before. No matter, whether I input 20 lines of text or 2 words.

System.out.println("height = "+view.jlblText().getHeight());

If I knew the real heigh of the jlable, I could adjust the size of the view.

I don't know, why JDialog doesn't adjust it itself, if the height of the lable was changed.

JScrollPane could solve my problem. But it can't be used in this case.

Thanks in advance.

[1255 byte] By [flexeda] at [2007-11-27 10:36:30]
# 1

Three suggestions:

1) create a SSCCE so we can see your relevant code and play with it. Look here for more info on this:

http://homepage1.nifty.com/algafield/sscce.html

2) Repost this in the Swing forum. You've a better chance of getting good swing help there.

3) Search through these forums, especially the Swing forum. This problem pops up at least once a week.

Good luck!

Message was edited by:

petes1234

petes1234a at 2007-7-28 18:41:40 > top of Java-index,Java Essentials,Java Programming...
# 2

Note to all: The OP has reposted in the Swing forum at my request. The new post can be found here:

http://forum.java.sun.com/thread.jspa?messageID=9768116

petes1234a at 2007-7-28 18:41:40 > top of Java-index,Java Essentials,Java Programming...