0

I have a problem with multiple jcombobox and a textarea

I can load all the information from different arraylist but when I want to show the information of the last jcombobox and print it in the textarea this only prints the first one and does not change.

    public void manejadordeleditoriales() {

    try {
        for (int i = 0; i < Editoriales.values().length; i++) {

            if (Editoriales.values()[i].toString() == this.getCargalibros()
                    .getcomboBox_editoriales().getSelectedItem().toString()) {

                this.getCargalibros().getComboBox_Isbn().removeAllItems();
                this.getCargalibros().getComboBox_Libros().removeAllItems();
                this.getCargalibros().getComboBox_Autores()
                        .removeAllItems();
                this.getCargalibros().getComboBox_Tema().removeAllItems();
                this.getCargalibros().getComboBox_SubTema()
                        .removeAllItems();
                this.getCargalibros().getComboBox_Glosario()
                        .removeAllItems();

                for (int j = 0; j < this.getLibros().size(); j++) {
                    if (this.getLibros().get(j).getEditorial().toString() == this
                            .getCargalibros().getcomboBox_editoriales()
                            .getSelectedItem().toString()) {
                        this.getCargalibros().getComboBox_Isbn()
                                .addItem(this.getLibros().get(j).getIsbn());
                        this.getCargalibros()
                                .getComboBox_Libros()
                                .addItem(
                                        this.getLibros().get(j).getTitulo());
                        this.getCargalibros()
                                .getComboBox_Autores()
                                .addItem(
                                        this.getLibros().get(j)
                                                .getAutores());

                    }
                }

            }

        }
        manejadordelibros();
    } catch (NullPointerException nu) {

        this.getCargalibros().getComboBox_Isbn().removeAllItems();
        this.getCargalibros().getComboBox_Isbn()
                .addItem("no hay datos para esta Editorial");

    }

    catch (IndexOutOfBoundsException a) {

        this.getCargalibros().getComboBox_Isbn().removeAllItems();
        this.getCargalibros().getComboBox_Isbn()
                .addItem("no hay datos para esta Editorial");
    }
}

public void manejadordelibros() {
    String[] tema = new String[this
            .getLibros()
            .get(this.getCargalibros().getComboBox_Libros()
                    .getSelectedIndex()).getTemas().size()];
    for (int i = 0; i < tema.length; i++) {
        tema[i] = this
                .getLibros()
                .get(this.getCargalibros().getComboBox_Libros()
                        .getSelectedIndex()).getTemas().get(i)
                .getTitulotema();
    }
    this.getCargalibros().getComboBox_Tema()
            .setModel(new DefaultComboBoxModel(tema));
    manejadordetemas();
}

public void manejadordetemas() {
    this.getCargalibros().getComboBox_SubTema().removeAllItems();
    String[] subtema = new String[this
            .getLibros()
            .get(this.getCargalibros().getComboBox_Libros()
                    .getSelectedIndex())
            .getTemas()
            .get(this.getCargalibros().getComboBox_Tema()
                .getSelectedIndex()).getSubtemas().size()];

    for (int i = 0; i < subtema.length; i++) {
        subtema[i] = this
                .getLibros()
                .get(this.getCargalibros().getComboBox_Libros()
                        .getSelectedIndex())
                .getTemas()
                .get(this.getCargalibros().getComboBox_Tema()
                        .getSelectedIndex()).getSubtemas().get(i)
                .getDenominacionSubtema();
    }
    this.getCargalibros().getComboBox_SubTema()
            .setModel(new DefaultComboBoxModel(subtema));
    manejadordesubtemas();
}

public void manejadordesubtemas() {
    try {

        this.getCargalibros().getComboBox_Glosario().removeAllItems();
        String[] definicion = new String[this
                .getLibros()
                .get(this.getCargalibros().getComboBox_Libros()
                        .getSelectedIndex())
                .getTemas()
                .get(this.getCargalibros().getComboBox_Tema()
                        .getSelectedIndex())
                .getSubtemas()
                .get(this.getCargalibros().getComboBox_SubTema()
                        .getSelectedIndex()).getDefinicion().size()];
        for (int i = 0; i < definicion.length; i++) {

            definicion[i] = this
                    .getLibros()
                    .get(this.getCargalibros().getComboBox_Libros()
                            .getSelectedIndex())
                    .getTemas()
                    .get(this.getCargalibros().getComboBox_Tema()
                            .getSelectedIndex())
                    .getSubtemas()
                    .get(this.getCargalibros().getComboBox_SubTema()
                            .getSelectedIndex()).getDefinicion().get(i)
                    .getDefinicion();

        }
        this.getCargalibros().getComboBox_Glosario()
                .setModel(new DefaultComboBoxModel(definicion));
        manejadordeglosario();
    } catch (ArrayIndexOutOfBoundsException e) {
        this.getCargalibros().getComboBox_Glosario()
                .addItem("Este subtema no tiene definiciones cargadas ");

    }

}

public void manejadordeglosario() {

    System.out.println(this.getCargalibros().getComboBox_Glosario()
            .getSelectedIndex());
    // this.getCargalibros().getTextArea().setText(" ");
    this.getCargalibros()
            .getTextArea()
            .setText(
                    this.getLibros()
                            .get(this.getCargalibros().getComboBox_Libros()
                                    .getSelectedIndex())
                            .getTemas()
                            .get(this.getCargalibros().getComboBox_Tema()
                                    .getSelectedIndex())
                            .getSubtemas()
                            .get(this.getCargalibros()
                                    .getComboBox_SubTema()
                                    .getSelectedIndex())
                            .getDefinicion()
                            .get(this.getCargalibros()
                                    .getComboBox_Glosario()
                                    .getSelectedIndex()).getContenido());
}   
IvanH
  • 5,039
  • 14
  • 60
  • 81
Turbo760
  • 1
  • 1

0 Answers0