Having trouble with combo box.

What im trying to do is put a string array into this combo box called jComboBoxParts how do i make it show? Right now when i load it, all i see is "Item1..."Item2...etc". Here is my code.
String[] partsString = { "oil can", "windshield", "tires", "v6 Cylinder head", "fuse"};
JComboBox[] jComboBoxParts = new JComboBox[partsString.length];
for(int i=0; i < partsString.length; i++)
jComboBoxParts[i] = new *JComboBox(*partsString);
with the bolded work i get an error. Please help.

eva21 wrote:
What im trying to do is put a string array into this combo box called jComboBoxParts how do i make it show? Right now when i load it, all i see is "Item1..."Item2...etc". Here is my code.
String[] partsString = { "oil can", "windshield", "tires", "v6 Cylinder head", "fuse"};
JComboBox[] jComboBoxParts = new JComboBox[partsString.length];
for(int i=0; i < partsString.length; i++)
jComboBoxParts[i] = new *JComboBox(*partsString);
with the bolded work i get an error. Please help.
That's ugly in so many ways...
This:
JComboBox[] jComboBoxParts = new JComboBox[partsString.length];does not do what you think it does. Instead, it creates an array of JComboBoxes initialized to the length of elements in your string array. So instead of a single JComboBox capable of holding 5 elements (which is what you were trying to do), you created 5 JComboBoxes capable of holding n elements.
What you want to do is something like this:
import javax.swing.*;
class Demo extends JFrame {
  private JComboBox box;
  public Demo() {
    initComponents();
  private void initComponents() {
    String[] items = { "oil can", "windshield", "tires", "v6 cylinder head", "fuse" };
    box = new JComboBox(items);
    this.getContentPane().add(box);
    this.pack();
    this.setSize(200, 60);
    this.setLocationRelativeTo(null);
    this.setDefaultCloseOperation(EXIT_ON_CLOSE);
    this.setTitle("Combox Box Demo");
  public static void main(String[] argv) {
    SwingUtilities.invokeLater(new Runnable() {
      public void run() {
        new Demo().setVisible(true);
}Another alternative, if you don't have the array of strings available when you instantiate your JComboBox, you could do something like this:
String items = { "oil can", "brakes", "windshield", "tail light", "something else", "blah", "more blah" };
for( String item : items )
  myJComboBox.addItem(item);

Similar Messages

  • Having trouble with combo box in action script 3

    I have created a combo box in action script 3.0 and have some things working and others not. I am creating a store for shirts, caps, etc..... so need different things and rates. Can anyone help me?
    [email protected]

    Creating a STORE for my website and used combo buttons with types of shirts for one button, 2nd button with color, and third with sizes.
    Using Action Script 3.0 making these work and having trouble.
    HELP meaning if you can connect to my computer remotely and see where my problem is. I am happy to pay if works.

  • Trouble with combo box

    I am using a combo box with the code below, but each time I
    arrive on this
    screen that displays cbTREATMENT, the combo box first draws
    itself with the
    default style, then applies my style, which looks a bit ugly
    onscreen.
    Anything I can do to rectify this?
    Thanks.
    cbTREATMENT.setStyle( "fontSize", "13" );
    cbTREATMENT.setStyle( "color", "0x000000" );
    cbTREATMENT.setStyle( "fontWeight", "bold" );
    cbTREATMENT.setStyle( "fontFamily", "arial" );
    cbTREATMENT.dropdown.rowHeight = 18;
    cbTREATMENT.dataProvider=["","name1","name2","name3];
    cbTREATMENT.text=vTREATMENT;

    Thanks for the reply, but I'm not sure what you mean, can you
    explain any
    further?
    "niki tsanov" <[email protected]> wrote in
    message
    news:fm5qnf$elq$[email protected]..
    > Store your combobox only into the library after that try
    with
    > createClassObject() to make dynamicly ComboBox item into
    the stage for me
    > work perfect

  • I am having trouble with my Mac Mini's ethernet connection.   Defining a new network interface shows no ethernet adaptor.  Reloading SL from DVD repaired.  But SL update lost ethernet again.  Will Lion Fix?

    I am having trouble with my mac mini ethernet.  It had been working for weeks after an update to SL 10.6.8.
    Once it went out and i repaired it by defining a new connection from System Preferences ->Network->(left panel service, +).
    But yesterday, after a power up.  my ethernet was not working again. I tried this old trick to repair it, but the interface choices
    listed for '+' a new service did not include Ethernet any more.  And the Utilities->System Profiler->Ethernet Cards shows
    no ethernet available.
    As a last ditch effort i reloaded my original SL from DVD.  (I think it was version 10.6.4 but i could be mistaken on the version).
    The ethernet worked!  But KeyNote wasn't going to work because apparently the version i purchased depends on 10.6.8.
    So I upgraded again to SL 10.6.8 (Plus some other updates like AirPort which i don't use).
    Now the Ethernet is not working again.  I see the same symptoms as before with the Ethernet seeming not installed.
    Is this a problem seen by others?
    Would going to Lion fix the problem?
    Could AirPort actually be the culprit and not SL?
    If i stay with my original SL, would i need to repurchase a version of KeyNote for the older version of SL?

    Have you reset the SMC?
    Shut down the computer.
    Unplug the computer's power cord.
    Wait fifteen seconds.
    Attach the computer's power cord.
    Wait five seconds, then press the power button to turn on the computer.
    While you're at it, resetting the PRAM won't hurt anything and 'might' help is SMC reset didn't work (PRAM does some port control):
    Shut down the computer.
    Locate the following keys on the keyboard: Command, Option, P, and R. You will need to hold these keys down simultaneously in step 4.
    Turn on the computer.
    Press and hold the Command-Option-P-R keys. You must press this key combination before the gray screen appears.
    Hold the keys down until the computer restarts and you hear the startup sound for the second time.
    Release the keys.
    Something else you might try .... you don't say how you're updating to 10.6.8, however, if you're using Software Update, you might try downloading the 10.6.8 combo update, which contains all updates to 10.6. Sometimes, Software Update doesn't work quite right, and installing the combo update fixes that. Download the update from Apple's download site at http://support.apple.com/downloads/ , using Disk Utility repair permissions, apply the combo update, then repair permissions again.

  • I am having trouble with some of my links having images. For example, Foxfire has a picture that looks like a small world. The links in question are blank.

    I am having trouble with my links/websites having images attached to them. The place where the image should be is blank. For example, AARP has an A for its image. My storage website has a blank broken box where the image should be. I forgot I had trouble and had to reset Foxfire, this problem occurred after that reset.

    cor-el,
    Mixed content normally gives the world globe image, unless you are using a theme that uses a broken padlock instead. Maybe the gray triangle means invalid? I came across that in a few themes (what is invalid was not made clear), but those were not using triangle shapes to indicate that.
    I came across that mention in one of the pages you posted:
    * https://support.mozilla.org/kb/Site+Identity+Button
    I cannot attach a screenshot because I have not seen a triangle of any kind in my address bar.

  • Having trouble with image processor...help please!

    HI there...First off I just bought a new iMac and haven't a clue what I'm doing so my problem could be related to that.  While I'm waiting for Adobe to transfer over my platform I downloaded the trial of CS5 Extended to get me started.  I'm having trouble with the image processor...I choose file/scripts/image processor...the dialog box comes up and I choose use open files and then try and choose the folder I want to save them in.  I choose my folder and hit run and it keeps telling me specify folder destination.  I can't for the life of me figure this out...what am I doing wrong?  It always worked fine for me on my PC and CS3.  I can't handle saving each image individually in the new folder...
    Thanks!!

    I haven't renamed anything as far as I know.  I made a new folder when I hit Folder option and it's highlighted as well as the path shows up in the processor box.  Just when I choose run it tells me to specify a folder.  The only thing I can think of is that maybe something messed up b/c I'm copied the files and folders over from my PC but it let me save as on the mac.  Also the folder I'm choosing to put them in is on the Mac harddrive.  IDK...

  • I am currently having trouble with an attached PDF fill-able form created in Acrobat being non savable in Reader

    Hello, I was wondering if you would be able to help me out?
    I am having trouble with my attached PDF fill-able form, I am creating a form that has a limit of one page so in order for more room in a certain field I have added a Hyperlink to an additional fill-able(secondary) form within the Parent document (primary fill-able form. The secondary form is inserted as an attachment into the Primary form. My problem is when I open this document up in Adobe Reader, the Primary fill-able form is savable but the attached Secondary form for which the hyperlink leads to is non-savable and is a must print only. Is there a way to make the Secondary form savable as well within the same document? or is there another way I could execute what it is I am trying to achieve?
    Trying to save other as extended reader has not worked, also if I save the attachment file as an extended reader first I am unable to attach a return hyperlink back to the Parent document,
    Help would be greatly appreciated please and thank you!

    I can't say for certain without looking at the actual PDF but it does appear that they created one large text box over multiple lines. For a fillable form it may have been smarter to remove the lines and create a box with smaller text that supports multiple lines.
    At any rate, nothing you can do about it with the free Reader (and depending on the security, maybe nothing with Acrobat either.)

  • Having trouble with Yahoo home page sign in. Some time it brings up my wife's Yahoo log in instead of my log in how can I fix this?

    When I open Firefox it is suppose to take me to my Yahoo home page. But it opens up showing my wifes Yahoo sigh in page in stead of mine. Having trouble with Yahoo home page sign in. Some time it brings up my wife's Yahoo log in instead of my log in how can I fix this?

    Did your wife tick the box on the Yahoo sign in page to remember her for two weeks?
    It would be best two have two separate Firefox profile folders, one for each of you to prevent such problems.<br />
    Then you also do not have problems with deleting or changing bookmarks.
    * http://kb.mozillazine.org/Creating_a_new_Firefox_profile_on_Windows
    * http://kb.mozillazine.org/Shortcut_to_a_specific_profile
    * http://kb.mozillazine.org/Using_multiple_profiles_-_Firefox

  • Still having trouble with Gallery Slideshow

    Still having trouble with Gallery Slideshow, in Live Preview it bounces to  the top of the page but not centered where I like it.
    Hope someone can help.
    Thanks

    no is not hosted anywhere Im working on a Fantasy Photography site. from the image the top one is design mode and bottom is preivew mode. But my problem is
    as you can see from the images ( red boxes )  it moves when is in preview mode and the sizes of the images change as well as you can see. I dont know why? I tried figuring it out
    but no luck. I hope this helps.
    thanks

  • Hi, having trouble with my iMac on startup. Background screen appears, but no icons,

    Having trouble with my iMac- on startup, the background screen appears, but no icons. The spinning beach ball appears for quite a long while, then when the icons finally come up, when I open a finder window, the only icons to appear are the Network and Macintosh HD icons. I've tried to repair disk permissions: this came up with heaps of errors, which it then fixed, but the original problem remains.
    Any suggestions on how to fix this?
    thanks

    Please read this whole message before doing anything.
    This procedure is a test, not a solution. Don’t be disappointed when you find that nothing has changed after you complete it.
    Step 1
    The purpose of this step is to determine whether the problem is localized to your user account.
    Enable guest logins and log in as Guest. For instructions, launch the System Preferences application, select Help from the menu bar, and enter “Set up a guest account” (without the quotes) in the search box. Same problem(s)?
    After testing, log out of the guest account and, in your own account, disable it if you wish. Any files you created in the guest account will be deleted automatically when you log out of it.
    Note: If you’ve activated “Find My Mac” or FileVault in Mac OS X 10.7 or later, then you can’t enable the Guest account. Create a new account in which to test, and delete it, including its home folder, after testing.
    Step 2
    The purpose of this step is to determine whether the problem is caused by third-party system modifications that load automatically at startup or login.
    Disconnect all wired peripherals except those needed for the test, and remove all aftermarket expansion cards. Boot in safe mode and log in to the account with the problem. The instructions provided by Apple are as follows:
    Be sure your Mac is shut down.
    Press the power button.
    Immediately after you hear the startup tone, hold the Shift key. The Shift key should be held as soon as possible after the startup tone, but not before the tone.
    Release the Shift key when you see the gray Apple icon and the progress indicator (looks like a spinning gear).
    Safe mode is much slower to boot and run than normal, and some things won’t work at all, including wireless networking on certain Macs.
    The login screen appears even if you usually log in automatically. You must know your login password in order to log in. If you’ve forgotten the password, you will need to reset it before you begin.
    Same problem(s) in safe mode?
    After testing, reboot as usual (i.e., not in safe mode) and verify that you still have the problem. Post the results of steps 1 and 2.

  • Is anyone having trouble with their RAZR not ringing or only ringing sometimes? I also lose the use of any voice technology when this happens.

    Is anyone having trouble with their RAZR not ringing or only ringing sometimes? I also lose the use of any voice technology when this happens.

    What is going on with the motorola software fix?
    Tav Gauss CEO, President
    The Action Group, Human Resources Solutions
    252-237-3717
    1800-529-8470
    <http://www.theactiongrouphr.com/> www.theactiongrouphr.com
    PO Box 158
    Wilson North Carolina 27894-0158
    Follow The Action Group HR. Connect with us on  <http://capstr.at/Hd> Twitter |  <http://capstr.at/HY> LinkedIn |  <http://capstr.at/Hc> YouTube

  • I am having trouble with iPhoto-it won't launch.

    am having trouble with iPhoto-it won't launch and leaves a blank white screen box and spinning wheel of death-if I re-install software-will I lose all photos and faces settings? Any ideas-this is a Mac Pro and Xserve school system.
    It seemed to stem from when I was transferring some movie footage from an HD camcorder to iMovie.
    This is a school system and I'm worried I may lose many photos and face recognition data.
    Phil

    1. The library is separate from the application, so re-installing shouldn't cause an issue with the actual photos. But it would be foolhardy in the extreme to do anything without first backing up.
    2. Often these issues are caused by a damaged Library, so reinstalling doesn't change much.
    FWIW
    To re-install iPhoto
    1. Put the iPhoto.app in the trash (Drag it from your Applications Folder to the trash)
    2a: On 10.5:  Go to HD/Library/Receipts and remove any pkg file there with iPhoto in the name.
    2b: On 10.6: Those receipts may be found as follows:  In the Finder use the Go menu and select Go To Folder. In the resulting window type
    /var/db/receipts/
    A Finder Window will open at that location and you can remove the iPhoto pkg files.
    3. Re-install.
    If you purchased an iLife Disk, then iPhoto is on it.
    If iPhoto was installed on your Mac when you go it then it’s on the System Restore disks that came with your Mac. Insert the first one and opt to ‘Install Bundled Applications Only.
    If you purchased it on the App Store you can find it in your Purchases List.
    Alternative approach:
    Option 1
    Back Up and try rebuild the library: hold down the command and option (or alt) keys while launching iPhoto. Use the resulting dialogue to rebuild. Choose to Rebuild iPhoto Library Database from automatic backup.
    If that fails:
    Option 2
    Download iPhoto Library Manager and use its rebuild function. This will create a new library based on data in the albumdata.xml file. Not everything will be brought over - no slideshows, books or calendars, for instance - but it should get all your albums and keywords back.
    Because this process creates an entirely new library and leaves your old one untouched, it is non-destructive, and if you're not happy with the results you can simply return to your old one. .
    Regards
    TD

  • Having trouble with pop-up windows and ads for MacKeeper

    I've been having trouble with pop-up windows and ads for MacKeeper and similar "services." Tried to download "MPlayerX" a week ago and it all started then. I thought I deleted the file but I'm still having trouble. I've been digging for solutions on here, but nothing I've found on here has worked yet--the VSearch stuff (I think) isn't on my hard drive. Any advice?

    You installed a variant of the "VSearch" trojan. Remove it as follows.
    This malware has many variants. Anyone else finding this comment should not expect it to be applicable.
    Back up all data before proceeding.
    Triple-click anywhere in the line below on this page to select it:
    /Library/LaunchAgents/com.venus.agent.plist
    Right-click or control-click the line and select
              Services ▹ Reveal in Finder (or just Reveal)
    from the contextual menu.* A folder should open with an item selected. Drag the selected item to the Trash. You may be prompted for your administrator login password.
    Repeat with each of these lines:
    /Library/LaunchDaemons/com.venus.daemon.plist
    /Library/LaunchDaemons/com.venus.helper.plist
    Restart the computer and empty the Trash. Then delete the following items in the same way:
    /Library/Application Support/venus
    /System/Library/Frameworks/v.framework
    The problem may have started when you downloaded and ran an application called "MPlayerX." That's the name of a legitimate free movie player, but the name is also used fraudulently to distribute VSearch. If there is an item with that name in the Applications folder, delete it, and if you wish, replace it with the genuine article from mplayerx.org.
    This trojan is often found on illegal websites that traffic in pirated content such as movies. If you, or anyone else who uses the computer, visit such sites and follow prompts to install software, you can expect more of the same, and worse, to follow. Never install any software that you downloaded from a bittorrent, or that was downloaded by someone else from an unknown source.
    In the Security & Privacy pane of System Preferences, select the General tab. The radio button marked Anywhere  should not be selected. If it is, click the lock icon to unlock the settings, then select one of the other buttons. After that, don't ignore a warning that you are about to run or install an application from an unknown developer.
    Then, still in System Preferences, open the App Store or Software Update pane and check the box marked
              Install system data files and security updates (OS X 10.10 or later)
    or
              Download updates automatically (OS X 10.9 or earlier)
    if it's not already checked.
    *If you don't see the contextual menu item, copy the selected text to the Clipboard by pressing the key combination  command-C. In the Finder, select
              Go ▹ Go to Folder...
    from the menu bar and paste into the box that opens by pressing command-V. You won't see what you pasted because a line break is included. Press return.

  • I am having trouble with my IMac 27 2006

    I am having trouble with my IMac 27 2006 start up OK will run however picture stops, scattered all over screen shutters and then sometimes freezes. Can I reinstall OSX? Or is there a program that dose Fixes?

    How to Perform an Archive and Install
    An Archive and Install will NOT erase your hard drive, but you must have sufficient free space for a second OS X installation which could be from 3-9 GBs depending upon the version of OS X and selected installation options. The free space requirement is over and above normal free space requirements which should be at least 6-10 GBs. Read all the linked references carefully before proceeding.
    1. Be sure to use Disk Utility first to repair the disk before performing the Archive and Install.
    Repairing the Hard Drive and Permissions
    Boot from your OS X Installer disc. After the installer loads select your language and click on the Continue button. When the menu bar appears select Disk Utility from the Installer menu (Utilities menu for Tiger, Leopard or Snow Leopard.) After DU loads select your hard drive entry (mfgr.'s ID and drive size) from the the left side list. In the DU status area you will see an entry for the S.M.A.R.T. status of the hard drive. If it does not say "Verified" then the hard drive is failing or failed. (SMART status is not reported on external Firewire or USB drives.) If the drive is "Verified" then select your OS X volume from the list on the left (sub-entry below the drive entry,) click on the First Aid tab, then click on the Repair Disk button. If DU reports any errors that have been fixed, then re-run Repair Disk until no errors are reported. If no errors are reported click on the Repair Permissions button. Wait until the operation completes, then quit DU and return to the installer. Now restart normally.
    If DU reports errors it cannot fix, then you will need Disk Warrior and/or Tech Tool Pro to repair the drive. If you don't have either of them or if neither of them can fix the drive, then you will need to reformat the drive and reinstall OS X.
    2. Do not proceed with an Archive and Install if DU reports errors it cannot fix. In that case use Disk Warrior and/or TechTool Pro to repair the hard drive. If neither can repair the drive, then you will have to erase the drive and reinstall from scratch.
    3. Boot from your OS X Installer disc. After the installer loads select your language and click on the Continue button. When you reach the screen to select a destination drive click once on the destination drive then click on the Option button. Select the Archive and Install option. You have an option to preserve users and network preferences. Only select this option if you are sure you have no corrupted files in your user accounts. Otherwise leave this option unchecked. Click on the OK button and continue with the OS X Installation.
    4. Upon completion of the Archive and Install you will have a Previous System Folder in the root directory. You should retain the PSF until you are sure you do not need to manually transfer any items from the PSF to your newly installed system.
    5. After moving any items you want to keep from the PSF you should delete it. You can back it up if you prefer, but you must delete it from the hard drive.
    6. You can now download a Combo Updater directly from Apple's download site to update your new system to the desired version as well as install any security or other updates. You can also do this using Software Update.

  • Trouble with grey boxes around certain text or words

    We are having trouble with some of our
    InDesign files. When the text is flowed in from Word there are grey outline boxes showing up around certain words or phrases. We have been working with the preferences and also the dictionary and nothing seems to fix our problem.
    Any suggestions?
    Thanks for your help!

    Did you open the hyperlinks panel and delete the links, or change the highlight? You have to change the highlights one at a time, I think. (I hate Word's automatic hyperling nonsense).

Maybe you are looking for

  • HOW TO CHANGE HOST NAME AFTER SAP IS INSTALLED?

    i have installed ecc6 in my computer.But after installation is completed i want to change my computer(system) name.If i change the computer name is there any problem occur.May i change computer name after installation also.

  • How to make Hierarchy view  fixed in marketing plan .

    Hi Gurus, I have a requirement to make the Hierarchy view  as fixed ie To remove the toggel functionality . Component MPL_MAIN . for which I removed the toggel button and make the view visible all the times . I have removed the button by commenting t

  • How to open the NSComboBox list programmatically

    Been struggling with this all day. Perhaps I'm barking up the wrong tree. This is the scenario: I have a database of 8,000 items, represented to the user as text. The user has to pick one. I'm thinking NSComboBox. But 8,000 items is a lot, so I want

  • Problem setting an Open Password on an Adobe Interactive Form

    Hi, I'm generating a series of Adobe Interactive Forms using data pulled from R3 via BAPIs.  The PDFs are created without an issue but I want to put an Open Password on them (a password the user must enter in order to open the PDF).  From my reading

  • How to pull a last DML done on any table

    Hi Gyans, Is there a way for to pull the last DML done on any table, using normal sqlplus - if not then let me know the tool which you can use to do the same.