Solved

Formatting JLabels

Posted on 2003-11-23
11
407 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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MySqlDump not dumping triggers 1 43
Is Applet the way to go for my drag and drop system? 8 25
Java syntax, or is it Selenium 6 30
Java 8 to Java 6 8 20
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
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 …
This video teaches viewers about errors in exception handling.

808 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