This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes making a portion of a text component unselectable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "making a portion of a text component unselectable" Watch "making a portion of a text component unselectable" New topic
Author

making a portion of a text component unselectable

Jhedzkie Skies
Ranch Hand

Joined: Oct 28, 2009
Posts: 118
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

Joined: Oct 27, 2005
Posts: 19656
    
  18

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Jhedzkie Skies
Ranch Hand

Joined: Oct 28, 2009
Posts: 118
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

Joined: Dec 01, 2009
Posts: 53
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
 
Consider Paul's rocket mass heater.
 
subject: making a portion of a text component unselectable
 
Similar Threads
What is a Console class
How a character save in 2 bytes in Java?
Creating a command prompt is swing
Blocking user input
array and setmethod