Re: Components in JPanel




"Carl" <c.groner@xxxxxxxxx> wrote in message
news:1143588725.125176.137160@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hello Nandu,
My reply is inline...

Nandu wrote:
Hi
I am placing JLabels, JButtons , JRadioButtons and other components
on the JPanel at random. Now how can i know what are components are
there in the JPanel at a instance of time.

The Container.getComponents() method will retrive an array of all
Component objects in the Container.

How can get their names. For
example if btn_Hello is a JButton and if it is on the JPanel then i
should be able to get btn_Hello is on the JPanel.

How about the getName() method of Component objects?

If I remember correctly, getName() returns a blank (or null) if you call it
without first using setName() to give the component a name. So, you will
want to make a point of giving the component a name with setName() when you
create it, e.g. setName("my first button").

--
Rhino


.



Relevant Pages

  • Restricting dragging component inside a JPanel
    ... I have a JPanel into which JButtons are added. ... Kindly advice how i can restrict the dragging ...
    (comp.lang.java.gui)
  • Restricting dragging a JButton inside a JPanel
    ... The following code creates a JPanel on which JButtons can be added by ... GridBagConstraints gridBagConstraints; ... public void actionPerformed{ ...
    (comp.lang.java.gui)
  • cant see Jpanel and Jbutton
    ... here is a strange problem that, I had added some jbuttons on a jpanel( ... thk u very much, hope someone help, thks again ...
    (comp.lang.java.help)
  • Re: Components in JPanel
    ... I am placing JLabels, JButtons, JRadioButtons and other components ... there in the JPanel at a instance of time. ... How about the getNamemethod of Component objects? ...
    (comp.lang.java.help)
  • scrollpane
    ... I have a JPanel with a variable number of JButtons. ... scrollpane.where I can scroll through al JButtons. ... JScrollPane myScrollPane= new JScrollPane; ...
    (comp.lang.java.gui)