Re: multi-lined labels?
Erk. A better solution (IMO) is to extend JTextArea, and give it the look and feel of a JLabel. The HTML solution seems kinda hacky to me - different OS's give different font sizes, etc. I just don't like it that the line break is hardcoded, and prefer Java to decide for me. The HTML solution also depends on the window staying the same width, etc. -Original Message- From: Harkishin Nachnani [EMAIL PROTECTED] To: alex [EMAIL PROTECTED]; [EMAIL PROTECTED] [EMAIL PROTECTED] Date: Thursday, July 05, 2001 08:05 Subject: RE: multi-lined labels? Use HTML Example: html line one br line two /html -Original Message- From: alex [mailto:[EMAIL PROTECTED]] Sent: Thursday, July 05, 2001 1:36 PM To: [EMAIL PROTECTED] Subject: multi-lined labels? Is there a way to create a JLabel with text that breaks across multiple lines? Thanks, -alex __ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail http://personal.mail.yahoo.com/ ___ Swing mailing list [EMAIL PROTECTED] http://eos.dk/mailman/listinfo/swing ___ Swing mailing list [EMAIL PROTECTED] http://eos.dk/mailman/listinfo/swing ___ Swing mailing list [EMAIL PROTECTED] http://eos.dk/mailman/listinfo/swing
RE: multi-lined labels?
He Greg: thats sounds like a good idea...Can you throw some light on the JTextArea method ??? Regards, Harkishin -Original Message- From: Greg Munt [mailto:[EMAIL PROTECTED]] Sent: Friday, July 06, 2001 5:30 AM To: Harkishin Nachnani; alex; [EMAIL PROTECTED] Subject: Re: multi-lined labels? Erk. A better solution (IMO) is to extend JTextArea, and give it the look and feel of a JLabel. The HTML solution seems kinda hacky to me - different OS's give different font sizes, etc. I just don't like it that the line break is hardcoded, and prefer Java to decide for me. The HTML solution also depends on the window staying the same width, etc. -Original Message- From: Harkishin Nachnani [EMAIL PROTECTED] To: alex [EMAIL PROTECTED]; [EMAIL PROTECTED] [EMAIL PROTECTED] Date: Thursday, July 05, 2001 08:05 Subject: RE: multi-lined labels? Use HTML Example: html line one br line two /html -Original Message- From: alex [mailto:[EMAIL PROTECTED]] Sent: Thursday, July 05, 2001 1:36 PM To: [EMAIL PROTECTED] Subject: multi-lined labels? Is there a way to create a JLabel with text that breaks across multiple lines? Thanks, -alex __ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail http://personal.mail.yahoo.com/ ___ Swing mailing list [EMAIL PROTECTED] http://eos.dk/mailman/listinfo/swing ___ Swing mailing list [EMAIL PROTECTED] http://eos.dk/mailman/listinfo/swing ___ Swing mailing list [EMAIL PROTECTED] http://eos.dk/mailman/listinfo/swing
RE: multi-lined labels?
You can use this: public static final JComponent createMultiLineLabel(String text) { // Count the number of newline characters in the text StringTokenizer st = new StringTokenizer(text, \n); int lines = st.countTokens(); JTextArea ta = new JTextArea(text, lines, 0); ta.setAlignmentX(Component.LEFT_ALIGNMENT); ta.setOpaque(false); ta.setEnabled(false); ta.setFont(UIManager.getFont(Label.font)); ta.setDisabledTextColor(UIManager.getColor(Label.foreground)); ta.setMaximumSize(ta.getPreferredSize()); // in case parent's layout is a BoxLayout return ta; } Then all you need to do is: getContentPane().add(createMultiLineLabel(Hello\nWorld)); John -Original Message- From: Harkishin Nachnani [mailto:[EMAIL PROTECTED]] Sent: Friday, July 06, 2001 6:55 AM To: Greg Munt; alex; [EMAIL PROTECTED] Subject: RE: multi-lined labels? He Greg: thats sounds like a good idea...Can you throw some light on the JTextArea method ??? Regards, Harkishin -Original Message- From: Greg Munt [mailto:[EMAIL PROTECTED]] Sent: Friday, July 06, 2001 5:30 AM To: Harkishin Nachnani; alex; [EMAIL PROTECTED] Subject: Re: multi-lined labels? Erk. A better solution (IMO) is to extend JTextArea, and give it the look and feel of a JLabel. The HTML solution seems kinda hacky to me - different OS's give different font sizes, etc. I just don't like it that the line break is hardcoded, and prefer Java to decide for me. The HTML solution also depends on the window staying the same width, etc. -Original Message- From: Harkishin Nachnani [EMAIL PROTECTED] To: alex [EMAIL PROTECTED]; [EMAIL PROTECTED] [EMAIL PROTECTED] Date: Thursday, July 05, 2001 08:05 Subject: RE: multi-lined labels? Use HTML Example: html line one br line two /html -Original Message- From: alex [mailto:[EMAIL PROTECTED]] Sent: Thursday, July 05, 2001 1:36 PM To: [EMAIL PROTECTED] Subject: multi-lined labels? Is there a way to create a JLabel with text that breaks across multiple lines? Thanks, -alex __ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail http://personal.mail.yahoo.com/ ___ Swing mailing list [EMAIL PROTECTED] http://eos.dk/mailman/listinfo/swing ___ Swing mailing list [EMAIL PROTECTED] http://eos.dk/mailman/listinfo/swing ___ Swing mailing list [EMAIL PROTECTED] http://eos.dk/mailman/listinfo/swing ___ Swing mailing list [EMAIL PROTECTED] http://eos.dk/mailman/listinfo/swing
Re: multi-lined labels?
In the updateUI method of your JTextArea subclass: LookAndFeel.installBorder (this, Label.border); LookAndFeel.installColorsAndFont (this, Label.background, Label.foreground, Label.font); The LookAndFeel class is in the javax.swing package. -Original Message- From: Harkishin Nachnani [EMAIL PROTECTED] To: alex [EMAIL PROTECTED]; [EMAIL PROTECTED] [EMAIL PROTECTED] Date: Thursday, July 05, 2001 08:05 Subject: RE: multi-lined labels? Use HTML Example: html line one br line two /html -Original Message- From: alex [mailto:[EMAIL PROTECTED]] Sent: Thursday, July 05, 2001 1:36 PM To: [EMAIL PROTECTED] Subject: multi-lined labels? Is there a way to create a JLabel with text that breaks across multiple lines? Thanks, -alex __ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail http://personal.mail.yahoo.com/ ___ Swing mailing list [EMAIL PROTECTED] http://eos.dk/mailman/listinfo/swing ___ Swing mailing list [EMAIL PROTECTED] http://eos.dk/mailman/listinfo/swing ___ Swing mailing list [EMAIL PROTECTED] http://eos.dk/mailman/listinfo/swing
Re: multi-lined labels?
You must use html text. For example: import javax.swing.*; public class Multiline extends JFrame{ public Multiline() { JLabel text = new JLabel("htmlHelloBRworld/html"); getContentPane().add(text); } static public void main(String []args) { Multiline m = new Multiline(); m.pack(); m.setVisible(true); }} Regards. - Jose Luis Rando Calvo Area de Investigación y Desarrollo Estudio Informática Software S.L.U.- · · [ Grupo EI ] · ·- http://www.grupoei.com mail: [EMAIL PROTECTED] phone: +34 952 653 516 fax: +34 952 650 460- alex [EMAIL PROTECTED] 07/05 7:35 Is there a way to create a JLabel with text that breaks across multiplelines?Thanks,-alex__Do You Yahoo!?Get personalized email addresses from Yahoo! Mailhttp://personal.mail.yahoo.com/___Swing mailing list[EMAIL PROTECTED]http://eos.dk/mailman/listinfo/swing
RE: multi-lined labels?
Use HTML Example: html line one br line two /html -Original Message- From: alex [mailto:[EMAIL PROTECTED]] Sent: Thursday, July 05, 2001 1:36 PM To: [EMAIL PROTECTED] Subject: multi-lined labels? Is there a way to create a JLabel with text that breaks across multiple lines? Thanks, -alex __ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail http://personal.mail.yahoo.com/ ___ Swing mailing list [EMAIL PROTECTED] http://eos.dk/mailman/listinfo/swing ___ Swing mailing list [EMAIL PROTECTED] http://eos.dk/mailman/listinfo/swing