Can the same button be used for different things

hi, i want to be able to change what area the player goes to when they press the journey button. but the code i made can only display one message, and that is, "you journey on..."
i want to be able , for each button press, to move the player forward to a new area, is that possible? here is the code so far.
import java.applet.Applet;
import java.awt.Button;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class Buttondemo extends Applet implements ActionListener{
String msg = "";
String zone = "forest";
String message = "Current zone is" + zone;
Button attack,run, inventory, search, journey ;
public void init(){
attack = new Button("attack");
run = new Button("run");
inventory = new Button("inventory");
search = new Button("search");
journey = new Button("journey");
add(attack);
add(run);
add(inventory);
add(search);
add(journey);
attack.addActionListener(this);
run.addActionListener(this);
inventory.addActionListener(this);
search.addActionListener(this);
journey.addActionListener(this);
public void actionPerformed(ActionEvent ae){
String str = ae.getActionCommand();
if(str.equals("attack")){
msg = "You attack!";
else if(str.equals("run")){
msg = "You run!";
else if(str.equals("inventory")){
msg = "Here is your inventory";
else if(str.equals("search")){
     msg = "You start searching...";
else 
     msg = "You journey on...";
repaint();
public void paint(Graphics g){
g.drawString(msg, 6, 100);

Ofcourse its possible. Maybe you wanna consider using an specific actionlistener for the journey button instead of using the common actionlistener.
Like this:
journey.addActionListener(new ActionListener() {
     public void actionPerformed(ActionEvent ae){
          //Move forward...
});

Similar Messages

  • Can the same name be used for both an iCal calendar and reminder list?

    In iCal, I have a Reminder list named "Home".  I have been trying to also give a Calendar the name "Home", but iCal does not seem to want me to do this. When I try to use the name Home for a Calendar, it changes it to the name "Home C" (a name that I gave it when I couldn't get it to let me use "Home").  Is this a restriction within iCal?  I have iCal synched with iCloud, which in turns syncs with an app called 2Do on my iPhone.  I am not sure if that may be part of the problem. 

    Yes, it can
    Stedman

  • Do I need to buy a new printer, dedicated for my Mac or can I use the same one we use for our PCs?

    Do I need to buy a new printer, dedicated for my Mac or can I use the same one we use for our PCs?

    Hello stacksofamber and welcome to Apple Support Communities,
    You should be able to find a Mac OSX driver for that printer. Did you check with the manufacturer/'s website?

  • My iPad will not charge and every time I charge it. It comes up with the iTunes icon and I will not charge, it is not a new I pad and the same charger I use for the I pad I use for my I phone and it will charge. What is wrong?

    My iPad will not charge and every time I charge it. It comes up with the iTunes icon and I will not charge, it is not a new I pad and the same charger I use for the I pad I use for my I phone and it will charge. What is wrong?

    What exactlyare you seeing on the iPad's screen ? If it's the iTunes icon and a cable then that means that it's gone into recovery mode - you will need to connect it to your computer's iTunes and you should be able to use that to reset it back to factory defaults and you can then restore/resync your content to it.

  • I ADDED A CAMERA USING wpS THAT SCREWED UP MY WIFI. i RISTALLED AND NOW MY LAPTOP IS GETTING THE NET, BUT MY IPAD ISN'T ACCEPTING THE PASSWORD--THE SAME AS i USED FOR THE LAPTOP.

    I added a dlink camera and used WPS to do that. It apparently disabled my regular wifi. I reloaded the disk for my dlink router and now my laptop is getting a signal, but my ipad won't accept the [passwrd-the same one I used for the laptop.

    Just double check that reloading the disk for the router did not restore it to factore settings and reset the password to the factory default password.
    Try settings/general/reset/reset network settings and try again to connect with the ipad

  • On Apple TV. Can the USB port be used for a keyboard and mouse interface

    On Apple TV. Can the USB port be used for a keyboard and mouse interface

    A bluetooth keyboard can be used with the Apple TV.
    There is no need for a mouse with an ATV.

  • HT4623 I still can't update, i get error 3252 every time, after over 500mb is downloaded, not happy to waste all the data i could use for other things

    I still can't update, i get error 3252 every time, after over 500mb is downloaded, not happy to waste all the data i could use for other things.
    is there another way i can download the update? it just never work, tried multiple time

    The most common causes are:
    Your antivirus, firewall or router security is blocking access to Apple's servers - try temporarily disabling them - if you have Kaspersky this is definitely the problem
    At some time in the past you used this computer to jailbreak, unlock or otherwise hack ANY iPhone, iPod Touch or iPad - if this applies to you your hosts file is corrupt and you will have to edit it and remove any lines that contain "gs.apple.com"

  • Can I use the "same" button multiple times for multiple galleries?

    OK so I am extremely untrained in CS4 and Actionscript. However I have managed to get along fairly well until I started to dynamically upload images as a gallery. This works great if I have one gallery, but for my site I have 9 galleries!!! I have a back and next button, but I want to be able to use those same buttons for all of the galleries so they look the same. I have split them up and renamed them, but I am clueless on how to script the buttons to work. Please help...and don't laugh at my poor scripting. This is what I have now because I do not know where to put the other button names without getting errors.
    stop();
    next_btn .addEventListener(MouseEvent.CLICK, nextImage);
    var imageNumber: Number=1;
    function checkNumber(): void{
        next_btn.visible=true;
        back_btn.visible=true;
        if(imageNumber==15){
            trace(imageNumber);
        next_btn.visible=false;
        if(imageNumber==1){
            trace(imageNumber);
        back_btn.visible=false;
    function nextImage(evtObj:MouseEvent):void {
        imageNumber++;
        mc_engagement.source= "photo/engagement/en0"+imageNumber+".jpg";
        mc_amish.source= "photo/amish/Amish"+imageNumber+".jpg";
        mc_chicago.source= "photo/chicago/ch"+imageNumber+".jpg";
        mc_landscapes.source= "photo/landscapes/land"+imageNumber+".jpg";
        mc_goodvsevil.source= "photo/goodvsevil/ge"+imageNumber+".png";
        mc_animals.source= "design/animals/an"+imageNumber+".png";
        mc_icons.source= "design/icons/icon0"+imageNumber+".png";
        mc_objects.source= "design/objects/pc"+imageNumber+".png";
        mc_typography.source= "design/typography/type"+imageNumber+".png";
        checkNumber();
    back_btn .addEventListener(MouseEvent.CLICK, backImage);
    function backImage(evtObj:MouseEvent):void {
        imageNumber--;
        mc_engagement.source= "photo/engagement/en0"+imageNumber+".jpg";
        mc_amish.source= "photo/amish/Amish"+imageNumber+".jpg";
        mc_chicago.source= "photo/chicago/ch"+imageNumber+".jpg";
        mc_landscapes.source= "photo/landscapes/land"+imageNumber+".jpg";
        mc_goodvsevil.source= "photo/goodvsevil/ge"+imageNumber+".png";
        mc_animals.source= "design/animals/an"+imageNumber+".png";
        mc_icons.source= "design/icons/icon0"+imageNumber+".png";
        mc_objects.source= "design/objects/pc"+imageNumber+".png";
        mc_typography.source= "design/typography/type"+imageNumber+".png";
        checkNumber();

    I'm still a novice with Flash myself, but I have two comments.
    First, at this point, won't your buttons control all galleries at the same time? Which means, if I go to image 5 in one gallery, then move to another gallery, I'll start at image 5, because the actions are all connected.
    Second, you can definitely use the same buttons for multiple galleries. It seems to me that as long as you've assigned the buttons an instance name, these actions should already work to control all the galleries (see the note above). I guess I would need to understand a bit more about how your project is built.

  • How to own the same e-mail-address for different Apple-IDs

    Hello
    I’m under the impression, that I can’t use the same e-mail-address for iCloud I used already in my Apple-ID for iTunes, because I get no verification mail for the iCloud account. Is this correct or did I something wrong?
    Thanks for supporting me
    I already raised this question in the iCloud forum, but till now nobody answered - may be the wrong sub-forum

    Many thanks for the answer - that's what I suspected. Anyway...
    The problem I have now is, that my Apple-ID I used already for some years in order to buy apps is in the "old" format (e.g. duggy832), that means not in the form of an eMail-address. iCloud accept only Apple-IDs in the “new” format meaning in the form like an eMail-address (e.g. [email protected]).
    So it needs to modify the old Apple-ID from duggy832 to [email protected] or to “transfer” – if possible – my shopping from Apple-ID duggy832 to [email protected]
    Which way is possible, which is safe/secure, which is recommended?
    Thanks in advance

  • How can I use the same thread pool implementation for different tasks?

    Dear java programmers,
    I have written a class which submits Callable tasks to a thread pool while illustrating the progress of the overall procedure in a JFrame with a progress bar and text area. I want to use this class for several applications in which the process and consequently the Callable object varies. I simplified my code and looks like this:
            threadPoolSize = 4;
            String[] chainArray = predock.PrepareDockEnvironment();
            int chainArrayLength = chainArray.length;
            String score = "null";
            ExecutorService executor = Executors.newFixedThreadPool(threadPoolSize);
            CompletionService<String> referee = new ExecutorCompletionService<String>(executor);
            for (int i = 0; i < threadPoolSize - 1; i++) {
                System.out.println("Submiting new thread for chain " + chainArray);
    referee.submit(new Parser(chainArray[i]));
    for (int chainIndex = threadPoolSize; chainIndex < chainArrayLength; chainIndex++) {
    try {
    System.out.println("Submiting new thread for chain " + chainArray[chainIndex]);
    referee.submit(new Parser(chainArray[i]));
    score = referee.poll(10, TimeUnit.MINUTES).get();
    System.out.println("The next score is " + score);
    executor.shutdown();
    int index = chainArrayLength - threadPoolSize;
    score = "null";
    while (!executor.isTerminated()) {
    score = referee.poll(10, TimeUnit.MINUTES).get();
    System.out.println("The next score is " + score);
    index++;
    My question is how can I replace Parser object with something changeable, so that I can set it accordingly whenever I call this method to conduct a different task?
    thanks,
    Tom                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    OK lets's start from the beginning with more details. I have that class called ProgressGUI which opens a small window with 2 buttons ("start" and "stop"), a progress bar and a text area. It also implements a thread pool to conducts the analysis of multiple files.
    My main GUI, which is much bigger that the latter, is in a class named GUI. There are 3 types of operations which implement the thread pool, each one encapsulated in a different class (SMAP, Dock, EP). The user can set the necessary parameters and when clicking on a button, opens the ProgressGUI window which depicts the progress of the respective operation at each time step.
    The code I posted is taken from ProgressGui.class and at the moment, in order to conduct one of the supported operations, I replace "new Parser(chainArray)" with either "new SMAP(chainArray[i])", "new Dock(chainArray[i])", "new EP(chainArray[i])". It would be redundant to have exactly the same thread pool implementation (shown in my first post) written 3 different times, when the only thing that needs to be changed is "new Parser(chainArray[i])".
    What I though at first was defining an abstract method named MainOperation and replace "new Parser(chainArray[i])" with:
    new Callable() {
      public void call() {
        MainOperation();
    });For instance when one wants to use SMAP.class, he would initialize MainOperation as:
    public abstract String MainOperation(){
        return new SMAP(chainArray));
    That's the most reasonable explanation I can give, but apparently an abstract method cannot be called anywhere else in the abstract class (ProgressGUI.class in my case).
    Firstly it should be Callable not Runnable.Can you explain why? You are just running a method and ignoring any result or exception. However, it makes little difference.ExecutorCompletionService takes Future objects as input, that's why it should be Callable and not Runnable. The returned value is a score (String).
    Secondly how can I change that runMyNewMethod() on demand, can I do it by defining it as abstract?How do you want to determine which method to run?The user will click on the appropriate button and the GUI will initialize (perhaps implicitly) the body of the abstract method MainOperation accordingly. Don't worry about that, this is not the point.
    Edited by: tevang2 on Dec 28, 2008 7:18 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Can I use a different I'd for developing on the same Mac I use for iTunes?

    I Want to become an app developer but I would like to use a new account. I already have an apple I'd that I want to keep using for everything else on my Mac. Is it possible to use one for music and apps and another for developing on the same computer?

    Hi Schatzie246,
    Thanks for visiting Apple Support Communities.
    You can create a new Apple ID for use with the Apple Developer Programs if you'd prefer:
    New Apple ID
    Create a new Apple ID if you have an existing iTunes Connect account, participate in the Volume Purchase Program, are enrolled in the iOS Developer Enterprise Program, or prefer to have an Apple ID dedicated
    to your business transactions.
    From Apple Developer: Sign in or create an Apple ID.
    See this page for more information about the Apple Developer Programs:
    https://developer.apple.com/support/
    Best Regards,
    Jeremy

  • Multiple use of the same video time line for different audio tracks

    I have a 90 minute video timeline
    I will be putting different audio tracks in multiple languages.
    But as i was just editing i wondered if i could use only a segment (30 minutes ) of the timeline
    along with a 30 minute audio.
    Example:
    So the first thing on the menu will be the whole 90 minute video
    with a 90 minute music track
    Second thing might be the 90 minute video with a 90 minute commentary
    Third thing might be the first 30 minutes of video with a different commentary
    Forth thing on the menu might be the first 30 minutes of video and 30 minutes of
    a different language
    Etc.
    I realize i will need to make space (mb)  for all the audio.....but if i could use the same video or pieces of it
    that would be fantastic.
    If i can do this i am presuming i should use playlists and chapter playlists to get it done?
    I have never done this before and would love some feedback on an over view or tips
    that might save me some guess work
    Thanks for any help :-)
    Soshman

    Soshman wrote:
    Hey Stan!
    Thanks for your help...i think i am really getting this. And have learned a lot.
    I had to go back to my computer programming and flowcharting skills to figure out the flow :-)
    And i still have 153mb to spare when i build it.
    I ended up lining up all the different videos and audios exactly for each time line except for 1 timeline.
    Question: I know if the audio is shorter it will be ok.... but if the audio is longer than the video on a timeline ( and its the audio i assigned it by specify link )
    Will the DVD keep playing until the audio is done or end when the video is done playing?
    2nd Question: I am previewing the playlists with the "Preview from Here" feature
    I specify the link and chapter within that timeline ( it is the only timeline with more than one chaper....the one with the longer audio than video from the question above )
    For most of the audios i only need video chapter 1.....the preview here plays it ok but if i hit the skip to next (in the preview button on theright of the play button)...it goes to the next chapter #2... instead of the next timeline chapter 1 like it is programed to do from the playlist.
    I am wondering if this is just fluke in the preview feature...or will it do that on the actual DVD as well?
    Lastly because i am using different timelines. I am wondering if there are delays between playlists? for example...i have a long audio that continues between three timelines...i have spliced it pretty fine so it picks up perfectly on the next timeline...but i am wondering if the DVD when playing in realtime will have a little black space inbetween timelines.
    Thanks again for your help and time :-)
    Mark
    Hiya Mark.
    DVD-Video is video dominant, with the audio always following the visuals so if the audio ends berfore the video it will not (okay, should not) be a problem.
    However, the other way around could go either way - if the actual video timeline has ended the audio may well truncate so I would personally add videoblack at the very least.
    I am also not at all sure how you are going to work a single contiguous audio file across 3 separate playlists. This sounds flawed in concept to me (have I misunderstood your meaning?). In DVD-Video the format is graphically/visually dominant - the audio must always be tied to a visual asset be it a menu or a timeline - so there is no way to have one piece of audio playing across 3 timelines and having it play back glitch free whilst the timeline changes. You will not get a black space - it will simply stop. So unless I have misunderstood you in some way.........
    As Stan says, preview is flaky - the only way to know for sure is to multiplex & burn.

  • Can the same iphone be used to develop on two different mac hardware sets?

    My co-worker and I are both developing iPhone code. I am the only one around with an iPhone. A couple of questions:
    1.) It is possible for him to use my iphone to test his code (with HIS mac), then I do the same on MY mac. Will this conflict? Will iTunes freak?
    2.) If we were to purchase another iphone, we'd prefer not to get a contract (which Apple makes you do). Can we use an unlocked phone, or an ATT phone purchased on eBay (assuming there is no current subscription).
    We are running identical OSx versions. I have and air, he has a pro.
    Thanks!

    Nevermind! The answers are all in the apple signup process. Sorry bout that.

  • I can't sign in b/c "your acct is inactive" and I can't register a new acct w/ the same email I used for the original registration. FF7.0.1

    When I try to sign in I get "your acct is inactive" message and no info on how to activate it. When I try to register a new acct, I can't use my email address b/c its associated w/ my "inactive" acct. So I opened a new email acct in order to register a new FF acct.
    The original problem I have concerns ReminderFox in FF7.0.1, Windows 7
    It's there but I can't enter any notes/reminders in it??

    That can happen if you have used the account for quite some time.
    Try to post a request to reactivate on the Contributors forum if you can't set a new password.
    *https://support.mozilla.com/users/pwreset
    *https://support.mozilla.com/forums/contributors

  • How do i sweep two voltage at the same time by using for loop ?

    Hello, Can anyone help me on this topic ?
    My problem is to sweep Vds and Vgs as same time vs Id in MOSFET by using for loop. I also use the Agilent power supply source. Let me tell a litle bit about what i'm doing. For different value of Vds, i will get Vgs vs Id curve. (The x axis is Vgs, the y-axis is Id).
    I started to create two for-loop, the inner to sweep Vgs, and the outer one to sweep Vds. My problem is don't know how to connect all the wire in  the for loop.
    In the for loop i saw N, i icon. Suppose I have the two variable for Vgs such as Vgs start and Vgs_stop. Should the Vgs_start( or Vgs_stop) be connected to N or leave it in the for_loop ?
     for example: I want to sweep Vgs from 0(for Vgs_start)  to  5(Vgs_strop) V, and the step increment is .5V how do i connect these variables in the for loop ?
    Thank you for your time
    Ti Nguyen

    It is easier to use a while loop.  Dennis beat me to the punch.  Here is my solution:
    You can remove the flat sequence structure if you use Error In and Error Out to ensure the execution flow will occur in the proper order.  Be sure to include the delay time in the loop so that your vi doesn't hog all the CPU time.
    Message Edited by tbob on 10-17-2005 01:00 PM
    - tbob
    Inventor of the WORM Global
    Attachments:
    RampVoltage.PNG ‏8 KB

Maybe you are looking for