Results 1 to 5 of 5
- 02-24-2011, 06: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, 06: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)How to Ask Questions the Smart Way
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
- 02-24-2011, 10: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, 05:05 PM #4
Well, what happened when you tried that? Sounds about right to me.
If you want help with colors, you should provide an SSCCE that demonstrates what you're doing. Also, just as a hint, you might try using HTML to add colors.How to Ask Questions the Smart Way
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
- 02-25-2011, 07:26 PM #5
Well I didn't really do that yet, I was making sure I was going to do it right. Out of all the things I know about java, GUI are one of the things that I have trouble in.:mad: Sorry but I don't know how to auto resize a component. Is there a setting for that or do I right custom code for that. So far I added two JTextPane to my JFrame. I will worry about the colors later. Thanks:)
Similar Threads
-
Need help with printing console output to JTextArea
By ShinTec in forum AWT / SwingReplies: 4Last Post: 06-04-2010, 10:10 AM -
JTextArea on PopUp -JTextArea isn't editable
By Richy76 in forum AWT / SwingReplies: 3Last Post: 02-01-2010, 07:51 PM -
Link an external compiler to the eclipse environment throw the console in eclispe
By adolf111 in forum EclipseReplies: 1Last Post: 12-13-2008, 01:24 AM -
Environment for java
By carl in forum New To JavaReplies: 2Last Post: 07-31-2007, 08:33 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks