Olá amigos, preciso criar uma tela de apresentação para um trabalho, que na verdade ja está criada, mas não consigo colocar vários nomes dentro desta tela sendo que teria que ficar um em baixo do outro. Tentei usar o \n mas não funcionou. Alguem poderia me ajudar nesta formatação do texto? Obrigado.
Vejam o código:
[code]import java.awt.;
import javax.swing.;
class Teste extends JFrame {
FontMetrics fm;
String s = “APENAS TESTES”;
// JOSE
// RODRIGO
// ANTONIO
public Teste() {
setTitle(“TESTES- APRESENTAÇÃO”);
Font font = new Font(“Jokerman”, Font.ITALIC, 36);
setFont(font);
fm = getFontMetrics(font);
setSize(fm.stringWidth(s)+30, fm.getHeight()+60);
setVisible(true);
setSize(550, 550);
setResizable(false);
setLocationRelativeTo(null);
}
public void paint(Graphics g) {
Insets ins = getInsets();
int w = getSize().width-ins.left-ins.right;
int h = getSize().height-ins.top-ins.bottom;
int centerX = w/2 + ins.left;
int centerY = h/2 + ins.top;
g.setColor(Color.red);
g.fillRect(ins.left, ins.top, w, h);
g.setColor(Color.yellow);
g.drawString(
s,
centerX-fm.stringWidth(s)/2,
centerY + (fm.getAscent()-fm.getDescent())/2
);
}
static public void main(String[] args) {
new Teste();
}
}[/code]