Ajuda com Jogo

3 respostas
B
package inicio;  
  
import java.awt.BorderLayout;  
import java.awt.EventQueue;  
  
import javax.swing.JFrame;  
import javax.swing.JPanel;  
import javax.swing.border.EmptyBorder;  
import javax.swing.JLabel;  
import javax.swing.JComboBox;  
import javax.swing.JTextField;  
import javax.swing.JButton;  
import javax.swing.DefaultComboBoxModel;  
  
public class start extends JFrame {  
  
   private JPanel contentPane;  
   private JTextField tf_nome;  
     
  
   /** 
    * Launch the application. 
    */  
   public static void main(String[] args) {  
      EventQueue.invokeLater(new Runnable() {  
         public void run() {  
            try {  
               start frame = new start();  
               frame.setVisible(true);  
            } catch (Exception e) {  
               e.printStackTrace();  
            }  
         }  
      });  
   }  
  
   /** 
    * Create the frame. 
    */  
   public start() {  
        
      setTitle("RPG");  
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);  
      setBounds(100, 100, 344, 344);  
      contentPane = new JPanel();  
      contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));  
      setContentPane(contentPane);  
      contentPane.setLayout(null);  
        
      JLabel lblEscolhaSuaClasse = new JLabel("Escolha sua classe");  
      lblEscolhaSuaClasse.setBounds(25, 55, 106, 14);  
      contentPane.add(lblEscolhaSuaClasse);  
        
      JLabel lblEscolhaSuaRaa = new JLabel("Escolha sua ra\u00E7a");  
      lblEscolhaSuaRaa.setBounds(25, 124, 106, 14);  
      contentPane.add(lblEscolhaSuaRaa);  
        
      JLabel lblDigiteSeuNome = new JLabel("Digite seu nome");  
      lblDigiteSeuNome.setBounds(25, 193, 106, 14);  
      contentPane.add(lblDigiteSeuNome);  
        
      JComboBox cb_classe = new JComboBox();  
      cb_classe.setModel(new DefaultComboBoxModel(new String[] {"", "Mago", "Guerreiro", "Arqueiro"}));  
      cb_classe.setBounds(172, 52, 116, 20);  
      contentPane.add(cb_classe);  
        
      if(cb_classe.equals("Mago")){  
         JComboBox cb_raca = new JComboBox();  
         cb_raca.setModel(new DefaultComboBoxModel(new String[] {"","Halfling", "Elfo", "Humano"}));  
         cb_raca.setBounds(172, 121, 116, 20);  
         contentPane.add(cb_raca);  
         }  
      if(cb_classe.equals("Guerreiro")){  
         JComboBox cb_raca = new JComboBox();  
         cb_raca.setModel(new DefaultComboBoxModel(new String[] {"","An\u00E3o", "Orc", "Humano"}));  
         cb_raca.setBounds(172, 121, 116, 20);  
         contentPane.add(cb_raca);  
         }  
        
      if(cb_classe.equals("Arqueiro")){  
         JComboBox cb_raca = new JComboBox();  
         cb_raca.setModel(new DefaultComboBoxModel(new String[] {"","Elfo", "Halfling", "Humano"}));  
         cb_raca.setBounds(172, 121, 116, 20);  
         contentPane.add(cb_raca);  
         }  
        
      JComboBox cb_raca = new JComboBox();  
      cb_raca.setModel(new DefaultComboBoxModel(new String[] {"", "Halfling", "Elfo", "Meio-Elfo", "An\u00E3o", "Orc", "Humano"}));  
      cb_raca.setBounds(172, 121, 116, 20);  
      contentPane.add(cb_raca);  
        
      tf_nome = new JTextField();  
      tf_nome.setBounds(172, 190, 116, 20);  
      contentPane.add(tf_nome);  
      tf_nome.setColumns(10);  
        
      JButton btnStart = new JButton("Come\u00E7ar");  
      btnStart.setBounds(25, 248, 263, 23);  
      contentPane.add(btnStart);  
   }  
  
}

3 Respostas

InicianteJavaHenriqu

E qual é o problema :?:

:thumbup:

B
ainda não recebia a historia do jogo, meu companheiro a esta criando.

O problema é que eu quero que quando a pessoa escolha a classe apareça por exemplo:

Se a pessoa escolher mago;

na combo box da raça apareça so halfling, elfo, humano

Se escolher guerreiro;

So aparecer na combo box da raça humano, anão,orc

Se escolher arqueiro;

So aparecer na combo box  da raça humano, meio-elfo, halfling
ViniGodoy

Tópico movido para o fórum de interface gráfica.
Por favor, leia com atenção a lista de fóruns antes de postar.

Criado 15 de julho de 2012
Ultima resposta 15 de jul. de 2012
Respostas 3
Participantes 3