Re: GUI....Controlling Control Buttons ....

From: Dirk Starke (dstarkeCUT_IT_at_starke-net.de)
Date: 02/28/05


Date: 28 Feb 2005 00:19:24 -0800

Hello Sameer,

> I have designed a frame which contains a TextArea ,TextField and a
> JButton.
> [...]
> When I start the JFrame instance it shows the Window but does not show
> any component, i have to strech it little bit to show all the
> components.
>
> To avoid this, I execute a pack() routine on the frame, but then
> all the components of the frame gets collected in one part of the
> frame.
> [...]
> How to avoid this so as to display a full window?

I guess you are setting the sizes of the Java components. I do not
prefer this way of GUI construction. May I advise you to set the
number of columns and rows your textarea/-field should be able to show
(see methods JTextArea.setColumns(int) and .setRows(int))?

You could use a BorderLayout to construct the main frame with the
textarea in the center part and a panel with the textfield and the
button in the southern part.

If you have setup the layout of the frame correctly you can call
pack() and your frame will be sized as desired (see
http://java.sun.com/docs/books/tutorial/uiswing/layout/index.html).

> Can I design a frame with Close button only i.e. without Minimize and
> Maximize button? Is it possible to control display of Control buttons
> in Swing?

You could use a JDialog. Else this might help
http://java.sun.com/docs/books/tutorial/uiswing/components/frame.html#setDefaultLookAndFeelDecorated.

> Related to Thread Issues
> -------------------------------
> I open a new JFrame in a new Thread from a java program (which is also
> a JFrame).
>
> The class definition for this new JFrame application to be opened is
>
> public class Chat extends JFrame implements Runnable {
> .........
> }
>
> When i dispose the Frame, will this new thread be get killed?
> Or it continue to use system resources?

I think the thread will be killed when run() exits.
I hope you know that GUI interaction has to be done from the event
dispatching thread (see
http://java.sun.com/docs/books/tutorial/uiswing/misc/threads.html).

> How to kill a particular thread from a JVM when there are so many
> threads running simeltaneously?

Just let the thread know that he has to finish its run-method.

Greetings
     Dirk