Results 1 to 5 of 5
  1. #1
    jjackielz is offline Member
    Join Date
    Mar 2011
    Posts
    5
    Rep Power
    0

    Question Adding timer on my applet

    how to start a timer . . when i click the button on my applet "Click To Start"
    . . . i tried some swing timer but no luck on running it. then after the timer reach the designated time the game will execute . . here is my code: hope you can help me
    . . i highlighted it
    :confused::confused::confused::confused::confused:

    Java Code:
    public class blancojumbling extends Applet implements pauljumblenamestring {
    
    	Button play, input, rules;
    		TextField pauljumbletext ,paulrighttextfield;
    			Label pauljumblelabel, paulcorrectlabel, paulresultlabel;
    				Font textFont = new Font("Helvetica", Font.PLAIN, 16);
    							int displayMode = 0; 
    								int index;
    public blancojumbling () 
    	
    {
    	
    	setBackground(Color.black);
        setFont(textFont);
    
    	pauljumblelabel=new Label("Jumble Words");
    	add(pauljumblelabel);
    	pauljumblelabel.setAlignment(Label.CENTER);
    
    	pauljumbletext =new TextField(30);
    	pauljumbletext.setEditable(false);
    	add(pauljumbletext);
    	
    	playhandler handler =new playhandler();
    	[COLOR="Red"]play [/COLOR]= new Button("Click To Start");
    	add([COLOR="Red"]play[/COLOR]);
    	play.addActionListener(handler);
    
    	rules = new Button("Explain the rules");
        add(rules);
    	
    	paulcorrectlabel=new Label("Enter Correct Words");
    	add(paulcorrectlabel);
    	pauljumblelabel.setAlignment(Label.CENTER);
    
    	paulrighttextfield=new TextField(30);
    	add(paulrighttextfield);
    	
    	input=new Button("Click Here To Submit.");
    	add(input);
    	input.addActionListener(
    
    new ActionListener()
    {
    	public void actionPerformed(ActionEvent event)
    {
    
    		for(int count=0;count<correctstrings.length;count++)
    {
    		if(paulrighttextfield.getText().equals(correctstrings[count])&&index==count)
    {
    	JOptionPane.showMessageDialog(null, "Good Job! You're Right!", "Alert", JOptionPane.PLAIN_MESSAGE); 
    		paulresultlabel.setVisible(false);
    	}
    		else if(paulrighttextfield.getText()!=(correctstrings[count])&&index == count)
    	{
    	JOptionPane.showMessageDialog(null, "Incorrect Input!", "Alert", JOptionPane.ERROR_MESSAGE); 
    		paulresultlabel.setVisible(false);
    }
    	}
    		}
    			}
    );
    
    	paulresultlabel=new Label(" ");
    		add(paulresultlabel);
    			setVisible(true);	
    	}
    
    public void paint (Graphics g)
    { if (displayMode == 0)
          return;
        else
          showRules(g);
    }	
    	
    
    public void showRules (Graphics g)
    
    { g.setColor(Color.white);
    
        g.drawString("COUNTRY NAMES",50,220);
        g.drawString("Guess the jumbled country name",50,250);
    	g.drawString("by clicking the Click To Start",50,270);
    	g.drawString("then enter the correct name in the textbox.",50,290);
        g.drawString("The fastest one to enter the correct" ,50,310);
    	g.drawString("correct country name will win the game.",50,330);
    }
    	
    public boolean action(Event e, Object arg)
    { if (e.target == rules)
         { displayMode = 1 - displayMode;
           repaint();
    	 }
        return true;
    }
    		
    	public static void main(String args[])
    {
    		blancojumbling application =new blancojumbling();
    	}	
    	private class playhandler implements ActionListener
    {
    	public void actionPerformed(ActionEvent event)
    {
    	setjumblewordtest(); 
    	}
    		}
    	public void setjumblewordtest()
    {
    		int output=(int)(Math.random() * blancojumbling.length);
    			pauljumbletext.setText(blancojumbling[output]);
    
    index=output;
    
    	}
    	
    	
    }

    im trying to run the objTimeCounter that ive got on the net but no luck
    Last edited by Fubarable; 03-20-2011 at 11:28 AM. Reason: Moderator Edit: quote tags changed to code tags

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,298
    Rep Power
    20

    Default

    So, you removed the text of your last question?
    question on how to put this button to work

    You don't deserve help on a forum.

    db

  3. #3
    jjackielz is offline Member
    Join Date
    Mar 2011
    Posts
    5
    Rep Power
    0

    Default

    . . . why?

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Why did you delete the text from your previous thread? Your questions are not just for you but for all with similar problems in the future, and your removing text hurts their ability to get help from those threads.

  5. #5
    jjackielz is offline Member
    Join Date
    Mar 2011
    Posts
    5
    Rep Power
    0

    Default

    oh im sorry, i did'nt know it . . . ill just return that old text . . sorry. . . i apologize. . coz i did'nt work on that thing anymore . . sorry . .

Similar Threads

  1. Adding sound to an applet
    By Ryan10 in forum New To Java
    Replies: 1
    Last Post: 03-02-2011, 04:54 PM
  2. Stopping a Timer from Inside the timer
    By krishnan in forum Java Applets
    Replies: 2
    Last Post: 10-04-2010, 11:15 PM
  3. adding music to a applet.
    By ramsrocker in forum New To Java
    Replies: 1
    Last Post: 02-14-2009, 04:31 AM
  4. Adding color to a java applet?
    By soc86 in forum Java Applets
    Replies: 2
    Last Post: 11-02-2008, 04:14 PM
  5. Replies: 0
    Last Post: 04-04-2008, 02:46 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •