0
How do I make a jcombobox in this method? The Combobox would be the type the user is supposed to choose, I tried to make one but it didn’t work out very well. And this method is in my main class and how do I set in a Preparedstatement who is in a Dao class?
My method that is in the Main class
 public static void inserirEnderecoTeste(){
        Bean viagem = new Bean();
        Object[] opcoes = {"Um","Dois","Tres","Quatro"};  
        viagem.setTipo(JOptionPane.showInputDialog(null, "Escolha um item" , "Selecao de itens" ,  
         JOptionPane.PLAIN_MESSAGE , null ,opcoes,""));
        viagem.setDataInicio(DataHelper.StringToCalendar("dd/MM/yyyy", 
                JOptionPane.showInputDialog("Insira a data de inicio:\n(Deve ser no formato  DD/MM/YYYY)", "30/05/2015")));
        viagem.setDataFim(DataHelper.StringToCalendar("dd/MM/yyyy", 
                JOptionPane.showInputDialog("Insira a data de fim:\n(Deve ser no formato  DD/MM/YYYY)", "01/05/2015")));
        viagem.setCidade(JOptionPane.showInputDialog("Insira a cidade:"));
        viagem.setUf(JOptionPane.showInputDialog("Insira o bairro:"));
        viagem.setValorDiaria(new Double(JOptionPane.showInputDialog("Valor da diária:")));
        viagem.setColaborador(JOptionPane.showInputDialog("Insira um colaborador"));
        viagem.setCliente(JOptionPane.showInputDialog("Insira um cliente"));
        //vb.setCidade(JOptionPane.showInputDialog("Insira a cidade Destino:", "Angra dos Reis"));
        if (Dao.inserir(viagem)){
            JOptionPane.showMessageDialog(null, "Inseriu!");
        } else {
            JOptionPane.showMessageDialog(null, "Não Inseriu!");
        }
    }
 }
This is the class Dao where I’m supposed to set the jcombobox
public static boolean inserir(Bean endereco) {
        boolean executou = false;
        if (ConexaoMySQL.conectar()) {
            try {
                Connection con = ConexaoMySQL.getConexao();
                String sql = "Insert into viagem values (0,?,?,?,?,?,?,?,?)";
                PreparedStatement pstm = con.prepareStatement(sql);
        >>>>>>>     pstm.setString(1,endereco.getTipo()); <<<<<<<<<<<

http://docs.oracle.com/javase/7/docs/api/javax/swing/JComboBox.html#getSelectedItem%28%29
– ptkato