Solved

Formatting JLabels

Posted on 2003-11-23
11
408 Views
Last Modified: 2010-05-18
HI all

Im creating a simple GUI, ive got a box with a biography in it (about 500 words), currently im displaying them in a JLabel, the problem is that the text all appears across the same line. I also tried JText Area, but the problem with that was it was editable or it looked editable.

I basically need a large text area that appears the same as a JLabel, if anyone know how to do that it would be a great help

Thanks in advance

0
Comment
Question by:KrisM82
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
  • 2
  • +1
11 Comments
 
LVL 15

Expert Comment

by:jimmack
ID: 9806047
You could still use a JLabel if you really want using HTML (just add normal HTML as the label text, including the <HTML> tags and <P> etc.

I assume that you aren't happy setting the JTextArea uneditable (using setEditable(false)).
0
 

Author Comment

by:KrisM82
ID: 9806057
Thanks that should do the trick for now, is there anyway to that i can do this with out adding the tags, because each biography is different and then if I cange the layout i will need to re position all the <br> tags, and as there are over 50 biographycs i dont really want to have to edit them all every time I change the GUi a bit
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 9806079
Just call

setEditable(false);

on the JTextArea
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 86

Expert Comment

by:CEHJ
ID: 9806082
Oh sorry missed the fact that that's been suggested ;-) What's the problem with it btw?
0
 

Author Comment

by:KrisM82
ID: 9806097
Ive got a biorgaphy for about 500 people which are between 300 and 500 words in size, I want to display them so they look the same as a Jlbabel to keep the style all the same, ive tried using JTextAread and a fe others but they all look like edtable fields even if you set them not to be. I just want to displayed so the user cant edit it and the page has a running format
0
 

Author Comment

by:KrisM82
ID: 9806574
the problem is that its white and you can select the test and I want it to look like a JLabel so the game looks the same all over
0
 
LVL 92

Accepted Solution

by:
objects earned 50 total points
ID: 9806827
textarea.setBackground(bgcolour);
0
 
LVL 92

Expert Comment

by:objects
ID: 9806858
And to stop it being selected just set the selection colour the same as the background colour using setSelectionColor().
0
 
LVL 92

Expert Comment

by:objects
ID: 9806862
You''l probably also need to change the foreground colour and font to also match the JLabel.
0
 

Author Comment

by:KrisM82
ID: 9806982
Sorted the problem, thanks for the help
0
 
LVL 92

Expert Comment

by:objects
ID: 9807013
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to get all the API from website? 11 124
how to see all occupied ports on windows 10 laptop 15 83
Java: anonymous class 4 37
What is the use of Forwarding Class in java 1 34
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question