Need help with an app

what i need is the following:
Create an applet that has a JTextField for the user to enter the name of a color. If the color entered is not either red, white, blue, then your applet should throw an Exception and tell the user the color entered was not valid. Otherwise change the background color to the appropriate color.
this is what i have
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Colors extends JApplet implements ActionListener //make the class
     private GridLayout layout = new GridLayout(3, 1);
     JPanel panel02 = new JPanel(new FlowLayout()); //make panels
     JPanel panel03 = new JPanel(new FlowLayout());
     JPanel panel04 = new JPanel(new FlowLayout());
     Container con = getContentPane();
     FlowLayout Lay = new FlowLayout(FlowLayout.CENTER);
     JLabel head = new JLabel("Please enter a color");
     JTextField choice = new JTextField("",10);
     JButton enter = new JButton("Press After Typing");
     JLabel error = new JLabel("");
     JPanel pane = new JPanel() ; //make a new panel
     public void init()
          con.setLayout(layout);//set the layout
          con.add(panel02);
          con.add(panel03);
          con.add(panel04);
          panel02.add(head);
          panel03.add(choice);
          panel03.add(enter);
               enter.addActionListener(this);
          panel04.add(error);
     public void actionPerformed(ActionEvent e) //make the actions
          String red, white, blue;
          Object source = e.getSource(); //get the source
          String aColor = choice.getText();
                    if(aColor == "red")
               panel02.setBackground(Color.RED);     
//panel02.setBackground(Color.RED);
//panel03.setBackground(Color.BLUE);
//panel04.setBackground(Color.WHITE);
error.setText(aColor); //("Wrong Color Choice");               
               if(aColor == "red")
                    getContentPane().setBackground(Color.RED); //change the back ground color
               //catch(Exception ex)
               //     error.setText("Wrong Color Choice");
}

Did you already try to reset the phone by holding the sleep and home button for about 10sec, until the Appel logo comes back again? You will not lose data by resetting, but it can cure some glitches.

Similar Messages

  • Newbie needs help with Flex app

    Hi there. I am very new to Flex and also fairly new to
    programming although I do have a little experience.
    I am trying to create an app which stores code snippets or
    common text I tend to use every day in my documents and emails.
    So basically I need help on a design level. I can refer to
    the developer's manual for exact instructions for commands, but I
    need to know what to code first.
    The app will consist of:
    -a tree directory structure where I can create groups.
    -There will be a basic text editor where I input all my data,
    basic text formatting options (font, bullets etc) would be a bonus.
    -A search function
    -Finally it will ideally allow multiple client apps write to
    a central database file over a network
    Can anyone suggest how I should approach such a project?
    Or are there any tutorials / source files which demonstrate
    each bullet point?
    thanks.

    Hey jono,
    I'm new too. But I think I might know the right components.
    If you google any of these + flex 3 you should get some
    decent documentation
    tree - advanced dataGrid component
    basic text editor - rich text editor component
    search function - well, you're gonna need to read up on
    arrays, and arraycollection. Once you get that stuff working, you
    can write up a function to search for a string in an array.
    network functionality - HTTPService, you can dump the
    datagrid into a database, and have it load the database when you
    open up the application.
    Give these things a shot, tutorials / sources will come with
    the google searches.

  • Need help with installing app.

    I need help installing .jar file on my Droid phone.

    Oh, man, the last time I heard of a .JAR file was on a Motorola Razr!
    That ain't goin' on a Droid....
    Unless you have some more context to share about this.....
    Geri O

  • I need help with downloading apps?

    I got an iPad 2 today and I entered all my details in and also my bank details in, but then it's saying to me to enter 'security code' in? And I don't know what it is. I have realised that a lot of people are having this problem and it obviously needs to be sorted? Please help me?????

    Thanks for your responses but when I go on app store and then on featured, I press 'free app' and then it says 'install app' and then I click on 'use existing apple id' - so then I enter my username and password, then all my bank details ans everything else, there all correct but then it comes up with... 'your payment method was declined, please enter another payment method' - all I want is FREE apps, no paid ones? Is there anyway I could get around this? - I have noticed a lot of people are having this problem HELPPPPP lol x

  • Need help with Java app for user input 5 numbers, remove dups, etc.

    I'm new to Java (only a few weeks under my belt) and struggling with an application. The project is to write an app that inputs 5 numbers between 10 and 100, not allowing duplicates, and displaying each correct number entered, using the smallest possible array to solve the problem. Output example:
    Please enter a number: 45
    Number stored.
    45
    Please enter a number: 54
    Number stored.
    45 54
    Please enter a number: 33
    Number stored.
    45 54 33
    etc.
    I've been working on this project for days, re-read the book chapter multiple times (unfortunately, the book doesn't have this type of problem as an example to steer you in the relatively general direction) and am proud that I've gotten this far. My problems are 1) I can only get one item number to input rather than a running list of the 5 values, 2) I can't figure out how to check for duplicate numbers. Any help is appreciated.
    My code is as follows:
    import java.util.Scanner; // program uses class Scanner
    public class Array
         public static void main( String args[] )
          // create Scanner to obtain input from command window
              Scanner input = new Scanner( System.in);
          // declare variables
             int array[] = new int[ 5 ]; // declare array named array
             int inputNumbers = 0; // numbers entered
          while( inputNumbers < array.length )
              // prompt for user to input a number
                System.out.print( "Please enter a number: " );
                      int numberInput = input.nextInt();
              // validate the input
                 if (numberInput >=10 && numberInput <=100)
                       System.out.println("Number stored.");
                     else
                       System.out.println("Invalid number.  Please enter a number within range.");
              // checks to see if this number already exists
                    boolean number = false;
              // display array values
              for ( int counter = 0; counter < array.length; counter++ )
                 array[ counter ] = numberInput;
              // display array values
                 System.out.printf( "%d\n", array[ inputNumbers ] );
                   // increment number of entered numbers
                inputNumbers++;
    } // end close Array

    Yikes, there is a much better way to go about this that is probably within what you have already learned, but since you are a student and this is how you started, let's just concentrate on fixing what you got.
    First, as already noted by another poster, your formatting is really bad. Formatting is really important because it makes the code much more readable for you and anyone who comes along to help you or use your code. And I second that posters comment that brackets should always be used, especially for beginner programmers. Unfortunately beginner programmers often get stuck thinking that less lines of code equals better program, this is not true; even though better programmers often use far less lines of code.
                             // validate the input
       if (numberInput >=10 && numberInput <=100)
              System.out.println("Number stored.");
      else
                   System.out.println("Invalid number.  Please enter a number within range."); Note the above as you have it.
                         // validate the input
                         if (numberInput >=10 && numberInput <=100)
                              System.out.println("Number stored.");
                         else
                              System.out.println("Invalid number.  Please enter a number within range."); Note how much more readable just correct indentation makes.
                         // validate the input
                         if (numberInput >=10 && numberInput <=100) {
                              System.out.println("Number stored.");
                         else {
                              System.out.println("Invalid number.  Please enter a number within range.");
                         } Note how it should be coded for a beginner coder.
    Now that it is readable, exam your code and think about what you are doing here. Do you really want to print "Number Stored" before you checked to ensure it is not a dupe? That could lead to some really confused and frustrated users, and since the main user of your program will be your teacher, that could be unhealthy for your GPA.
    Since I am not here to do your homework for you, I will just give you some advice, you only need one if statement to do this correctly, you must drop the else and fix the if. I tell you this, because as a former educator i know the first thing running through beginners minds in this situation is to just make the if statement empty, but this is a big no no and even if you do trick it into working your teacher will not be fooled nor impressed and again your GPA will suffer.
    As for the rest, you do need a for loop inside your while loop, but not where or how you have it. Inside the while loop the for loop should be used for checking for dupes, not for overwriting every entry in the array as you currently have it set up to do. And certainly not for printing every element of the array each time a new element is added as your comments lead me to suspect you were trying to do, that would get real annoying really fast again resulting in abuse of your GPA. Printing the array should be in its own for loop after the while loop, or even better in its own method.
    As for how to check for dupes, well, you obviously at least somewhat understand loops and if statements, thus you have all the tools needed, so where is the problem?
    JSG

  • I need help with an app game purchase

    I recently added 20$ to my account with 2 10$ Itunes cards. I play the app called clash of clans, in the game you can buy things with itunes, I tried to make a purchase for 19.99 when there is just about 21 $ in my itunes and it's telling me I have insufficient funds. This is odd becusee a couple days ago I did the same thing with the itunes card but now I'm getting this error. I checked my itunes again and I have the money, please help!

    What country are you in ? If you are in the US then does your state's sales tax take it over what you have on your account ?

  • Need help with Camera app

    Hello RIM support,
    I am a new owner of BB Playbook.  Everything seems to be working okay except camera app.  I can take a picture with it but nothing will show up in picture app.  According to the help video, the pictures taken by camera app should show up in picture app from the menu option.
    Please help.
    Thanks
    Kevin
    Solved!
    Go to Solution.

    Yes, your pictures taken with the Playbook camera certainly should show in the Pictures folder on the Playbook.
    Just for the heck of it, can you try turning your Playbook off and back on and check your Pictures app/folder again?
    1. If any post helps you please click the below the post(s) that helped you.
    2. Please resolve your thread by marking the post "Solution?" which solved it for you!
    3. Install free BlackBerry Protect today for backups of contacts and data.
    4. Guide to Unlocking your BlackBerry & Unlock Codes
    Join our BBM Channels (Beta)
    BlackBerry Support Forums Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • I need help with iAD/App development!

    So I released an app, and it went on sale yesterday on the App Store (free app: if you want it, the developer name is Abdulrahman Ahmad, and the game name is Space Defense), but I'm having some problems. When I was testing the app (on an iPhone, and on the xCode Simulator), the ads were working, and I was getting "You're iAD is configured correctly (or whatever the test ads say)" but now that the app has finally released, no ads are appearing (but iTunes Connect says that the ads are live?). Also, I released 2 different versions of the app (2 downloads, 1 was optimized for 5 inch screen, one for 3.5 in (just figured out how to make it one app, that'll be coming out in the update), and when I was looking at my iTunes Connect iAD portal, only 1 app was showing up to have adds (the 3.5 inch one doesn't have ads for some reason?):
    SO! Summery if I confused you:
    iAD was working in the testing phase of the app, but not showing up now(even though iTunes Connect says ads are live)?
    And 1 of my apps is not showing up in my iTunes Connect iAD terminal...
    Any and all help appreciated!
    Thanks in advance!

    RE: Nevermind, i guess it takes a day or so for ads to finally start showing, and i guess i forgot to check off iad compatibility with the second app!

  • TS1424 Need help with netflix app over wifi on iphone 4

    I have iPhone 4 which is 3G.  I used the Netflix app on this phone. I recently got a new phone. I stopped the phone service and cell data plan to my iPhone 4. The netflix app still worked fine over wifi connection.  Suddenly, I am unable to connect to netflix.  I was going to try to remove and reinstall but I now cannot connect to iTunes store.  I found something that said I need to set up the phone to sync with wifi on iTunes, which I did.  synced again.  App still won't work and still cannot connect to iTunes store from phone.  My other iPhone 5 works fine but I need the netflix on the older iPhone 4 because of connection to tv.
    any ideas?????  I've tried signing out of netflix and back in on computer...  can't get in to Netflix app to even sign out then in.

    You can change the email address of an Apple ID without creating a new account. Apparently you didn't do this. You will need to Authorize the computer using the AppleID and password that the content was purchased with.
    Try connecting the phone, but DO NOT SYNC. Go to the iTunes File menu and choose Transfer Purchases. This should put the apps and music purchased with the old account into the iTunes library. Launch of of the songs and you should be prompted for the password to authorize that account.

  • Need help with downloading apps

    Hi I'm trying to upload some apps from creative cloud and it keeps saying that it has been downloaded already but won't show up on my application folder. I installed a trial version but deleted perhaps it things that it been installed already. Any help would be amazing.
    thanks!

    Hi student-panda,
    Please run Creative Cloud Cleaner tool and then launch CC Desktop apps. it should fix the issue.
    http://www.adobe.com/support/contact/cscleanertool.html
    regards,
    Abhijit

  • Need help with iPad app syncing in iTunes

    When I first connect iPad to iTunes, and select apps, all the apps on iPad display, but they are semi-transparent.
    When I uncheck sync, then only the apps that were installed originally show up, and are 'solid'.
    When I try to sync apps on my iPad, it shows these 'solid' icons only (less apps in iTunes than I have on the iPad) and warns I will lose apps not shown if I sync?!   That sounds more like a revert than a sync.  I do not want to revert, I want iTunes to update itself to show the list of apps I have purchased on the iPad.
    Anyone know how to get iTunes to show the apps I have on the iPad and let me sync them all to iTunes without losing what I purchased on the App Store through iPad?

    How could we help you?
    You did not even mention the name of the app.
    Contact the app maker and ask.

  • HT2693 Need help with purchased App, Please :o(

    Hi,
    I've purchased the Jllian Michael's app. And for some reason when I go onto the app it kicks me out.
    How does once go about on getting it fix. I've try deleting and re installing the app didn't work, I've tried restarting my
    Iphone. I don't know what to do. Can I get my money back? Please help.
    Thanks
    Karen R

    Try this:
    1. Close all apps in the Task Bar. Double-click the Home button and hold apps down for a second or two. Tap the minus sign to close app.
    2. Hold the Sleep and Home button down until you see the Apple Logo.

  • Need help with iPlanet App Server Install

    We have the Fast Track edition installed as webserver on an NT box. We
    have also loaded the Test Drive edition application server and we are
    trying to verify its installation. I have the IP and port number and
    then put in the /ias-samples/index.html and keep getting message Invalid
    URL.
    Checked for the directory existance and it is there. Does it need to be
    mapped somehow?
    What are we missing?
    Thanks In Advance ~

    Hi Tom,
    I don't know what is Fast Track edition of web server. Would you give
    the
    webserver name and version number (such as iWS 4.1 service pack6). It
    may be the case that iAS does not support the iWS. Check if the web
    server is running fine by typing only the ip address. No port number is
    neccessary for NT. You can try with no port number.
    <machine name>.<domain name>/ias-samples/index.html
    regds
    iAS devsupport
    visiontechdesigns wrote:
    >
    We have the Fast Track edition installed as webserver on an NT box. We
    have also loaded the Test Drive edition application server and we are
    trying to verify its installation. I have the IP and port number and
    then put in the /ias-samples/index.html and keep getting message Invalid
    URL.
    Checked for the directory existance and it is there. Does it need to be
    mapped somehow?
    What are we missing?
    Thanks In Advance ~

  • Need help with Preview app on MacBook pro 2011 / Lion.  Strange lockup followed by compounding issues

    Began by not being able to close files when opened in preview. Only way to escape... Force quit of preview program.
    Found help here. Tried multiple fixes - still acting very strange

    OK - I kept on trying and reading everything I could find on the issue.  Finally success!
    moved to the trash -
    ALL  com.apple.preview *.* files in the Library directory
    moved to the trash -
    the directory for com.apple.preview inside the Containers directory
    verified at library the permissions (cmd I) set to read/write
    restarted.....
    all trashed files rebuilt
    all functionality of preview is back!!!
    Hope this helps anyone else who is having trouble with preview!!

  • Need help with an app that won't finish downloading to my iPhone 5s

    This app will neither finish downloading, nor will it delete. The app is called Google Translate. please help me. Thank you all in advance.

    Did you already try to reset the phone by holding the sleep and home button for about 10sec, until the Appel logo comes back again? You will not lose data by resetting, but it can cure some glitches.

  • I need help with an app

    I downloaded an app called Text for free which costs $0.99 in which you can text to India. But when i am texting to india! it doesnt work so can u please let me know how to operate that app. Please reply me as soon as possible.
    Thank you so much

    so i type the number and type and msg and hit send right?
    and it asks me to select the country and carrier and i say india! and there are like 7 carriers. I dont know which one to select so i select all of them but it says it is queued in email outbox to be sent out shortly. But I ask my friend in India but he doesnt get it! I tried it yesterday but it didnt work!

Maybe you are looking for