Problem mit dem Action listener....

hans-sonny

Bekanntes Mitglied
Hi leute ich hab eine JMenuBar mit 2 JMenu's jedes dieser JMenu's hat zwei JMenuItems


wenn ich jetzt z.B. auf item1 klicke führt er mir die aktion zwei mal aus ...


das ist mein action listener...

völlig egal welches item ich anklicke es wird immer zwei mal aufgerufen

Java:
@Override
    public void actionPerformed(final ActionEvent e) {
        /*
         * ----------------------------------------------------------------------
         * Exit Game
         * ----------------------------------------------------------------------
         */
        if (e.getSource().equals(this.item2)) {
            final int n = JOptionPane.showConfirmDialog(this, "Do you realy want to Exit the game?", "Exit game", JOptionPane.YES_NO_OPTION);

            if (n == JOptionPane.YES_OPTION) {
                System.exit(0);
            }
        }
        /*
         * ----------------------------------------------------------------------
         * Start new Game
         * ----------------------------------------------------------------------
         */
        if (e.getSource().equals(this.item1)) {
            //Get Players Name
            String name = JOptionPane.showInputDialog(null, "Enter your Name: ");
            playlogic.Global_vars.setName(name);
            playersName.setText(playlogic.Global_vars.getName() + "'s deck");
            playersName.setFont(new Font("Serif", Font.BOLD, FONTSIZENAME));
            playersName.setForeground(Color.WHITE);

            //Add Panels
            this.rightpanel.add(this.userCards);
            this.leftpanel.add(colorP);


            final int start = JOptionPane.showConfirmDialog(this, "Do you want to start a new game?", "Start game", JOptionPane.YES_NO_OPTION);

            if (start == JOptionPane.YES_OPTION) {
                this.label.setText(" ");
                // Start game
                this.newGuigame = new playlogic.Playlogic();
                // Color of top Card
                final unocards.Card card = this.newGuigame.getUsed().showCard(0);
                // set actual color!
                this.setColorPanel(card);
                //Centerpanel
                this.centerpanel.add(cardLabel);           
            }
        }
        
        /*
         * ----------------------------------------------------------------------
         * About dialog
         * ----------------------------------------------------------------------
         */
        if (e.getSource().equals(this.item4)){
            double version = playlogic.Global_vars.getVersion();
            String string = "Copyright Felix Hohlwegler & Duy Nguyen " + "Version: " + version;
            final int about = JOptionPane.showConfirmDialog(this, string , "About", JOptionPane.OK_OPTION);
        }
        
    }


woran könnte das liegen?
 

Neue Themen


Zurück
Oben