• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

making a portion of a text component unselectable

 
Aron Jhed Amiscosa
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • 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.
 
Rob Spoor
Sheriff
Pie
Posts: 20661
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • 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
  • 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...


 
Stanislav Lapitsky
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic