Ajuda

2 respostas
K

ola gente bom dia a todos!!

Gente Gostaria de saber se tem algum tutorial basico para o netBeans baixei junto com sdk 5.0.

além deste tenho outro problema no meu codigo la vai:

import java.awt.<em>;

import java.awt.event.</em>;

import javax.swing.<em>;

import java.Swing.event.</em>;

import java.util.*;

public class ProvaFinal extends WindowAdapter implements ActionListener{

public static void main(String[] args){//
Frame f=new Frame("Calculadora");//

f.setSize(200,200);//

f.setBackground(Color.gray);//

f.setLayout(new FlowLayout(FlowLayout.LEFT));//

Label label1 = new Label("Valor");//

Label label2 = new Label("Resultado");//

f.add(label1);//

f.add(label2);//

TextField t1=new TextField(10);//

TextField t2= new TextField(10);//

f.add(t1); //

f.add (t2);//

Button b1= new Button("ok");//

Button b2= new Button ("limpar");//

f.add(b1);//

f.add(b2);//

f.addWindowListener(new ProvaFinal ());//

f.setVisible(true);//
}

public void WindowClosing(WindowEvent e){

System.exit(0);//

}

}

:arrow: JTextField Resultado = new JTextField(10);//

:arrow: JButton b2 = new JButton ("Limpar");//

:arrow: b2.addActionListener(this);//

 :arrow: public void actionPerformed (ActionEvent e){//
  if(e.getSource()== b2){ //
  
    Resultado.setText(""); //

}

}

if(e.getSource()==b1){ //

Resultado.setText(OK);

}
if( e.get source()==b2){//
 valor.setText("limpar");}

onde está marcado esta erro de compilação classe ou interface esperado
alguns amigos do portal deram dicas boas das quais pela situação so um deu certo e agora gente me dêem uma luz neste tunel por favor!!

karlota
:cry:

2 Respostas

B

tudo que esta abaixo da 1º marcação esta fora do escopo da classe ! confere suas { ok ?
ve se funciona …

B

foi mal , esqueci do codigo …

import java.awt.*; 
import java.awt.event.*; 
import javax.swing.*; 
import java.Swing.event.*; 
import java.util.*; 
public class ProvaFinal extends WindowAdapter implements ActionListener&#123; 
public static void main&#40;String&#91;&#93; args&#41;&#123;// 

Frame f=new Frame&#40;"Calculadora"&#41;;// 

f.setSize&#40;200,200&#41;;// 

f.setBackground&#40;Color.gray&#41;;// 

f.setLayout&#40;new FlowLayout&#40;FlowLayout.LEFT&#41;&#41;;// 

Label label1 = new Label&#40;"Valor"&#41;;// 

Label label2 = new Label&#40;"Resultado"&#41;;// 

f.add&#40;label1&#41;;// 

f.add&#40;label2&#41;;// 

TextField t1=new TextField&#40;10&#41;;// 

TextField t2= new TextField&#40;10&#41;;// 

f.add&#40;t1&#41;; // 

f.add &#40;t2&#41;;// 

Button b1= new Button&#40;"ok"&#41;;// 

Button b2= new Button &#40;"limpar"&#41;;// 

f.add&#40;b1&#41;;// 

f.add&#40;b2&#41;;// 

f.addWindowListener&#40;new ProvaFinal &#40;&#41;&#41;;// 

f.setVisible&#40;true&#41;;// 
&#125; 
public void WindowClosing&#40;WindowEvent e&#41;&#123; 
System.exit&#40;0&#41;;// 
    JTextField Resultado = new JTextField&#40;10&#41;;// 
 
  JButton b2 = new JButton &#40;"Limpar"&#41;;// 
 
  b2.addActionListener&#40;this&#41;;// 

&#125; 
public void actionPerformed &#40;ActionEvent e&#41;&#123;// 
  if &#40;e.getSource&#40;&#41; == b2&#41; &#123; //

    Resultado.setText&#40;""&#41;; //
  &#125;

  if &#40;e.getSource&#40;&#41; == b1&#41; &#123; //
    Resultado.setText&#40;"OK"&#41;;
  &#125;

  if &#40;e.getSource&#40;&#41; == b2&#41; &#123; //
    valor.setText&#40;"limpar"&#41;;
  &#125;
&#125;

&#125;
Criado 22 de dezembro de 2004
Ultima resposta 22 de dez. de 2004
Respostas 2
Participantes 2