Ajuda urgente!

3 respostas
Rodrigoalvis
import java.awt.BorderLayout;

import java.awt.FlowLayout;

import java.awt.GridLayout;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;
import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.JPanel;

import javax.swing.JRadioButton;

import javax.swing.JRootPane;

import javax.swing.JTextArea;

public class Teste2 extends JFrame implements ActionListener{

JPanel p;
JPanel p2,p3,p4,p5;
JLabel  lPergunta1,lPergunta2,lPergunta3,lPergunta4,lPergunta5,lPergunta6,lPergunta7,lPergunta8,lPergunta9,lPergunta10,lPergunta11,lPergunta12,lPergunta13,lPergunta14,lPergunta15,lPergunta16,lPergunta17,lPergunta18,lPergunta19,lPergunta20,lResposta;
JRadioButton rCerto,rErrado,r2Certo,r2Errado,r3Certo,r3Errado,r4Certo,r4Errado;
public Teste2 (){

super(Teste Que tipo de cabeça você tem.);

setSize(280,330);

getRootPane().setWindowDecorationStyle(JRootPane.FRAME);

setUndecorated(true);

setLocation(250,250);

p=new JPanel();

p2 = new JPanel();

p3 = new JPanel();

p4 = new JPanel();

p5 = new JPanel();

lPergunta1=new JLabel (1 - Censurar programas de televisão em que apareçam cenas de sexo e violência é uma dever do governo.);

rCerto = new JRadioButton(Certo);

rErrado = new JRadioButton(Errado);

lPergunta2=new JLabel (2 - O fornecimento de energia elétrica deveria ser de responsabilidade exclusiva do estado.);

r2Certo = new JRadioButton(Certo);

r2Errado = new JRadioButton(Errado);

lPergunta3 = new JLabel(3 - O sistema bancário deveria ser estatal.);

r3Certo = new JRadioButton(Certo);

r3Errado = new JRadioButton(Errado);

lPergunta4 = new JLabel(4 - Cabe ao governo cuidar do que é público.);

r4Certo = new JRadioButton(Certo);

r4Errado = new JRadioButton(Errado);

p.setLayout(new GridLayout (4,2));

p2.setLayout(new GridLayout (4,2));

p3.setLayout(new GridLayout (4,2));

p4.setLayout(new GridLayout (4,2));

p.setLayout(new FlowLayout(FlowLayout.LEFT));

p.add(lPergunta1);

p.add(rCerto);

p.add(rErrado);

p2.add(lPergunta2);

p2.add(r2Certo);

p2.add(r2Errado);

p3.add(lPergunta3);

p3.add(r3Certo);

p3.add(r3Errado);

p4.add(lPergunta4);

p4.add(r4Certo);

p4.add(r4Errado);

getContentPane().add(p,BorderLayout.CENTER);

getContentPane().add(p2,BorderLayout.SOUTH);

getContentPane().add(p3,BorderLayout.CENTER);

getContentPane().add(p4,BorderLayout.SOUTH);

pack();

setVisible(true);

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}

public static void main(String args[]){

new Teste2();

}
public void actionPerformed(ActionEvent evento) {
	// TODO Auto-generated method stub

}

}


Quando executa aparece somente as duas ultimas perguntas.Queria saber saber qual é o erro.

3 Respostas

ViniGodoy

Comece por aqui:
http://www.guj.com.br/posts/list/50115.java

Rodrigoalvis

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JRootPane;
import javax.swing.JTextArea;

public class Teste2 extends JFrame implements ActionListener{

JPanel p;
JPanel p2,p3,p4,p5;
JLabel lPergunta1,lPergunta2,lPergunta3,lPergunta4,lPergunta5,lPergunta6,lPergunta7,lPergunta8,lPergunta9,lPergunta10,lPergunta11,lPergunta12,lPergunta13,lPergunta14,lPergunta15,lPergunta16,lPergunta17,lPergunta18,lPergunta19,lPergunta20,lResposta;
JRadioButton rCerto,rErrado,r2Certo,r2Errado,r3Certo,r3Errado,r4Certo,r4Errado;
public Teste2 (){
super("Teste Que tipo de cabeça você tem.");
setSize(280,330);
getRootPane().setWindowDecorationStyle(JRootPane.FRAME);
setUndecorated(true);
setLocation(250,250);
p=new JPanel();
p2 = new JPanel();
p3 = new JPanel();
p4 = new JPanel();
p5 = new JPanel();
lPergunta1=new JLabel ("1 - Censurar programas de televisão em que apareçam cenas de sexo e violência é uma dever do governo.");
rCerto = new JRadioButton("Certo");
rErrado = new JRadioButton("Errado");
lPergunta2=new JLabel ("2 - O fornecimento de energia elétrica deveria ser de responsabilidade exclusiva do estado.");
r2Certo = new JRadioButton("Certo");
r2Errado = new JRadioButton("Errado");
lPergunta3 = new JLabel("3 - O sistema bancário deveria ser estatal.");
r3Certo = new JRadioButton("Certo");
r3Errado = new JRadioButton("Errado");
lPergunta4 = new JLabel("4 - Cabe ao governo cuidar do que é público.");
r4Certo = new JRadioButton("Certo");
r4Errado = new JRadioButton("Errado");
p.setLayout(new GridLayout (4,2));
p2.setLayout(new GridLayout (4,2));
p3.setLayout(new GridLayout (4,2));
p4.setLayout(new GridLayout (4,2));
p.setLayout(new FlowLayout(FlowLayout.LEFT));
p.add(lPergunta1);
p.add(rCerto);
p.add(rErrado);
p2.add(lPergunta2);
p2.add(r2Certo);
p2.add(r2Errado);
p3.add(lPergunta3);
p3.add(r3Certo);
p3.add(r3Errado);
p4.add(lPergunta4);
p4.add(r4Certo);
p4.add(r4Errado);
getContentPane().add(p,BorderLayout.CENTER);
getContentPane().add(p2,BorderLayout.SOUTH);
getContentPane().add(p3,BorderLayout.CENTER);
getContentPane().add(p4,BorderLayout.SOUTH);
pack();
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String args[]){
new Teste2();
}

public void actionPerformed(ActionEvent evento) {
// TODO Auto-generated method stub

}

[code]

L

Então, deixe seu código certo com as tags corretas, conforme o post enviado pelo ViniGodoy, muito bem explicado pelo Mantu, no caso abaixo eu coloquei antes de iniciar o fonte, as tags code abrindo e fechando o texto, assim fica muito mais claro e fácil de entender…
Segue seu código formatado…

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JRootPane;
import javax.swing.JTextArea;



public class Teste2 extends JFrame implements ActionListener{

JPanel p;
JPanel p2,p3,p4,p5;
JLabel lPergunta1,lPergunta2,lPergunta3,lPergunta4,lPergunta5,lPergunta6,lPergunta7,lPergunta8,lPergunta9,lPergunta10,lPergunta11,lPergunta12,lPergunta13,lPergunta14,lPergunta15,lPergunta16,lPergunta17,lPergunta18,lPergunta19,lPergunta20,lResposta;
JRadioButton rCerto,rErrado,r2Certo,r2Errado,r3Certo,r3Errado,r4Certo,r4Errado;
public Teste2 (){
super("Teste Que tipo de cabeça você tem.");
setSize(280,330);
getRootPane().setWindowDecorationStyle(JRootPane.FRAME);
setUndecorated(true);
setLocation(250,250);
p=new JPanel();
p2 = new JPanel();
p3 = new JPanel();
p4 = new JPanel();
p5 = new JPanel();
lPergunta1=new JLabel ("1 - Censurar programas de televisão em que apareçam cenas de sexo e violência é uma dever do governo.");
rCerto = new JRadioButton("Certo");
rErrado = new JRadioButton("Errado");
lPergunta2=new JLabel ("2 - O fornecimento de energia elétrica deveria ser de responsabilidade exclusiva do estado.");
r2Certo = new JRadioButton("Certo");
r2Errado = new JRadioButton("Errado");
lPergunta3 = new JLabel("3 - O sistema bancário deveria ser estatal.");
r3Certo = new JRadioButton("Certo");
r3Errado = new JRadioButton("Errado");
lPergunta4 = new JLabel("4 - Cabe ao governo cuidar do que é público.");
r4Certo = new JRadioButton("Certo");
r4Errado = new JRadioButton("Errado");
p.setLayout(new GridLayout (4,2));
p2.setLayout(new GridLayout (4,2));
p3.setLayout(new GridLayout (4,2));
p4.setLayout(new GridLayout (4,2));
p.setLayout(new FlowLayout(FlowLayout.LEFT));
p.add(lPergunta1);
p.add(rCerto);
p.add(rErrado);
p2.add(lPergunta2);
p2.add(r2Certo);
p2.add(r2Errado);
p3.add(lPergunta3);
p3.add(r3Certo);
p3.add(r3Errado);
p4.add(lPergunta4);
p4.add(r4Certo);
p4.add(r4Errado);
getContentPane().add(p,BorderLayout.CENTER);
getContentPane().add(p2,BorderLayout.SOUTH);
getContentPane().add(p3,BorderLayout.CENTER);
getContentPane().add(p4,BorderLayout.SOUTH);
pack();
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String args[]){
new Teste2();
}

public void actionPerformed(ActionEvent evento) {
// TODO Auto-generated method stub

}

Resta agora sabermos qual seria sua dúvida…pois o assunto não esclarece muito bem, nem o corpo da mensagem…

Abraços…

Criado 17 de outubro de 2009
Ultima resposta 19 de out. de 2009
Respostas 3
Participantes 3