Re: custom Swing component



On 27 Sep 2005 23:51:55 -0700, "Chanchal" <chanchal.jacob@xxxxxxxxx>
wrote or quoted :

>i want to create a custom component with a text field and a button. i'm
>using netbeans IDE.when i place it to a container and resize the
>component, i want the text field to be resized accordingly. how would i
>do that. please help

Just create a create a ChanchalPanel class that extends JPanel.

in your constructor set up a layout manager.

add the JTextField and JButton.

hook up some listeners.

Now instantiate an instance of the ChanchalPanel and add it to some
bigger container and eventually validate the whole shebang and
setVisible( true ).

For something that simple, you might use a JOptionPane if you just
want it to pop up and go away.

see http://mindprod.com/jgloss/Jpanel.html
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
.