pessoal peguei uns códigos na net e deram alguns erros, o código está identico ao da apostila. Alguem poderia me ajudar? vlw…
importjavax.swing.*;importjava.awt.*;publicclassExemploLabelextendsJFrame{JLabelrotulo1,rotulo2,rotulo3,rotulo4;publicExemploLabel(){super("Exemplo com Label");Containertela=getContentPane();setLayout(null);rotulo1=newJLabel("Nome");rotulo2=newJLabel("Idade");rotulo3=newJLabel("Telefone");rotulo4=newJLabel("Celular");rotulo1.setBounds(50,20,80,20);rotulo2.setBounds(50,60,80,20);rotulo3.setBounds(50,100,80,20);rotulo4.setBounds(50,140,80,20);rotulo1.setForeground(Color.red);rotulo2.setForeground(Color.blue);rotulo3.setForeground(newColor(190,152,142));rotulo4.setForeground(newColor(201,200,100));rotulo1.setFont(newFont("Arial",Font.BOLD,14));rotulo2.setFont(newFont("Comic Sans MS",Font.BOLD,16));rotulo3.setFont(newFont("Courier New",Font.BOLD,18));rotulo4.setFont(newFont("Times New Roman",Font.BOLD,20));tela.add(rotulo1);tela.add(rotulo2);tela.add(rotulo3);tela.add(rotulo4);setSize(400,250);setVisible(true);setLocationRelativeTo(null);}publicstaticvoidmain(Stringargs[]){ExemploLabelapp=newExemploLabel();app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);}
Bom amigo, peguei o seu código e só tava faltando um parenteses.
tenta esse ai:
importjavax.swing.*;importjava.awt.*;publicclassExemploLabelextendsJFrame{JLabelrotulo1,rotulo2,rotulo3,rotulo4;publicExemploLabel(){super("Exemplo com Label");Containertela=getContentPane();setLayout(null);rotulo1=newJLabel("Nome");rotulo2=newJLabel("Idade");rotulo3=newJLabel("Telefone");rotulo4=newJLabel("Celular");rotulo1.setBounds(50,20,80,20);rotulo2.setBounds(50,60,80,20);rotulo3.setBounds(50,100,80,20);rotulo4.setBounds(50,140,80,20);rotulo1.setForeground(Color.red);rotulo2.setForeground(Color.blue);rotulo3.setForeground(newColor(190,152,142));rotulo4.setForeground(newColor(201,200,100));rotulo1.setFont(newFont("Arial",Font.BOLD,14));rotulo2.setFont(newFont("Comic Sans MS",Font.BOLD,16));//faltava um parenteses nessa linha!!rotulo3.setFont(newFont("Courier New",Font.BOLD,1));rotulo4.setFont(newFont("Times New Roman",Font.BOLD,20));tela.add(rotulo1);tela.add(rotulo2);tela.add(rotulo3);tela.add(rotulo4);setSize(400,250);setVisible(true);setLocationRelativeTo(null);}publicstaticvoidmain(Stringargs[]){ExemploLabelapp=newExemploLabel();app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);}}
T
Thiago_Domingues
nao amigo essa linha é assim:
rotulo3.setFont(new Font(“Courier New”,Font.BOLD,18 )); // é que a escrita foi transformada em emoticon
Com o seu código aconteceu a mesma coisa. será talvez erro do JCreator?
quando mando compilar td ok, mas qdo mando rodar o projeto da esse erro.
T
Thiago_Domingues
alguem tem mais alguma idéia do que possa estar acontecendo?
cs.santos0
Cara, aki quando rodei, funcionou perfeitamente.
acho que é o seu JCreator
flw
T
Thiago_Domingues
sei lá intaum…o importante é q o código está certo…vou testar em outro IDE…vlw…