Whats with setLocation()

how come the setLocation() method for JPanel does not change the location of a jbutton i hav added to the panel. i really need a method that changes the position of a jlabel in jpanel without resorting to setBounds method that requires me to set the size of the jlabel
[275 byte] By [prodigy111a] at [2007-10-2 18:20:42]
# 1
i thing u faces layout managers problem; use setLayout(null) of panel so that it allows components to be added where u wishes to put them in screen.
vidhi_dwivedia at 2007-7-13 19:41:15 > top of Java-index,Desktop,Core GUI APIs...
# 2

> how come the setLocation() method for JPanel does not change the location

> of a jbutton i hav added to the panel.

it is the job of the layoutManager to 'locate' the components, according to the

specified layout and considering the component's preferredSize. You can

locate the component anywhere if you set the layout to null, but this is a really bad idea.

> i really need a method that changes the position of a jlabel in jpanel without

> resorting to setBounds

if you learn what each layout manager does, you generally can nest several of

them to place a component just about anywhere you want

http://java.sun.com/docs/books/tutorial/uiswing/layout/index.html

http://java.sun.com/docs/books/tutorial/uiswing/layout/visual.html

http://java.sun.com/developer/onlineTraining/GUI/AWTLayoutMgr/shortcourse.html

http://mindprod.com/jgloss/layout.html

Michael_Dunna at 2007-7-13 19:41:15 > top of Java-index,Desktop,Core GUI APIs...