Solved

Formatting JLabels

Posted on 2003-11-23
11
401 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
  • 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
 
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This video teaches viewers about errors in exception handling.

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now