This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Works without textarea...why? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Works without textarea...why?" Watch "Works without textarea...why?" New topic
Author

Works without textarea...why?

Alisha Burke
Greenhorn

Joined: Jan 22, 2005
Posts: 27
Hi all,

I have a code which does simple multiplication like 1x2, 2x2 and so on.
Why is it that when i try to insert the result of multiplication in a "textarea" i get compilation error( I have tried using without textareas and the multiplication is going on well). I want to familiarize with textareas that's why i am testing this out. Please shed some light on this....thank you.









[ February 19, 2005: Message edited by: Alisha Burke ]

[ February 19, 2005: Message edited by: Alisha Burke ]
[ February 19, 2005: Message edited by: Alisha Burke ]
Liam Tiarnach
Ranch Hand

Joined: Aug 06, 2004
Posts: 51
You'll love this one...
f is a String, right ???

f=Integer.toString(i);// f is a String...


but here...

output.insert(resultString, f*20);


you are trying to multiply f by 20... Hmm...

also, where is 'i' coming from ( and don't say from across the street... )...
the reason I ask is that the only place I see 'i' is in your method Calculate(), but 'i' there will fall out of scope and therefore cannot be used outside your method...

any way, there is the trail of bread crumbs for ya...

copy and paste... what an idea...


- Liam...<br />- ' He who never sleeps... '
Alisha Burke
Greenhorn

Joined: Jan 22, 2005
Posts: 27
Hi Liam

copy and paste :roll:

well i used to post the same question in 6 different forums. Not a very good idea though cos some ppl are members of diff forums and they'll notice (like you ) .

I stick to 2 forums now(this java ranch is my favourite)

*cheers*
Liam Tiarnach
Ranch Hand

Joined: Aug 06, 2004
Posts: 51
I only belong to two, though I post more at the other... this one is definitely friendly...
Igor Stojanovic
Ranch Hand

Joined: Feb 18, 2005
Posts: 58
I was posting on several forums but now when I found out about java ranch I will post only here, very friendly forum, nice people with lots of experts willing to help and very fast answers (average answer I get so far is between 2 hours after posting question)





kind regards
Igor
Alisha Burke
Greenhorn

Joined: Jan 22, 2005
Posts: 27
I agree with u Igor. This forum is the friendliest forum i have known so far can't say for the other forum where there r a lot of and

Anyway back to my question, i have made some changes to my code. Now what i did was insert the answer(in the output textarea) under the calculate method so that I can use the 'i' variable. Is this correct?....or am I just making it look worse...
[ February 19, 2005: Message edited by: Alisha Burke ]
Liam Tiarnach
Ranch Hand

Joined: Aug 06, 2004
Posts: 51
looking better... but I would replace repaint() with calculate() in your actionPerformed() method... when you add text, the TextArea will get updated automatically...
so far so good...
Alisha Burke
Greenhorn

Joined: Jan 22, 2005
Posts: 27
Thanks for pointing it out to me
Wonder why i missed that in the first place :roll:
Liam Tiarnach
Ranch Hand

Joined: Aug 06, 2004
Posts: 51
By now you probably ready to beat up you program...
replace that output.insert() with output.append()
the reason... insert() is used if you want to insert a string into an existing text in your TextArea starting at the position given by the second arguement...
so if in your TextArea you have a text that says :

This some text

and you want to insert "is" into the statement, then you would do...

then you will get...

This is some text

so append will give you the desired results... so to speak...
next will be how to get the each results on a new line...

so instead of this...

5 x 1 = 5 5 x 2 = 10...

get this...

5 x 1 = 5
5 x 2 = 10
...

hehe... use the new line character '\n'...

have fun...
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
Alisha, why do you go back and edit your previous posts? It makes it very difficult for someone to jump in and try to help. Many of the messages in this thread don't make any sense now that you have removed some of the related information. I would strongly suggest that you leave previous posts as they are so that others can join in at any time. Also, someone may later encounter a similar problem and want to use the search tool to find previous discussions.

I would be more than happy to help you, but at the moment I can't because of your editing. Please keep this in mind for future posts.

Thanks,

Layne


Java API Documentation
The Java Tutorial
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Works without textarea...why?
 
Similar Threads
The Fastest Man in The World
Need Help With Sequence Alignment
Paint Method Puhhlease Help
How to reference a component?
How to convert binary to decimal?