Results 1 to 1 of 1
- 12-27-2007, 09:48 PM #1
Member
- Join Date
- Aug 2007
- Location
- belgium
- Posts
- 1
- Rep Power
- 0
presse 1 menuitem execute 4 times the same JFrame
I have programmed a game that plays in a jframe. It should play 4 times the red paragraph. When the game is finished i have to push again on the menuitem "speel memory" and that is not the way I want it.
My question is how can 1 select once the menuitem "play memory" and execute 4 times "play memory"
package View.Menu;
import Model.*;
import View.Memory.MemoryKaartenPaneel;
import Model.MemoryInstellingen.Instellingen;
import javax.swing.JFrame;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.Color;
public class MenuVenster extends BasisMenuVenster implements ActionListener {
private Instellingen instellingen;
private MemoryKaartenPaneel newgame;
public MenuVenster() {
super("Memory spel");
instellingen = new Instellingen();
newgame = null;
JMenuBar menubar = new JMenuBar();
this.setJMenuBar(menubar);
JMenu menu1 = new JMenu("Ending");
JMenu menu2 = new JMenu("play game");
menubar.add(menu1);
menubar.add(menu2);
JMenuItem exitItem = new JMenuItem("End");
JMenuItem SpeelMemory = new JMenuItem("play memory");
menu1.add(exitItem);
menu2.add(playMemory);
SpeelMemory.addActionListener(this);
exitItem.addActionListener(this);
}
public void actionPerformed (ActionEvent evt){
String actionCommand = evt.getActionCommand();
cleanPanel();
if (actionCommand.equals("play Memory")){
newgame = new MemoryKaartenPaneel(instellingen);
this.getContentPane().add(newgame);
this.validate();
if (actionCommand.equals("End")){
System.exit(0);
}
}
private void cleanPanel(){
if (newgame != null){
remove (newgame);
}
}
}
Similar Threads
-
cannot execute EJB application.
By JavaEmpires in forum Enterprise JavaBeans (EJB)Replies: 1Last Post: 07-17-2008, 09:53 AM -
Recursive Method ==> find how many times a value is repeated in an array
By NatNat in forum New To JavaReplies: 2Last Post: 02-16-2008, 08:52 PM -
Problem calling classes to flip coin x number of times and record heads or tails
By adlb1300 in forum New To JavaReplies: 2Last Post: 11-11-2007, 08:07 AM -
Execute Jar file
By barney in forum New To JavaReplies: 1Last Post: 08-07-2007, 07:13 AM -
why does not execute this?
By aleplgr in forum New To JavaReplies: 6Last Post: 08-01-2007, 11:37 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks