Erros encontrados em Linhas de Comando

[code]import java.lang.Math;
import javax.swing.JOptionPane;

public class adivinhar extends javax.swing.JFrame {
public adivinhar(){
initComponents(); }

int segredo, tentativa;
private void initComponents(){
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabl();
SNumero = new javax.swing.JSpinner();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle(“Jogo Do Adivinhar”);
jPanel1.setLayout(null);

jLabel1.setText(“N\u00famero”);
jPanel1.add(jLabel);
JLabel1.setBounds(30,20,52,15);

SNumero.setAlignmentX(1.0F);
SNumero.setAlignmentY(1.0F);
SNumero.setAutoscrolls(true);
SNumero.setDoubleBuffered(true);
SNumero.setFocusable(false);
jPanel1.add(SNumero);
SNumero.setBounds(90,20,60,20);

jButton1.setText(“Iniciar”);
jButton1.addActionListener(new java.awt.event.ActionListener(){

public void actionPerformed(java.awt.event.ActionEvent evt){
jButton1ActionPerformed(evt); } });

jPanel1.add(jButton1);
jButton1.setBounds(10,50,72,25);

jButton2.setText(“Testar”);
jBUtton2.addActionListener(new java.awt.event.ActionListener(){

public void actionPerformed(java.awt.event.ActionEvent evt){
jButton2ActionPerformed(evt); } });

jPanel1.add(jButton2);
jButton2.setBounds(90,50,73,25);

getContentPane().add(jPanel1.java.awt.BorderLayout.CENTER);

java.awt.Dimension screenSize = java.awt.Tollkit.getDefaultToolkit().getScreenSize();
setBounds((screenSize.width-178)/2, (screenSize.height-114)/2,178,114); }

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt){
tentativa=SNumero.getValue().hashCode();
if(segredo>tentativa){
JOptionPane.showMessageDialog(null, “Tente um Número maior”);
}else if(segredo<tentativa){
JOptionPane.showMessageDialog(null, “Tente um Número menor”);
}else if(segredo==tentativa){
JOptinoPane.showMessageDialog(null, “Parabéns”); } }

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt){
segredo = (int)(Math.random()*10);

public static void main(String args[]){
java.awt.EventQueue.invokeLater(new Runnable(){
public void run(){
new adivinhar().setVisible(true);
} }); }

private javax.swing.JSpinner SNumero;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JLabel jLabel1;
private javax.swing.JPanel jPanel1;
}[/code]

Erro nas linhas: 67, 74, 75, 76, 77 e 78

Gostaria que alguém me explicasse os erros que estão ocorrendo nas linhas…
Vlw…

Ajuda muito se você escrever o texto dos erros aqui…

Também ajudaria muito se vc formatasse corretamente o código ali em cima…
colocando a identação correta.

teste.java:4: ‘{’ expected
public class adivinhar extends javax.swing.JFrame
^
teste.java:67: illegal start of expression
public static void main(String args[]){
^
teste.java:74: illegal start of expression
private javax.swing.JButton jButton1;
^
teste.java:75: illegal start of expression
private javax.swing.JButton jButton2;
^
teste.java:76: illegal start of expression
private javax.swing.JLabel jLabel1;
^
teste.java:77: illegal start of expression
private javax.swing.JPanel jPanel1;
^
teste.java:78: reached end of file while parsing
}
^
7 errors

É isso que aparece…

Não entendi “identação correta”
vlw

Me diz uma coisa… se o pessoal já está te ajudando nesse tópico:
http://www.guj.com.br/posts/list/30/98030.java

Por que abriu outro tópico? É melhor continuar postando suas dúvidas por lá!

Evite a duplicação desnecessária de tópicos, ok? :wink:
Aí nem você e nem nós precisaremos ficar vigiando em 2 lugares diferentes. :roll:

A identação envolve dar espaços no código quando um comando estiver subordinado a outro (basicamente, quando vc abrir chaves). Com seu código reto do jeito que está, é muito difícil ver onde os comandos começam e terminam.

Vou postar o seu código novamente, identado da maneira correta:

[code]
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JSpinner;

public class Adivinhar extends JFrame {
private int segredo;
private int tentativa;
private JSpinner SNumero;
private JButton jButton1;
private JButton jButton2;
private JLabel jLabel1;
private JPanel jPanel1;

public Adivinhar() {
    initComponents();
}

private void initComponents() {
    jPanel1 = new JPanel();
    jLabel1 = new JLabel();
    SNumero = new JSpinner();
    jButton1 = new JButton();
    jButton2 = new JButton();

    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setTitle("Jogo Do Adivinhar");
    jPanel1.setLayout(null);

    jLabel1.setText("N\u00famero");
    jPanel1.add(jLabel1); //Essa variável chama-se jLabel1, não jlabel
    jLabel1.setBounds(30, 20, 52, 15); //Cuidado o j é minúsculo

    SNumero.setAlignmentX(1.0F);
    SNumero.setAlignmentY(1.0F);
    SNumero.setAutoscrolls(true);
    SNumero.setDoubleBuffered(true);
    SNumero.setFocusable(false);
    jPanel1.add(SNumero);
    SNumero.setBounds(90, 20, 60, 20);

    jButton1.setText("Iniciar");
    jButton1.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            jButton1ActionPerformed(evt);
        }
    });

    jPanel1.add(jButton1);
    jButton1.setBounds(10, 50, 72, 25);

    jButton2.setText("Testar");
    jButton2.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            jButton2ActionPerformed(evt);
        }
    });

    jPanel1.add(jButton2);
    jButton2.setBounds(90, 50, 73, 25);

    getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);

    java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
    setBounds((screenSize.width - 178) / 2, (screenSize.height - 114) / 2, 178, 114);
}

private void jButton2ActionPerformed(ActionEvent evt) {
    tentativa = SNumero.getValue().hashCode();
    if (segredo > tentativa) {
        JOptionPane.showMessageDialog(null, "Tente um Número maior");
    } else if (segredo < tentativa) {
        JOptionPane.showMessageDialog(null, "Tente um Número menor");
    } else if (segredo == tentativa) {
        JOptionPane.showMessageDialog(null, "Parabéns");
    }
}

private void jButton1ActionPerformed(ActionEvent evt) {
    segredo = (int) (Math.random() * 10);
} //Você tinha esquecido de fechar chaves aqui

public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {
        public void run() {
            new Adivinhar().setVisible(true);
        }
    });
}

}[/code]

Você pode identar código apertando as teclas ALT+SHIFT+F no Netbeans ou CTRL+SHIFT+F no Eclipse.

Notou que é muito mais fácil ver onde as coisas começam e terminam agora? Note que no código faltava fechar chaves uma vez. Isso ficou claramente visível com a identação do código, mas é muito difícil de ver sem a identação. Por isso ela é tão importante.

Eu também ajeitei o nome da classe de adivinha para Adivinha, como tinham te instruído no outro tópico. É muito importante seguir as convenções de código do Java. Preste mais atenção da próxima vez.

Você também tinha cometido uma série de erros de digitação:
Por exemplo, escreveu Tollkit no lugar de Toolkit, trocou algumas letras de lugar no nome de algumas variáveis, confundiu maiúscula com minúscula, etc. Lembre-se: no Java jLabel1, JLabel1, JLABEL1, são variáveis completamente diferentes.

Esse código é realmente seu? Para alguém com algumas dúvidas tão básicas, você não deveria estar usando o Swing. Faça o que o pessoal sugeriu no outro tópico. Pegue umas apostilas de java básico (a da Caelum é uma ótima opção) e estude os conceitos! Vai ser de grande ajuda! :wink: