473,386 Members | 1,924 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How do I change line in a JLabel text?

108 100+
I have a label and when setting the text I want to change line .
For instance


String str="first line \n Secondline ";
JLabel label.setText(str);


I tried the above code but it does not work..How do I change line in a string ?
Dec 28 '10 #1
3 2380
Dheeraj Joshi
1,123 Expert 1GB
I tried the above code but it does not work
This is generic statement. What value label text has once you execute this code?

Please post the output as well.
Regards
Dheeraj Joshi
Dec 30 '10 #2
phpuser123
108 100+
first line Secondline
That's my output
Dec 30 '10 #3
Dheeraj Joshi
1,123 Expert 1GB
To support the multi line JLabel you need to implement your own UI Class to render the multiple lines.

But there is a quick work around.
You can use HTML tags instead of this.

Expand|Select|Wrap|Line Numbers
  1. JLabel label.setText("<html>Hello World! <br> I rule this world </html>");
  2.  
Regards
Dheeraj Joshi
Dec 30 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Benjamin Rutt | last post by:
I have a tkinter 'Text' and 'Scrollbar' connected and working normally. When a new line of text is inserted (because I'm monitoring an output stream), I'd like the text and scrollbar to be...
9
by: Peter | last post by:
Hi at all, how can I do to make a css file to change automatically the text size of the text that is into a table relatively the screen size? I.E. if the screen is 800 x I want the text...
2
by: Martin Dew | last post by:
I have a RichTextBox called rtbOutput. I am adding lines of text using the AppendText method. What I want to do is immediately after adding this line of text make sure that this line of text is...
2
by: Tom | last post by:
I want to get the 'size' of a line of text so that I can set the width of a control to show all that text. For instance, say my text is 'The dog chased the cat around the room' and I want to set a...
4
by: Tor Inge Rislaa | last post by:
How add a line of text to a textfile? I need a way to open an existing file of type .txt insert a line of tekst and then close the file again. TIRislaa
3
by: GeorgeB | last post by:
How can I print a line of text to a dot matrix printer and just perform a linefeed then at another time (by another action) print again another line just below the line previously printed using...
2
by: Simon | last post by:
Dear reader, Is it possible to change the text of a label in a form on the event "By open". In the event some VBA code will change the label text.
0
by: Screaming Eagles 101 | last post by:
I'dd like to change line(x) in a richtextbox, wordwrap is true, multiline is true. This ain't possible sayin' myTBX.Lines(5) = "blablabla" it seems... Why not ? I have a workaround by saying...
8
by: AdolfBinStalin | last post by:
Hi, I'm fairly new to perl and I'm running into a problem. I have a program that reads in a file line by line, performs a change on the text, and then outputs it to another file. I use "while(my...
0
by: Nelu | last post by:
I would appreciate some comments on the code below for reading a line of text from a stream. #include <stdio.h> #include <stdlib.h> #include <stdint.h> /** * Reads a line of text from a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.