Results 1 to 5 of 5
- 02-24-2011, 07:28 PM #1
Console like Environment in JTextArea
I have a couple of questions. I want to make a console like environment in a JTextArea like the command prompt or terminal. Like when you type in the terminal you can only type on the last line and cant move the mouse cursor up and delete any characters. For example in the terminal the mouse cursor always stays after the line name@name-linux:~$ You cant change the mouse cursor position with the mouse. Is that even possible. My second question is can you change the text color in the JTextArea only on some text. Like this
This is some text
This is some text
This is some more text
- 02-24-2011, 07:30 PM #2
For your first problem, I'd probably use two different text areas- one for what's currently being typed, and one for the "history".
For your second problem, read this: Using Text Components (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Swing Components)
- 02-24-2011, 11:10 PM #3
Thanks Kevin but Im still having some problems. Im going to be using JTextPane. So you want me to create two JTextPanes. One is the history and the other is the enter text in. This is going to be hard to explain. So do I want my enter text TextPane to be below the history TextPane? When I press enter in the enter text TextPane the text will go to the history TextPane. The history textpane will get bigger and bigger as I add more text to it and it will push the enter text textpane down. Then when I clear it, the enter text TextPane will be back at the top and there will be nothing in the history TextPane. Is that correct?
Also Im having trouble with added colors to some of the text in a JTextPane. Do you have to use StyleContext or something like that?
- 02-25-2011, 06:05 PM #4
SSCCE that demonstrates what you're doing. Also, just as a hint, you might try using HTML to add colors.
- 02-25-2011, 08:26 PM #5
- By ShinTec in forum AWT / SwingReplies: 4Last Post: 06-04-2010, 10:10 AM
- By Richy76 in forum AWT / SwingReplies: 3Last Post: 02-01-2010, 08:51 PM
- By adolf111 in forum EclipseReplies: 1Last Post: 12-13-2008, 02:24 AM
- By carl in forum New To JavaReplies: 2Last Post: 07-31-2007, 08:33 PM