• 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

making a portion of a text component unselectable

 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi there...

i am seeking an advice of which JTextComponent to use in this situation..
im like emulating a command prompt... like


console> "commands here"
console> "more commands"



im wondering... which text component will help me best here..

and also, i wanted to know how to make it not to be highlighted. really just a command prompt.

i need suggestions. thanks.
 
Sheriff
Posts: 22791
131
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know it it's possible at all. You don't see just about every application with command entry functionality to use a separate text field (or combo box with the last X commands) for entry and a non-editable text area for output.
 
Aron Jhed Amiscosa
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Prime wrote:I don't know it it's possible at all. You don't see just about every application with command entry functionality to use a separate text field (or combo box with the last X commands) for entry and a non-editable text area for output.



i see. thanks for this enlightenment.

all i've done so far is uneditable text area with key listeners to append inputs.



so far, that is about my stuff.

so i need appends to do inputs thru key listeners. now im stuck in implementing the backspace...


 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can add a DocumentFilter to the textarea's document. In the insertString and remove methods just check whether offset comes in the last line after the last \n.
Also you can add custom higlighter t prevent selection text portions. Or just add caret listener to check selection start and end and reset thm if the start!=end.

Regards,
Stas
 
reply
    Bookmark Topic Watch Topic
  • New Topic