|
Replies:
17
-
Last Post:
Sep 13, 2006 11:12 AM
by: Bill Snyder
|
|
|
|
|
|
|
multiline label
Posted:
Sep 4, 2006 10:34 AM
|
|
|
Does SwingLabs have a multi-line JLabel component?
--Bill [att1.html]
|
|
|
|
|
|
|
RE: multiline label
Posted:
Sep 4, 2006 3:49 PM
in response to: Bill Snyder
|
|
|
I wish!
Seriously, we always just end up using a JEditorPane and configure it to look like a label.
Richard
>Does SwingLabs have a multi-line JLabel component?
--------------------------------------------------------------------- To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net For additional commands, e-mail: jdnc-help@jdnc.dev.java.net
|
|
|
|
|
|
|
|
Re: multiline label
Posted:
Sep 4, 2006 3:57 PM
in response to: Richard Bair
|
|
|
Or a JTextArea. Our Aerith demo did just that (see this screenshot: http://www.flickr.com/photos/romainguy/163900068/in/ set-72157594161003744/ the big block of text). Here is the code:
JTextArea area = new JTextArea(text) { @Override public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint (RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
super.paint(g); } }; area.setEditable(false); area.setEnabled(false); area.setWrapStyleWord(true); area.setLineWrap(true); area.setOpaque(false); area.setForeground(detailsColor); area.setDisabledTextColor(detailsColor); // give disabled text a normal color
You can skip the paintComponent() part if you don't care about automatic antialiasing.
On 5 sept. 06, at 00:49, Richard Bair wrote:
> I wish! > > Seriously, we always just end up using a JEditorPane and configure > it to look like a label. > > Richard > >> Does SwingLabs have a multi-line JLabel component? > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net > For additional commands, e-mail: jdnc-help@jdnc.dev.java.net >
-- Romain GUY <romain.guy@mac.com> http://jroller.com/page/gfx http://www.progx.org
--------------------------------------------------------------------- To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net For additional commands, e-mail: jdnc-help@jdnc.dev.java.net
|
|
|
|
|
|
|
|
Re: multiline label
Posted:
Sep 4, 2006 4:27 PM
in response to: Romain GUY
|
|
|
Thanks. I was using a JTextArea. I'm already using some of the Aerith code, so I will just grab that snippet from AlbumSelector.
Thanks!
On 9/4/06, Romain GUY <romain.guy@mac.com> wrote: > > Or a JTextArea. Our Aerith demo did just that (see this screenshot: > http://www.flickr.com/photos/romainguy/163900068/in/ > set-72157594161003744/ the big block of text). Here is the code: > > JTextArea area = new JTextArea(text) { > @Override > public void paint(Graphics g) { > Graphics2D g2 = (Graphics2D) g; > g2.setRenderingHint > (RenderingHints.KEY_ANTIALIASING, > > RenderingHints.VALUE_ANTIALIAS_ON); > > super.paint(g); > } > }; > area.setEditable(false); > area.setEnabled(false); > area.setWrapStyleWord(true); > area.setLineWrap(true); > area.setOpaque(false); > area.setForeground(detailsColor); > area.setDisabledTextColor(detailsColor); // give > disabled text a normal color > > You can skip the paintComponent() part if you don't care about > automatic antialiasing. > > On 5 sept. 06, at 00:49, Richard Bair wrote: > > > I wish! > > > > Seriously, we always just end up using a JEditorPane and configure > > it to look like a label. > > > > Richard > > > >> Does SwingLabs have a multi-line JLabel component? > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net > > For additional commands, e-mail: jdnc-help@jdnc.dev.java.net > > > > -- > Romain GUY <romain.guy@mac.com> > http://jroller.com/page/gfx > http://www.progx.org > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net > For additional commands, e-mail: jdnc-help@jdnc.dev.java.net > > [att1.html]
|
|
|
|
|
|
|
|
Re: multiline label
Posted:
Sep 4, 2006 6:40 PM
in response to: Bill Snyder
|
|
|
The thing that doesn't quite work well with the JTextArea approach is resizing. Could be my layout manager (swing-layout), but when using the JTextArea vs a JTextAreaInAJScrollPane, the JTextArea doesn't expand and contract cleanly.
On 9/4/06, Bill Snyder <wsnyder6@gmail.com> wrote: > > Thanks. I was using a JTextArea. I'm already using some of the Aerith > code, so I will just grab that snippet from AlbumSelector. > > Thanks! > > > On 9/4/06, Romain GUY <romain.guy@mac.com> wrote: > > > > Or a JTextArea. Our Aerith demo did just that (see this screenshot: > > http://www.flickr.com/photos/romainguy/163900068/in/ > > set-72157594161003744/ the big block of text). Here is the code: > > > > JTextArea area = new JTextArea(text) { > > @Override > > public void paint(Graphics g) { > > Graphics2D g2 = (Graphics2D) g; > > g2.setRenderingHint > > (RenderingHints.KEY_ANTIALIASING, > > > > RenderingHints.VALUE_ANTIALIAS_ON); > > > > super.paint(g); > > } > > }; > > area.setEditable(false); > > area.setEnabled(false); > > area.setWrapStyleWord(true); > > area.setLineWrap(true); > > area.setOpaque(false); > > area.setForeground(detailsColor); > > area.setDisabledTextColor(detailsColor); // give > > disabled text a normal color > > > > You can skip the paintComponent() part if you don't care about > > automatic antialiasing. > > > > On 5 sept. 06, at 00:49, Richard Bair wrote: > > > > > I wish! > > > > > > Seriously, we always just end up using a JEditorPane and configure > > > it to look like a label. > > > > > > Richard > > > > > >> Does SwingLabs have a multi-line JLabel component? > > > > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net > > > For additional commands, e-mail: jdnc-help@jdnc.dev.java.net > > > > > > > -- > > Romain GUY <romain.guy@mac.com> > > http://jroller.com/page/gfx > > http://www.progx.org > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net > > For additional commands, e-mail: jdnc-help@jdnc.dev.java.net > > > > > [att1.html]
|
|
|
|
|
|
|
|
Re: multiline label
Posted:
Sep 12, 2006 2:02 AM
in response to: Bill Snyder
|
|
|
Hello,
I was wondering : did you try using a plain JLabel with html code inside ?
Pierre.
|
|
|
|
|
|
|
|
Re: multiline label
Posted:
Sep 12, 2006 5:45 AM
in response to: weebib
|
|
|
I did not, the reason being the label text is dynamic and I have no control of the original data. Though as I type this, I wonder if JLabel would resize text properly if it is wrapped in a simple HTML block. I'll have to experiment...
OK, I tried a simple example in NB and attached it. I couldn't get the HTML label to resize properly. The 'best' solution I see at this point is a JTextArea. Though it has resize issues to. Take the example code, make the window wider, then make it the smaller again, and notice the JTextArea does not resize the text.
On 9/12/06, jdnc-interest@javadesktop.org <jdnc-interest@javadesktop.org > wrote: > > Hello, > > I was wondering : did you try using a plain JLabel with html code inside ? > > > Pierre. > [Message sent by forum member 'weebib' (weebib)] > > http://forums.java.net/jive/thread.jspa?messageID=152118 > > --------------------------------------------------------------------- > To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net > For additional commands, e-mail: jdnc-help@jdnc.dev.java.net > > [att1.html] [MultiLinLabelTest.java] [MultiLinLabelTest.form] --------------------------------------------------------------------- To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net For additional commands, e-mail: jdnc-help@jdnc.dev.java.net
|
|
|
|
|
|
|
|
Re: multiline label
Posted:
Sep 12, 2006 12:48 PM
in response to: Bill Snyder
|
|
|
OK, well, tried again, fiddling with the (group) layout manager. Wrapping the text in an <html></html> block seemed to work.
On 9/12/06, Bill Snyder <wsnyder6@gmail.com> wrote: > > I did not, the reason being the label text is dynamic and I have no > control of the original data. Though as I type this, I wonder if JLabel > would resize text properly if it is wrapped in a simple HTML block. I'll > have to experiment... > > OK, I tried a simple example in NB and attached it. I couldn't get the > HTML label to resize properly. The 'best' solution I see at this point is a > JTextArea. Though it has resize issues to. Take the example code, make the > window wider, then make it the smaller again, and notice the JTextArea does > not resize the text. > > > On 9/12/06, jdnc-interest@javadesktop.org <jdnc-interest@javadesktop.org > > wrote: > > > > Hello, > > > > I was wondering : did you try using a plain JLabel with html code inside > > ? > > > > Pierre. > > [Message sent by forum member 'weebib' (weebib)] > > > > http://forums.java.net/jive/thread.jspa?messageID=152118 > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net > > For additional commands, e-mail: jdnc-help@jdnc.dev.java.net > > > > > > [att1.html]
|
|
|
|
|
|
|
|
Re: multiline label
Posted:
Sep 12, 2006 3:41 PM
in response to: Bill Snyder
|
|
|
> OK, well, tried again, fiddling with the (group) > layout manager. Wrapping > the text in an <html></html> block seemed to work.
Could you give us a brief summary of what worked?
Also, I've been thinking for a while about how to do HTML like layouts (that is page layouts. You could say this is like HTML, or you could say it is like print layouts that you might find in Adobe InDesign) in Swing. I've thought both about doing a custom LayoutManager, using a JEditorPane. The idea is to support not just wrapping text, but flowing text. Imagine a JComponent subclass that writes text in the background. But it does it such that if a child component is on the FlowingTextComponent, the text will either flow around the image, overwrite the image, or the image would obscure the text (depending on some layout constraints).
It's a fuzzy idea, but something I've had on a low priority thread for a couple weeks now.
Overkill for what you're doing, though 
Richard
|
|
|
|
|
|
|
|
Re: multiline label
Posted:
Sep 12, 2006 6:17 PM
in response to: rbair
|
|
|
Maybe a little overkill for my app, but the fluid-layout is certainly a useful idea. SWT has a mechanism for this sort of thing in the 3.2 release.<http:// .. * Embedding objects in text*
Using TextLayout and StyledText, it is now possible to embed objects such as images or widgets inside text. Glyph metrics such as ascent, descent and width can be specified. Objects wrap with the text.
[image: Picture showing an image embedded in text]
For examples, see the following snippets:
- Embedding objects in TextLayout<http:// - Embedding objects in StyledText<http://
On 9/12/06, jdnc-interest@javadesktop.org <jdnc-interest@javadesktop.org> wrote: > > > OK, well, tried again, fiddling with the (group) > > layout manager. Wrapping > > the text in an <html></html> block seemed to work. > > Could you give us a brief summary of what worked? > > Also, I've been thinking for a while about how to do HTML like layouts > (that is page layouts. You could say this is like HTML, or you could say it > is like print layouts that you might find in Adobe InDesign) in Swing. I've > thought both about doing a custom LayoutManager, using a JEditorPane. The > idea is to support not just wrapping text, but flowing text. Imagine a > JComponent subclass that writes text in the background. But it does it such > that if a child component is on the FlowingTextComponent, the text will > either flow around the image, overwrite the image, or the image would > obscure the text (depending on some layout constraints). > > It's a fuzzy idea, but something I've had on a low priority thread for a > couple weeks now. > > Overkill for what you're doing, though  > > Richard > [Message sent by forum member 'rbair' (rbair)] > > http://forums.java.net/jive/thread.jspa?messageID=152378 > > --------------------------------------------------------------------- > To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net > For additional commands, e-mail: jdnc-help@jdnc.dev.java.net > > [att1.html]
|
|
|
|
|
|
|
|
Re: multiline label
Posted:
Sep 13, 2006 11:07 AM
in response to: Bill Snyder
|
|
|
> Embedding objects in text* > > Using TextLayout and StyledText, it is now possible > to embed objects such as > images or widgets inside text. Glyph metrics such as > ascent, descent and > width can be specified. Objects wrap with the text.
Without having read the API beyond this description, it sounds like the same mechanism we use with JEditorPane/JTextPane. You can also embed arbitrary components in either of those text components. Or are they actually using a TextLayout LayoutManager?
|
|
|
|
|
|
|
|
Re: multiline label
Posted:
Sep 13, 2006 11:09 AM
in response to: rbair
|
|
|
> > Embedding objects in text* > > > > Using TextLayout and StyledText, it is now > possible > > to embed objects such as > > images or widgets inside text. Glyph metrics such > as > > ascent, descent and > > width can be specified. Objects wrap with the > text. > > Without having read the API beyond this description, > it sounds like the same mechanism we use with > JEditorPane/JTextPane. You can also embed arbitrary > components in either of those text components. Or are > they actually using a TextLayout LayoutManager?
Actually, reading the code, it does look like it may be a LayoutManager after all.
Richard
|
|
|
|
|
|
|
|
Re: multiline label
Posted:
Sep 13, 2006 11:12 AM
in response to: rbair
|
|
|
The TextLayout mentioned here is not the AWT TextLayout, though it looks like it may have some similarities. I did not know you could embed components in JEditorPane. But lo and behold there is demo on the Swing tutorial...<http://
On 9/13/06, jdnc-interest@javadesktop.org <jdnc-interest@javadesktop.org> wrote: > > > Embedding objects in text* > > > > Using TextLayout and StyledText, it is now possible > > to embed objects such as > > images or widgets inside text. Glyph metrics such as > > ascent, descent and > > width can be specified. Objects wrap with the text. > > Without having read the API beyond this description, it sounds like the > same mechanism we use with JEditorPane/JTextPane. You can also embed > arbitrary components in either of those text components. Or are they > actually using a TextLayout LayoutManager? > [Message sent by forum member 'rbair' (rbair)] > > http://forums.java.net/jive/thread.jspa?messageID=152782 > > --------------------------------------------------------------------- > To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net > For additional commands, e-mail: jdnc-help@jdnc.dev.java.net > > [att1.html]
|
|
|
|
|
|
|
|
Re: multiline label
Posted:
Sep 12, 2006 7:14 PM
in response to: rbair
|
|
|
I've been thinking about much the same idea for a while now as well. I think layout management is one of the two or three things that new developers really have the most trouble with (we've recently discussed another of those in another thread)
The answer I'm coming up with is fairly radical: eliminate (or de-emphasize) the layout manager and adopt a page metaphor rather than a composite component metaphor. What seems to be working well for millions of authors is a document approach rather than a component approach.
I don't think describing Swing as it stands now is really the answer: most of the XML based swing managers require that the author understand Swing as it is currently designed and used -- might be fine for those of us who've aready climbed the learning curve, but little or no help for others.
I'm probably a little outside of what we could really do as a reasonable answer in the context of this project group. Where we might hit a middle ground is with a layout approach that may have come out few months ago:
http://jalbum.net/api/se/datadosen/component/RiverLayout.html
I think the basic idea of laying out the UI using a markup document gets one step closer to what you're thinking. We'd need to also account for fairly rich text flowing between and around the JComponents in the layout.
--- jdnc-interest@javadesktop.org wrote:
> > OK, well, tried again, fiddling with the (group) > > layout manager. Wrapping > > the text in an <html></html> block seemed to work. > > Could you give us a brief summary of what worked? > > Also, I've been thinking for a while about how to do > HTML like layouts (that is page layouts. You could > say this is like HTML, or you could say it is like > print layouts that you might find in Adobe InDesign) > in Swing. I've thought both about doing a custom > LayoutManager, using a JEditorPane. The idea is to > support not just wrapping text, but flowing text. > Imagine a JComponent subclass that writes text in > the background. But it does it such that if a child > component is on the FlowingTextComponent, the text > will either flow around the image, overwrite the > image, or the image would obscure the text > (depending on some layout constraints). > > It's a fuzzy idea, but something I've had on a low > priority thread for a couple weeks now. > > Overkill for what you're doing, though  >
__________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
--------------------------------------------------------------------- To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net For additional commands, e-mail: jdnc-help@jdnc.dev.java.net
|
|
|
|
|
|
|
|
Re: multiline label
Posted:
Sep 12, 2006 7:17 PM
in response to: David Hall
|
|
|
Now that I've read ahead in the thread, it appears to not be that unusual an idea after all.
( I might have to switch to a digest view <g> )
--- David Hall <davidahall@yahoo.com> wrote:
> I've been thinking about much the same idea for a > while now as well. I think layout management is one > of the two or three things that new developers > really > have the most trouble with (we've recently discussed > another of those in another thread) > > The answer I'm coming up with is fairly radical: > eliminate (or de-emphasize) the layout manager and > adopt a page metaphor rather than a composite > component metaphor. What seems to be working well > for > millions of authors is a document approach rather > than > a component approach. > > I don't think describing Swing as it stands now is > really the answer: most of the XML based swing > managers require that the author understand Swing as > it is currently designed and used -- might be fine > for > those of us who've aready climbed the learning > curve, > but little or no help for others. > > I'm probably a little outside of what we could > really > do as a reasonable answer in the context of this > project group. Where we might hit a middle ground > is > with a layout approach that may have come out few > months ago: > > http://jalbum.net/api/se/datadosen/component/RiverLayout.html > > I think the basic idea of laying out the UI using a > markup document gets one step closer to what you're > thinking. We'd need to also account for fairly rich > text flowing between and around the JComponents in > the > layout. > > --- jdnc-interest@javadesktop.org wrote: > > > > OK, well, tried again, fiddling with the (group) > > > layout manager. Wrapping > > > the text in an <html></html> block seemed to > work. > > > > Could you give us a brief summary of what worked? > > > > Also, I've been thinking for a while about how to > do > > HTML like layouts (that is page layouts. You could > > say this is like HTML, or you could say it is like > > print layouts that you might find in Adobe > InDesign) > > in Swing. I've thought both about doing a custom > > LayoutManager, using a JEditorPane. The idea is to > > support not just wrapping text, but flowing text. > > Imagine a JComponent subclass that writes text in > > the background. But it does it such that if a > child > > component is on the FlowingTextComponent, the text > > will either flow around the image, overwrite the > > image, or the image would obscure the text > > (depending on some layout constraints). > > > > It's a fuzzy idea, but something I've had on a low > > priority thread for a couple weeks now. > > > > Overkill for what you're doing, though  > > > > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam > protection around > http://mail.yahoo.com > > --------------------------------------------------------------------- > To unsubscribe, e-mail: > jdnc-unsubscribe@jdnc.dev.java.net > For additional commands, e-mail: > jdnc-help@jdnc.dev.java.net > >
__________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
--------------------------------------------------------------------- To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net For additional commands, e-mail: jdnc-help@jdnc.dev.java.net
|
|
|
|
|
|
|
|
Re: multiline label
Posted:
Sep 12, 2006 7:23 PM
in response to: David Hall
|
|
|
Back on the forum side (sorry about all the excess quoted mail text, everyone).
In my mind, I'd been cooking the idea as a sort of 'Java Client Pages' thing. It's markup to the author with embedded swing components, with some sort of scripting layer describing all of the binding, validation, event handling, and all of the other glue code that makes a rich application work.
|
|
|
|
|
|
|
|
Re: multiline label
Posted:
Sep 12, 2006 7:37 PM
in response to: david_hall
|
|
|
Ha. I like JAlbum, how did you come about looking at the codebase and seeing the RiverLayout?
Anyway, 'JCP' (oh wait, that acronym is already taken) is an interesting idea. Reminds me of the legacy JDNC markup goals, with the addition of a layout definition. Hmm.
On 9/12/06, jdnc-interest@javadesktop.org <jdnc-interest@javadesktop.org> wrote: > > Back on the forum side (sorry about all the excess quoted mail text, > everyone). > > In my mind, I'd been cooking the idea as a sort of 'Java Client Pages' > thing. It's markup to the author with embedded swing components, with some > sort of scripting layer describing all of the binding, validation, event > handling, and all of the other glue code that makes a rich application work. > [Message sent by forum member 'david_hall' (david_hall)] > > http://forums.java.net/jive/thread.jspa?messageID=152449 > > --------------------------------------------------------------------- > To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net > For additional commands, e-mail: jdnc-help@jdnc.dev.java.net > > [att1.html]
|
|
|
|
|
|
|
|
Re: multiline label
Posted:
Sep 13, 2006 5:24 AM
in response to: Bill Snyder
|
|
|
>> how did you come about looking at the codebase and seeing the RiverLayout?
I got the link directly to it either on java.net or one of the link/blog aggregators a few months ago. I've never looked at the app/library in general, but had filed away the basic layout idea in some dusty mental filing cabinet.
|
|
|
|
|