Size modifications

Hi,

I possess a code which displays a complicated window (with various buttons and so on).

Just as a start for learning Java, I would like to modify its size (width and length), thinking it would be a very simple matter.

Yet it wasn't

Some code extract is the following:

java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();

java.awt.Dimension dialogSize = getSize();

setSize(new java.awt.Dimension(100, 100));

By modifying the values 100 I do not get any size variation.

These lines lie in a certain class inside which an init method is called.

The init method begins with a strange header saying

"/** This method is called from within the constructor to

* initialize the form.

* WARNING: Do NOT modify this code. The content of this method is

* always regenerated by the FormEditor.

*/

"

Inside this method there are other size settings:

pack();

java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();

java.awt.Dimension dialogSize = getSize();

setSize(new java.awt.Dimension(230, 305));

setLocation((screenSize.width-230)/2,(screenSize.height-305)/2);

What is it all about? Is that the reason why I cannot modify the window?

What is the FormEditor? Is the code actually automatically re-written?

Sorry, maybe it is a stupid matter, but I cannot get out of it ..

Thanks in advance,

Stefano.

[1525 byte] By [arny64a] at [2007-11-26 12:54:15]
# 1

> I possess a code which displays a complicated window

> (with various buttons and so on).

> Just as a start for learning Java, I would like to

> modify its size (width and length), thinking it would

> be a very simple matter.

> Yet it wasn't

Yes it is a simple matter.

If you are using a drag and drop editor , there will be an option for changing the size of the window in the properties tab. If you really want to write the code then write it. You have not specified where you have put thecode for setting the size.

The init() method may be called in the constructor. So, initially the window will have the size specified in the init() method. If you want to change the size of the window , put the code after the init() method.

setSize(100,100);

(I guess you are extending a JFrame to create a window.)

haishaia at 2007-7-7 16:45:57 > top of Java-index,Java Essentials,New To Java...
# 2

I did put the code after the init() method but it did not work.

Look at the extract ...

.................

initComponents ();

//this pack code doesn't get called with null layout manager

pack ();

java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();

java.awt.Dimension dialogSize = getSize();

setSize(new java.awt.Dimension(236, 353));

setLocation((screenSize.width-236)/2,(screenSize.height-353)/2);

.............

arny64a at 2007-7-7 16:45:57 > top of Java-index,Java Essentials,New To Java...
# 3
Your code extract seems to be correct. Post your full code . Dont forget to use the code tag
haishaia at 2007-7-7 16:45:57 > top of Java-index,Java Essentials,New To Java...
# 4
I may not attach the whole code because it is proprietary.What about the specification saying that the code must not be modified?Is it really re-written?
arny64a at 2007-7-7 16:45:57 > top of Java-index,Java Essentials,New To Java...