> It is possible, in awt, to have a phrase divided in more of one line? I
> want display in a Button this:
[quoted text clipped - 12 lines]
> line.separator")+"name");
> I see only strange characters, and not new lines.
Both of the JLabel and JButton classes in Swing support using HTML for
their string values. I've never used any AWT, so I can't say for
certain whether they do or not -- but I suspect that they do.
So to set up a JButton like you want, you could simply create a new
JButton like this:
JButton btn = new JButton("<html>save<br>with<br>name</html>");
The closing "html" tag isn't strictly necessary, but I consider it bad
form not to close the tag.
= Steve =

Signature
Steve W. Jackson
Montgomery, Alabama
Marco - 28 Mar 2005 20:03 GMT
> So to set up a JButton like you want, you could simply create a new
> JButton like this:
>
> JButton btn = new JButton("<html>save<br>with<br>name</html>");
I read this, but with a Button the result is:
<html>save<br>with<br>name</html>
and not:
save
with
name
I know that swing was wroten in awt, then I think that if I can do anything
with swing, I can do with awt to. Or not? And how?
> It is possible, in awt, to have a phrase divided in more of one line? I
> want display in a Button this:
You have to implement your very own button, or switch to Swing.
/Thomas

Signature
The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
Marco - 29 Mar 2005 17:07 GMT
> You have to implement your very own button
How?
Marco - 29 Mar 2005 18:39 GMT
>> You have to implement your very own button
> How?
import java.io.*;
import java.awt.*;
public class ButtonMultiline extends Button
{
String[] texts;
public ButtonMultiline(String[] t)
{
super();
texts=t;
}
public void paint(Graphics g)
{
super.paint(g);
Dimension d=this.getSize();
int dy=d.height/(texts.length+1)+1;
FontMetrics metricaFont = getFontMetrics(g.getFont());
for (int i=0;i<texts.length;i++)
{g.drawString(texts[i],(d.width-metricaFont.stringWidth(texts[i]))/2,dy/4+dy*(i+1));}
}
}