lundi 28 décembre 2020

Java - If-statement returns false

I've got a button "addspieler" and when I first press it, the second if statement returns true and view.addbox is executed (I want to add an JComboBox every time the button is pressed). But after the execution the if-statement returns always "false" and view.addbox is not going to be executed anymore. I don't know why. Thanks for advice!

public void actionPerformed(ActionEvent e) {

            if (e.getSource() == view.button1) {
                view.zeige_AuswahlNeuesSpiel(modell.getSpieler());

            }

            if (e.getSource() == view.button_addSpieler) {
                view.add_Box(modell.spieler_Anzahl_NeuesSpiel, modell.getSpieler());

            }

    }

view.addbox =


 public void add_Box(int anz_spieler, ArrayList<Spieler> spieler_Liste)
        {
            if(ct >= anz_spieler)
                return;



            jcombo_Liste = erstelle_Box(anz_spieler);

            GridBagConstraints gbc = new GridBagConstraints();
            GridBagLayout layout = new GridBagLayout();
            setLayout(layout);


            jcombo_Liste.get(ct).addItem(spieler_Liste.toArray());






            button_addSpieler = new Button("Spieler hinzufügen");
            button_addSpieler.addActionListener(darts_controller);

            gbc.fill = GridBagConstraints.HORIZONTAL;
            gbc.gridx = 0;
            gbc.gridy = 0;
            f1.add(button_addSpieler,gbc);


            gbc.gridx = ct;
            gbc.gridy = 1;
            f1.add(jcombo_Liste.get(ct),gbc);

            ct = ct+1;
            f1.repaint();


        }

Aucun commentaire:

Enregistrer un commentaire