| Author |
can't I take a single array for JTextField and JTextArea as both are derived from JTextComponent
|
Kr. Pallav
Ranch Hand
Joined: Mar 06, 2010
Posts: 32
|
|
Below is the piece of code I am trying
The program compiles well but throws java.lang.ArrayStoreException: javax.swing.JTextArea
I know the reason is I am storing two different object JTextFiled and JTextArea to single array it is coming like that but both JTextField and JTextArea are derived from JTextComponent can't I take a single array , why to take two different array for them.
Is there any alternate way to do it in a single array .
|
~|>@//@\/~
Kumar Pallav
-------------------
SCJP 5: 86 %, SCWCD: 91%
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
There's the problem. You have declared it as an array of JTextComponents, but in reality it's an array of JTextFields. Change the initialization to new JTextComponent[...] and you should be fine.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Kr. Pallav
Ranch Hand
Joined: Mar 06, 2010
Posts: 32
|
|
Dear Rob Prime , I am really sorry for doing such silly mistake , and I am really thankful to you for replying and giving your time to me , It was such a silly mistake .
Thanks a lot ,God Bless
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
You're welcome
|
 |
 |
I agree. Here's the link: jrebel
|
|
subject: can't I take a single array for JTextField and JTextArea as both are derived from JTextComponent
|
|
|