Runtime help please

Greetings,
First off I will admit that this a part of a project for school. I am not asking for anyone to "give me code" or to "do it for me". I am having a problem tracing a runtime error with the below code. The error only occurs when you choose a selection from the jmenu (null pointer execption on line xyz). the jmenu is supposed to update the display in the JComboBox via the setSelectedItem() and the null pointer points towards the line for the setSelectedItem(). Any assistance in pointing me towards the source of the error is appreciated.
source code follows:
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
class Polygon extends JFrame implements ActionListener
{   // start Polygon Class
     /* Variable Declarations */
     Color color = Color.red;
     JComboBox comboBox;
     boolean moving;
     boolean overload;
     /* End Variable Declarations */
     Polygon()
     { //start Polygon contructor
          addWindowListener(new WindowAdapter()
                    public void windowClosing(WindowEvent e)
                              System.exit(0);
               }); // ends anon class for window closing (ends program)
     /* Creation of the MenuBar */
     JMenuBar menu = new JMenuBar();
     JMenu menuColor = new JMenu("Color");
     JMenuItem makeRed = new JMenuItem("Red");
          menuColor.add(makeRed);
          makeRed.addActionListener(this);
     JMenuItem makeBlue = new JMenuItem("Blue");
          menuColor.add(makeBlue);
          makeBlue.addActionListener(this);
     JMenuItem makeGreen = new JMenuItem("Green");
          menuColor.add(makeGreen);
          makeGreen.addActionListener(this);
     JMenuItem makeYellow = new JMenuItem("Yellow");
          menuColor.add(makeYellow);
          makeYellow.addActionListener(this);
     menu.add(menuColor);
     setJMenuBar(menu);
     /* End Creation of the MenuBar */
     /* Creation of the Combo box*/
     Object [] items = {"Red", "Blue", "Green", "Yellow"};
     JComboBox comboBox = new JComboBox(items);
     getContentPane().add(comboBox, BorderLayout.SOUTH);
     comboBox.addActionListener(new ActionListener()
               { //start anon class
                    public void actionPerformed(ActionEvent e)
                         { //start action Performed
                              JComboBox comboBox = (JComboBox)e.getSource();
                              String comboString = (String)comboBox.getSelectedItem();
                                   if(comboString.equals("Red"))
                              color = Color.red;
                                   else if(comboString.equals("Green"))
                                        color = Color.green;
                                   else if(comboString.equals("Blue"))
                                        color = Color.blue;
                                   else if(comboString.equals("Yellow"))
                                        color = Color.yellow;
                         } //end actionPerformed
                    } //end anon class
               ); //end function call for anon class
     /* End Creation of the Combobox */
     }// end Polygon contructor
     public void actionPerformed(ActionEvent e)
     {  // begins Actions
          JMenuItem menu = (JMenuItem)e.getSource();
          String menuString = menu.getText();
     if(menuString.equals("Yellow"))
     color = Color.yellow;
     comboBox.setSelectedItem("Yellow");
     else if(menuString.equals("Red"))
     color = Color.red;
     comboBox.setSelectedItem("Red");
     else if(menuString.equals("Blue"))
     color = Color.blue;
     comboBox.setSelectedItem("Blue");
     else if(menuString.equals("Green"))
     color = Color.green;
     comboBox.setSelectedItem("Green");
     } //ends Actions
public static void main (String []args)
     JFrame frame = new Polygon();
     frame.setTitle("Project 3");
     frame.setSize(300, 300);
     frame.setVisible(true);
} //end main
}//end Ploygon Class

hi
I checked ur code.
the problem is that u have initialized objects more than one time un necesssarly.
my friend for selecting an item from a combo box there are some methods iside java plz refer to them.
do not use String .equal() ...
i am sue that u will get ue souirce code copiled if u remove those problem,s.

Similar Messages

  • Filtering values of a query in a web template through URL. Help please!

    Hi all,
    I've designed some web templates based on 3.x queries and I'm facing a problem trying to filter the values the users can see, though URL.
    I know how to filter a value of a characteristic in the URL, for example:
    http://.../SAP/BW/BEX?...&CMD=LDOC&TEMPLATE_ID="web_template_name"&FILTER_IOBJNM=0AREA&FILTER_Value=001
    It shows the default values for the characteristics (Area=1), but it doesn't restrict the query to these values. The problem is that the user can choose another value of the characteristic, through the navigation_block for example (Area=2 or 3 or...).
    What I need is to restrict the query in the URL with some values (Area=1 for example) so that the other areas don't appear in the query.
    I've read some documents but I don't have the solution yet. For example:
    http://help.sap.com/saphelp_nw04/helpdata/en/44/b26a3b74a4fc31e10000000a114084/frameset.htm
    Any ideas please??
    Iñaki

    Hi,
    For your scenario you could use variables which are not changeable during runtime. Please refer to the following documentation. If you do not check the option 'Can Be Changed with Query Navigation' the variable will not be changeable during navigation.
    http://help.sap.com/saphelp_nw04/helpdata/en/22/1e9b3c334d8c15e10000000a114084/frameset.htm
    If you want to restrict certain users to certain data please also consider the authorization concept, which is the safest way of doing this.
    Best regards,
    Janine

  • Help please deploying Crystal Decisions 10 to Microsoft 2008 R2 IIS 7

    Folks, I need your help please. We've been using Crystal Decisions 10 with MS Server 2003. We're migrating to a VM envirionment with MS Server 2008 R2. I have everything working except for our crystal reports. We are a mostly an ASP Classic enviroment.
    When the report is called it opens, the SP query does not fail but the data does not show in the activex viewer. If there is a tree view associated with the report, you can see the expandable data points on the left but the report does not actually appear. No errors are apparent either.
    This thing is killing my production. Any help would be greatly appreaciated!

    Hi Jack
    I moved your post to the SAP Crystal Reports - Legacy SDKs SCN Space.
    I really doubt that you will ever get this working. As Sastry mentioned, CR 10 did not support MS Server 2008 R2. The only version of CR (using classic ASP) to support anything close (WIN 7) was CR XI R2 (v. 11.5.x), Service Pack 6. See the following wiki for more details:
    Crystal Reports v. 9.1 to SAP Crystal Reports, developer version for Microsoft Visual Studio Runtime Distribution and S…
    For CR XI R2 SP 6 and WIN 7 I wrote a small blog - essentially collating info reported by customers on how to get ASP working - on WIN 7 (sometimes this works, other times...). See:
    Report Designer Component (RDC) in classic ASP applications on Win 2008 Server and Win 7 - Possible Solutions
    Please note that both CR 10.x and 11.5.x are out of support (have been for years). My recommendation, understanding that porting the app to more recent versions of CR and either the .NET or Java SDK is not possible:
    Update to CR XI R2 and keep your fingers crossed. Your chances of getting this to work CR 10 are pretty well zero. Your chance of getting this to work with CR XI R2 SP 6 are better, but still approaching zero. You may be able to obtain CR XI R2 by calling sales (866-681-3435) or check the Worldwide Office Locations | SAP.
    Last note. If you do manage to get CR XI R2, please so keep in mind that:
    1) CR XI R2 is no longer supported.
    2) You will be using CR XI R2 in an unsupported environment (Server 2008).
    - Ludek
    Senior Support Engineer AGS Product Support, Global Support Center Canada
    Follow us on Twitter

  • WRAP UTILITY, Any help please!

    Hi Gurus,
    Can I know if Wrap utility is also installed as part of options during Oracle Client installation.
    I had a problem as stated below from oracle cleint using on of my applications.
    java.io.IOException: wrap: not found
    at java.lang.UNIXProcess.forkAndExec(Native Method)
    at java.lang.UNIXProcess.<init>(UNIXProcess.java:72)
    at java.lang.Runtime.execInternal(Native Method)
    at java.lang.Runtime.exec(Runtime.java:602)
    at java.lang.Runtime.exec(Runtime.java:461)
    at java.lang.Runtime.exec(Runtime.java:397)
    at java.lang.Runtime.exec(Runtime.java:359)
    at com.r2000.integration.wcif.dbtools.EncodeScript.wrapPLSQL(EncodeScript.java:83)
    at com.r2000.integration.wcif.dbtools.EncodeScript.beginEncoding(EncodeScript.java:216)
    at com.r2000.integration.wcif.dbtools.IGP.begin(IGP.java:149)
    at com.r2000.integration.wcif.dbtools.IGP.main(IGP.java:231)
    Any help please?

    Can you get it now? Any help? I don't know what gets installed as part of the Oracle client only - I'm surrounded by servers, no client machines. What this suggest to me is that you don't have a test environment that replicates your users' environment. This is a dangerous practice and will likely lead you to deliver applications with broken dependencies, if you haven't already (which you apparently have).
    Which I suppose is not very helpful to your current situation but you at least know what you need to do to avoid this situation in the future.
    Cheers, APC

  • I keep being asked to update my Safari but when I do a Software update it scans but never gives me a list and just says no new updates. Help please!

    I keep being asked to update my Safari but when I do a Software update it scans but never gives me a list and just says no new updates. Help please!

    There are no updates to either OS 10.5.8 or Safari 5.0.6.
    If you need a later version of Safari you must first upgrade your operating system to a later version of OS X.

  • At the end of my IMovie I want to write some text: as in" Happy Birthday Mandy we had a great time with you. etc..  How do I go about this? Which icon in IMovie lets me have a place to write text?? help please

    Please see my ? above: Im making an IMovie and need the last frame to just be text (can be on a color). I don't know how to go about doing this.  Ive already done all my photos and captions. Need to have it ready for TOMORROW: Friday May 23rd. Help please!
    Thanks

    You can choose a background for the text from Maps and Backgrounds.  Just drag a background to the end of the timeline, adjust to desired duration then drag title above it.
    Geoff.

  • I have just updated my PC with version11.14. I can no longer connect to my Bose 30 soundtouch via media player Can anyone help please

    I have a Bose soundtouch system .Until today I could play my iTunes music through it via air  player . .I have just uploaded the latest upgrade from iTunes and now I am unable to connect to the Bose system . Can anyone help please? I can connect via my iPad and by using the Bose app so it is not the Bose at fault

    @puebloryan, I realize this thread is a bit old, but I have encountered a similr problem and wondered if you had found a solution. I've been using home sharing from itines on my PCs for years, but two days ago, it suddenly stopped. I can share from my Macs, but not from the ONE PC library where I keep all my tunes. I tried all the usual trouble-shooting measures.
    After turning home sharing off on the PC's iTunes, turning it back on and turning some other settings off and on, my Macs and Apple TV could briefly "see" the PC library, but as soon as I try to connect -- the wheel spins for a bit and then the connection vanishes. It's as if they try and then give up.
    Since this sounds so similar to your problem, I was hoping you finally found a solution. I am also starting a new thread. Thanks!

  • My iMac 24 can no longer be paired with the keyboard; it doesn't recognise any keyboard at boot up, even the one it is paired with. Can anyone help, please?

    My iMac 24 can no longer be paired with the keyboard; it doesn't recognise any keyboard at boot up, even the one it is paired with. Can anyone help, please?
    Thank. Simon

    Brian - The batteries are fine and there has only every been one keyboard paired with it. We have tried my MacPro keyboard as well, and it will not even recognise that there is a discoverable keyboard nearby.
    Thanks, Simon

  • Photoshop Elements 6 on Mac help please !!!!!

    Hi there,
              I need help please !!!!!
    I have PSE 6 for my imac and bought myself a NIKON D60 so far so good. I have installed PSE 6 which comes with ADOBE Bridge CS3
    I have bought a book as well as I am new to photoshop and in fact DSLR cameras.
    I have got my photos into Bridge OK by the way they are JPEG format. According to the book I can open the JPEG in camera RAW by either selecting the JPEG and then pressing cmd+R or by selecting the JPEG and select open with and camera RAW should be available to selct.
    I cannot get of the options to work any ideas please
    Secondly I have taken some photos in RAW format and put then into Bridge again I cannot get the camera RAW interface to open with these neff images.
    If I try to open the image PSE 6 opens and gives me an error that the file format is not supported by PSE 6
    Am I missing something here as I have been trying for a week now !!!!!
    Sorry if this comes across a stupid question but it is new to me
    Chris      UK

    There's no "theory" about it. You should be able to open a raw file from bridge by double-clicking it, but it will open in ACR in PSE. You can't just use ACR within bridge in PSE, if that's what you're trying to do. To open a JPEG in ACR, go to file>Open in PSE and choose Camera raw as the format after you select the file but before you click Open.
    If you've correctly updated ACR, bridge should show you thumbnails of your raw files. If it doesn't try emptying the Bridge cache.

  • Photoshop CS2. Help please.

    Approx 8 years ago I purchased Photoshop CS2 online from Adobe. This past weekend I had to buy a new computer (Windows 8.1), and when I logged into my Adobe account just now to obtain my serial number and enter it after I attempted to download CS2, it said invalid serial number. Help please.
    Both tech support and the online chat person were not able to help me.

    The Activation Servers for CS2 and prior have been taken down. See the link below for an explanation and solution. Be sure to follow all directions, including using the new download serial number supplied on the page.
    CS2 and prior
    http://helpx.adobe.com/x-productkb/policy-pricing/creative-suite-2-activation-end-life.htm l
    --OB

  • I  used to have an OLD Photoshop cd but it has been lost and my program is no longer on cd. I talked with some photographer friends and this is what one of them told me to get: Adobe Photoshop Lightroom and CS CC... HELP please?

    I  used to have an OLD Photoshop cd but it has been lost and my program is no longer on cd. I talked with some photographer friends and this is what one of them told me to get: Adobe Photoshop Lightroom and CS CC... HELP please?

    If you still have your serial number, look at OLDER previous versions http://www.adobe.com/downloads/other-downloads.html
    Otherwise, the US$ 9.99 plan is what is current at Cloud Plans https://creative.adobe.com/plans

  • Creative live cam voice help please

    Help please,
    We are using the "live cam voice" model, with our computer (Vista 32bit), that appears to work OK, but after a few minutes we get the BSOD! We have tried un installing and re-installing drivers without any effect.Has anyone had this problem and if so how did you fix it.
    Regards,
    Arthur

    Thanks for your response. I have tried 3 ports so far, all with the same outcome. One of my sons had it happen to him on another computer (XP SP2) using this webcam . As to programmes open at the same time, I am not computer literate and have no idea what programmes were running on each occasion.We use the webcam for Skype and apart from that I may also have IE open and perhaps Outlook Express. Over and above those CS4 sometimes.
    If I cannot resolve this, can any one suggest another webcam please.
    Regards,
    Arthur

  • I get error message "unknown error" When trying to log on to itunes via pc, help please!

    I get error message "unknown error" When trying to log on to itunes via pc, help please!

    Hello, trolle56.
    Thank you for the question.  You may find these articles helpful in troubleshooting the error received with the iTunes Store. 
    Can't connect to the iTunes Store
    http://support.apple.com/kb/ts1368
    iTunes: Advanced iTunes Store troubleshooting
    http://support.apple.com/kb/ts3297
    Cheers,
    Jason H. 

  • I downloaded an upgrade to my adobe reader today, and ever since my search engine has switched to yahoo and wont change back to google. I have a macbook pro, help please? Does anyone know how I can change this back? I have tried through my settings but it

    I downloaded an upgrade to my adobe reader today, and ever since my search engine has switched to yahoo and wont change back to google. I have a macbook pro, help please? Does anyone know how I can change this back? I have tried through my settings but it doesnt work

    Hi Timia,
    If you are using Safari as a web browser :-
    Open Safari, go to Safari menu > Preferences > General, and put Google as the homepage. Then, choose Google as your default search engine.
    If you are using Google Chrome as the web browser :-
      Open Google Chrome.
      In the top right corner of the page, click the Chrome menu Chrome menu > Settings.
      In the "Search" section, select Google from the drop-down menu.
    Let me know if you still experience any issue.
    Regards,
    Aadesh

  • Will My Purchased Songs On My iPod Be affected if i sync my itunes library to my iPod?Help Please!

    A Song that i purchased on my iPod Wasnt able to get into my itunes library somehow ,and i want to sync my itunes library to my iPod because i recently Got a store brought CD and i want to insert it ,but im afraid my songs will get deleted ,especially my purchased ones...can someone help please ?

    Just sync. You can alway redownload iTunes purchases by:
    Downloading past purchases from the App Store, iBookstore, and iTunes Store

Maybe you are looking for

  • Photobooth recording videos cuts out

    Hiya my one month old macbook pro, was just using it today for a bit of fun, so i set the application up, starting recording while me and my friend did our act in front of the camera. as usual, i pressed stopped when we had finished (after 3 minutes)

  • MacBook Pro USB cable iPhone internet

    Hi I am a management consultant and the only one I know who is Mac based down here in Sydney, Australia. I use an iMac as my main office machine and configure a *MacBook Pro* using ChronoSync when I go interstate to see clients or run strategy worksh

  • Shopping cart directly picking up the contract in the backend

    Hello All when a shopping cart is created in Classic scenario with a product category , the system is picking up the Contract directly from the backend. There is a contract maintained in the backend for the Product category that has been used in the

  • Faces doesnt seem to work..

    I have about 50,000 photos on my Imac (which they say should not slow down iphoto, but I think it must). When I turned on faces and named my son, who should have several thousand, only about 20 came up, and half of them were of other people..am I doi

  • My adobe garamond font has disapeared from my font book any ideas on how to get it back please?

    My adobe garamond font has disapeared from my font book any ideas on how to get it back please?