• Post Reply Bookmark Topic Watch Topic
  • New Topic

Customizable JTextAreas?  RSS feed

 
Brian Drelling
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, I am making two programs. In one program, a builder, user can use JTextField and JTextArea to enter info, which they can then save into a .txt file. For the other program, a reader/viewer, the user should only be able to view the info from the text components.

I know the easiest option is to just make everything uneditable and call it a day. However, I'd like to have the info displayed in a better way. Like the way labels are, only without labels in the picture at all.

Basically, I want a text area that doesn't look like a text area. It can have a border, but I'd rather change the background color, etc.

I've looked into JTextPane, but I'm not sure if that is what I want. It looks overly complicated, using URL's to pull in "style documents" and other such stuff.


Can anyone help me figure out what I need in this scenario? If I need more info, I'd be happy to provide.

Thanks!
 
Rob Camick
Ranch Hand
Posts: 2801
15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but I'd rather change the background color, etc.


Then do it. Read the API for the appropriate method.

Or you can make the text area non opaque. Again the method is is the API.
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
edit Oops, postings overlapped
 
Brian Drelling
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Camick wrote:
but I'd rather change the background color, etc.


Then do it. Read the API for the appropriate method.

Or you can make the text area non opaque. Again the method is is the API.


I've been looking at the API for JTextArea and I don't know which method I am supposed to use.

Not trying to sound offensive, but it doesn't help much when asking for help, and I am told to "just do it because it is in the API". Asking "Did you check the API?" is one thing, but just telling me to go ahead and do it because the method doesn't help me to figure out what I am looking for.

I understand not giving the answer to a newbie outright because you expect them to learn, but this isn't really a question of helping me get a step further, but rather, making me feel like an idiot and telling me the answer is obvious when I cannot find it.

Again, not trying to sound offensive and I appreciate any and all help, but is there anything else you could tell me to push me in the right direction? I don't know which method I am expected to use, whether it is an inherited method or not, or even if you were specifically referencing JTextArea's over JTextPane's. I've looked both up and down and don't know exactly what you intended me to see. I don't doubt it is there since you say so and I believe you, but I can't find said method.
 
mark goking
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi brian, the JTextArea class in the api has lots of set#### methods where you can change the background, borders and others.

e.g.
background - setBackground()
border - setBorder()
 
Rob Camick
Ranch Hand
Posts: 2801
15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've looked both up and down and don't know exactly what you intended me to see.


When I answer a question I assume people know how use use the API and search it.

Why did you "look" up and down? How about doing a simple search? You said you wanted to change the "background", did you search for any method with the work "background" in the method name?

Did you do a search for any method with "set" in the method name?
 
Brian Drelling
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perhaps I am asking the wrong question? setBorder, setBackground, setOpaque, all these things don't accomplish exactly what I am looking for, but I guess I am not explaining myself well?
 
Paul Clapham
Sheriff
Posts: 22507
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, but do they do some of what you want? I mean, you said you wanted to change the background colour, so why isn't setBackground() the right thing? Or is it the right thing, but you need something else? Or are you having a problem choosing the right background colour? (If that's it, then just get the background colour from a JLabel and set your text component with that colour.)
 
Rob Camick
Ranch Hand
Posts: 2801
15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Brian Drelling wrote:Perhaps I am asking the wrong question? setBorder, setBackground, setOpaque, all these things don't accomplish exactly what I am looking for, but I guess I am not explaining myself well?


We have answered the question based on your original requirements. You have not changed any of the requirements.

If you need further help then you need to create a SSCCE (Short, Self Contained, Compilable and Executable, Example Program), that demonstrates the incorrect behaviour based on the suggestions we have already made.

Don't forget to use the Code Formatting Tags so the posted code retains its original formatting. That is done by selecting the code and then clicking on the "Code" button above the question input area.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!