• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Multiple text selection in JTextArea

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am pretty sure I have got it to work on OpenOffice2.3.
 
Rob Spoor
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well that explains it. I never met those applications
 
Maneesh Godbole
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
I wish to win the lottery. I wish for a lovely piece of pie. And I wish for a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic