Example #1
0
  private void jButton1ActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButton1ActionPerformed

    try {
      interfaces op;
      op = (interfaces) Naming.lookup("rmi://localhost/persistencia");

      pre = op.buscaPregunta(Integer.parseInt(jTextField1.getText()));
      if (pre != null) {
        this.jLabel5.setText(Integer.toString(pre.getIdpregunta()));
        this.jTextField2.setText(pre.getPregunta());
        this.jTextField3.setText(pre.getRespuestacorrecta());
        this.jTextField1.setText("");
        Examen c;
        c = op.buscaExamen(pre.getExamen().getIdexamen());
        Materia t;
        t = op.buscaMateria(c.getMateria().getIdmateria());
        this.jComboBox1.setSelectedItem(
            exa.getIdexamen() + "-" + t.getNombre() + "-" + exa.getParcial());
        this.jTextField1.setText("");

      } else {
        JOptionPane.showMessageDialog(null, "No existe");
      }

    } catch (NotBoundException ex) {
      Logger.getLogger(PreguntasForm.class.getName()).log(Level.SEVERE, null, ex);
    } catch (MalformedURLException ex) {
      Logger.getLogger(PreguntasForm.class.getName()).log(Level.SEVERE, null, ex);
    } catch (RemoteException ex) {
      Logger.getLogger(PreguntasForm.class.getName()).log(Level.SEVERE, null, ex);
    }
  } // GEN-LAST:event_jButton1ActionPerformed
Example #2
0
  public PreguntasForm() {
    List lista_examenes_combo = new ArrayList();
    initComponents();
    try {
      interfaces op;
      op = (interfaces) Naming.lookup("rmi://localhost/persistencia");
      lista_examenes_combo = op.listaExamenes();
      for (int i = 0; i < lista_examenes_combo.size(); i++) {
        exa = (Examen) lista_examenes_combo.get(i);
        MateriaDAO edao = new MateriaDAO();
        Materia ma;
        ma = edao.buscar(exa.getMateria().getIdmateria());
        jComboBox1.addItem(exa.getIdexamen() + "-" + ma.getNombre() + "-" + exa.getParcial());
      }

    } catch (NotBoundException ex) {
      Logger.getLogger(PreguntasForm.class.getName()).log(Level.SEVERE, null, ex);
    } catch (MalformedURLException ex) {
      Logger.getLogger(PreguntasForm.class.getName()).log(Level.SEVERE, null, ex);
    } catch (RemoteException ex) {
      Logger.getLogger(PreguntasForm.class.getName()).log(Level.SEVERE, null, ex);
    }
  }