Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-07-2007, 06:16 PM
JavaBean's Avatar
Moderator
 
Join Date: May 2007
Posts: 1,272
JavaBean is on a distinguished road
How to write multiline String in a JLabel
How can i write a string that is shown in many lines in a JLabel. Or is there any orher way to write them?

Also, similarly how to write tooltip text that spans across many lines. Not just one line
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 06-07-2007, 06:18 PM
Ada Ada is offline
Member
 
Join Date: May 2007
Posts: 8
Ada is on a distinguished road
You could just try setting the string text to what you want, and use the \n command to break the lines up.

ie.

Code:
String str = "This is \nmy example \nof a multi-line \nJLabel"; JLabel strLabel = new JLabel (str);
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 06-07-2007, 06:19 PM
Senior Member
 
Join Date: Dec 2006
Posts: 748
levent is on a distinguished road
Code:
import java.awt.*; import javax.swing.*; public class MultilineLabel { public static void main(String[] args) { String str = "This is \nmy example \nof a multi-line \nJLabel"; JLabel strLabel = new JLabel (str); display(strLabel, "Hmmm..."); } public static void display(JComponent comp, String title) { JFrame f = new JFrame(title); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(comp); f.pack(); f.setLocationRelativeTo(null); f.setVisible(true); } }
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Method to write if the string object can be converted to Integer or not. Abhishek New To Java 4 03-25-2008 01:16 PM
Finding the exact length of a string in a JLabel (in pixels) Clarkey Advanced Java 2 03-25-2008 06:49 AM
Problems with JLabel 2 geork New To Java 2 02-03-2008 09:40 PM
JLabel Jack AWT / Swing 2 07-02-2007 02:55 PM
JLabel Freddie AWT / Swing 2 05-29-2007 03:19 PM


All times are GMT +3. The time now is 11:55 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org