Re: Component.add ignores addition of same object ???
Hello Sabine,
Thanks for the responce...
But if you want X JTextFields, then you need to create X new
JTextFields. Otherwise, are you trying to display several input fields,
that all refer to the same object? What do you hope to gain from this?
yeah i know but i do sometimes need to display an object twice or
more.....
and this has to be a JTextField or a derived form.
i was kinda baffled that when i add a component, java kicked it out
without telling..
and since i can not find a thing in the manual....
The real question is:
is this allowed or not despite the fact what one wants with it... if
it is
not allowed i need to copy stuff. (not easy and nice....)
Superboer.
way fast=http://www.clipjes.nl/clip/nederlands/n/normaal_-
_oerend_hard.html
On 11 apr, 13:46, Sabine Dinis Blochberger <no.s...@here.invalid>
wrote:
Superboer wrote:
Hello All,
sorry for my ignorance, however why does this:
==================================
import javax.swing.*;
class x{
public static void main (String[] args) {
JPanel j = new JPanel(false);
JTextField jtf = new JTextField("nr");
for (int i = 0 ; i < 10; i++){
j.add(jtf);
}
System.out.println("have added:"+j.getComponentCount()+": to
JPanel...");
}
}
==================================
yield one. ???
And yes i do want to add X times the same object, not X times a new
object....
I can not find a clue in the manual.
Thanks
Superboer.
But if you want X JTextFields, then you need to create X new
JTextFields. Otherwise, are you trying to display several input fields,
that all refer to the same object? What do you hope to gain from this?
You can re-use the local Variable for adding (if you don't need any
reference to your JTextfields later on), but the new statement needs to
be inside the loop.
--
Sabine Dinis Blochberger
Op3racionalwww.op3racional.eu