This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Journey To Enterprise Agility and have Daryl Kulak & Hong Li on-line!
See this thread for details.
Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Multiple text selection in JTextArea  RSS feed

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wonder how, if possible, I can maintain multiple text selection in JTextArea/JTextPane/JEditorPane.

Any hints are very appreciated.

Frank :roll:
 
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Frank Truong:
I wonder how, if possible, I can maintain multiple text selection in JTextArea/JTextPane/JEditorPane.

Any hints are very appreciated.

Frank :roll:



There might be something in JTextComponent#setHighlighter and Highlighter#addHighlight()

Note: This is just an off the cuff reply as I personally have never tried it.
 
Sheriff
Posts: 21421
94
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It isn't possible. In fact, I have yet to meet the first text editor / IDE which does allow for multiple text selections.
 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob, I'm not sure you are correct. Open a Microsoft Word document (I know, I hate MS too). Now, use the mouse to select the first paragraph. Next, press the Control key and use the mouse to select a second paragraph elsewhere in the document. Do a "Copy" and then open a new Word document and do a Paste. The two paragraphs will show up on the document, but not the unselected portions of the original.

Now, can the current version of the JTextArea do this too? I don't know...but I may spend some time trying it out...
[ July 30, 2008: Message edited by: Gil Estes ]
 
Rob Spoor
Sheriff
Posts: 21421
94
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried the CTRL thing in both a JTextArea and MS Word 2000, and neither could do it. Perhaps MS have added this in a later version.
 
G Estes
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am testing in Word 2002, so not that recent of a thing. Haven't tested or tried to code to it in JTextArea. I'm not saying JTextArea is possible, just that there are apps that can do it...

Cheers!
 
Marshal
Posts: 59742
188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am pretty sure I have got it to work on OpenOffice2.3.
 
Rob Spoor
Sheriff
Posts: 21421
94
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well that explains it. I never met those applications
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Frank Truong:
I wonder how, if possible, I can maintain multiple text selection in JTextArea/JTextPane/JEditorPane.


Ok.
I toyed around and came up with this. Of course this is not fool proof (e.g. it cannot figure out de-selection, but its a start.

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!