• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Text Area help...Please!!!

 
Drew Thomas
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I'm sort of a newbie at java applets, and kind of to java in general. I've done basic java programming in college but that was all command line stuff, this is new to me.

I'm trying to do what should be simple (at least in my mind) I have the basic page worked out and it is working somewhat. The page consist of two frames, the applet is in the main frame and simply consist of a text area, a combo box, and a button. In the text area a user should be able to copy and paste a large selection of text in either German, Italian, French, Spanish, or English, then while they are reading the text if they wish to translate a word they can select a dictionary from the combo box and press the button and the translation dictionary will open in the right pane. I sort of have it working though not to the liking of the person that I'm writing it for. Here is a look at what is working right now:
http://classroom.fctl.ucf.edu/language/newlanguage

A little background: I'm rewriting this from JavaScript because JavaScript isn't really cross platform compliant, heck; it is not even cross browser compliant.

Here is the problem that I'm having:
The User wants the program to do the lookup with the selected dictionary as soon as the word is double clicked. I tried to implement this and I searched google but I can't find an onSelection() method, or can't find out something similar, like in java script. So what the work around to this was a customized Popup menu Driven by the right click event. The problem with this is that a normal TextArea can�t have a modified popup menu because the OS�s popup menu overrides it, and if I use a JTextArea then I have to jump through hoops to get copy/cut/paste to work.

Here is my question, Can anyone see a simpler workaround to this problem? If not can you point me in the right direction to a solid solution to this. I�ve been reading so many forums, help docs, class specifications, and Code that my eyes are crossed and I confused myself. I Guess all I need is a push in the right direction�may be one of you did an example of something with a text area that sort of meets my needs that you can link me to and I can get the rest.

A little footnote here: if you looked at the link you can see that it goes to a university webpage. This is not a class assignment! I know some people have problems with helping students with projects and I don�t blame them.

Thanks in advance for any help that you all can give me!



Drew Thomas
Technology Assistant
FCTL UCF
http://www.fctl.ucf.edu/
 
Abhinav Anand
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Please copy paste the following code into a file named MainFrame.java
Try to compile and execute. Double click on any word in the text are and you will see the result in the text box below:



Hope it helps.
 
Abhinav Anand
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Thomas,

Welcome to Java Ranch.

Please copy paste the code below into a file named MainFrame.java
Try to compile and execute, it should work properly.
In the executed program, double click on any word in the text area,
this will cause a message to be displayed in the text box below
the text area.



Hope this helps.
 
Abhinav Anand
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Thomas,

Welcome to Java Ranch.

Please copy paste the code below into a file named MainFrame.java
Try to compile and execute, it should work properly.
In the executed program, double click on any word in the text area,
this will cause a message to be displayed in the text box below
the text area.



Hope this helps.
 
Abhinav Anand
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Thomas,

Welcome to Java Ranch.

Please copy paste the code below into a file named MainFrame.java
Try to compile and execute, it should work properly.
In the executed program, double click on any word in the text area,
this will cause a message to be displayed in the text box below
the text area.



Hope this helps.
 
Drew Thomas
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Abhlnav, Thanks for the reply, That helps...I think you are on to something here! Thanks!


Drew
 
Drew Thomas
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Once again Abhinav I would like to thank you. I just finished implementing your suggestions and it worked beautifully. I've posted this request on 4 forums now and this was the first truly helpful reply that I got! Thanks!


Enjoy,
Drew
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic