Solved

Formatting JLabels

Posted on 2003-11-23
11
410 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
Technology Partners: 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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Suggested Solutions

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…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Suggested Courses

732 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