Combobox Selection Issue

I have an application that populates combobox2 based off of the selection made in combobox1. When a selection in combobox1 is made, I call a function that connects to a database and gets a list of all compatible parts for the selection in combobox1 from the MySQL table. I read the result set into a vector. I then pass the vector to combobox2 and it displays the list. Everything works perfectly.
The columns in MySQL are: sku, manufacturer, speed, cores, fsb, cache, l1,l2, compatible. I am puling out everything but the sku and compatible, and adding them to each row of the vector.
The problem I have is that after the user picks the option they want and it is time to submit the form, I want to get the sku number associated with their selection. Unfortunately, I can't go back to the database, as the manufacturer, speed, cores, fsb, cache, l1 and l2 might match hundreds of records. (I am using the column called "compatible" to determine which records go with which combobox1 selections).
What I can not seem to grasp, is what data structure I need to use to store the sku and the manufacturer/speed/cores/fsb/cache/l1/l2 so that they can be related to one another inside the combobox. I don't want to display the sku to the user, as that is unnecessary information.
There is a way in VB.net to set a value for a selection in the combobox, so that what is selected and what is sent to the system can be different. I don't know if something like that exists in Java. I don't know if something like an ArrayList would be better.

I may have just answered my own question. I can still go back to the database and pull the sku based on description, I just have to remember to include a check against the compatible list.(There should never been two rows with the exact same description for the exact same system.) However, that will require me to break out my string. See, when I read the a row into the vector I do:
optionsVector.add(rs.getstring("manufacturer" + "speed" + "cores" + "fsb" + "cache" + "l1" + "l2");
So in reverse I would have to break out the line "Intel, 2.5ghz, 4 cores, 800mhz, 8mb, 512k, 512k" into the original format and then search. Should be easier with the commas as delimiters. Still, seems like there should be an easier way.

Similar Messages

  • Runtime loading of XML file off a ComboBox selection

    I need to load an XML file at runtime based on a ComboBox
    selection that has the XML file path as its data.
    I figured out how to load an XML file at runtime by defining
    an HTTPService
    <mx:HTTPService id="stocksXML" url="xml/StockList.xml"
    resultFormat="e4x"/>
    and setting the <mx:Application
    creationComplete="stocksXML.send();"
    But when I now try to set the HTTPService url dynamically in
    the ComboBox change event handler
    private function loadData_changeHandler(event:ListEvent):void
    stocksXML.url = event.target.selectedItem.path;
    stocksXML.send();
    no data gets retrieved and the stocksXML.lastResult is null.
    What am I missing here? Why doesn't that work?
    Thanks in advance for any pointers

    I suggest adding a resultHandler to the HTTPService and check
    the results there. Also add a faultHandler so that you will know
    what the error was.

  • Change Data Provider Based on ComboBox Selection

    Complete noob using Flash CS5 for Macs. I have a ComboBox component and a TileList. I want the ComboBox selection to change the data provider for the TileList. I've used a sample script from the Adobe website at the bottom, but it is not working in this context. Google returns no better examples. Can anyone point me in the right direction?
    import fl.controls.ComboBox;
    import fl.data.DataProvider;
    import flash.display.DisplayObject;
    import flash.display.MovieClip;
    import fl.events.DataChangeEvent;
    // Combo Box ("aCb")
    var aCb:ComboBox = aCb;
    var Choices:Array = new Array(
        {label:"Artist Resin", data: "resin"},
        {label:"Ceramic", data: "ceramic"}
    aCb.dataProvider = new DataProvider(Choices);
    // TileList ("aTl")
    aTl.columnWidth = 110;
    aTl.rowHeight = 130;
    aTl.setSize(110,150);
    aTl.move(20, 150);
    aTl.setStyle("contentPadding", 5);
    // TileList Content
    var i:uint = 0;
    var resinitems:Array = [
    {label: "Image 1", source: "http://www.helpexamples.com/images/montreal/images/IMG_5057.jpg"},
    {label: "Image 2", source: "http://www.helpexamples.com/flash/images/gallery2/images/IMG_1592.jpg"}];
    var resin:DataProvider = new DataProvider();
    for(i=0; i < resinitems.length; i++) {}
    var ceramicitems:Array = [
    {label: "Image 3", source: "http://www.helpexamples.com/flash/images/gallery1/images/pic11.jpg"},
    {label: "Image 4", source: "http://www.helpexamples.com/flash/images/gallery1/images/pic14.jpg"},];
    var ceramic:DataProvider = new DataProvider();
    for(i=0; i < ceramicitems.length; i++) {}
    addChild(aCb);
    addChild(aTl); 
    // Code to Change Data Provider for Tile List
    aCb.addEventListener(Event.CHANGE, changedataProvider);
    function changedataProvider(event:Event):void {
        aTl.dataProvider = event.target.selectedItem.data;

    Thanks for your answers.
    I have already checked those links.
    Now th problem what I am facing is,
    I am not able to call the function ChangeLanguage through javascript.
    I have created a dropdwon using Hovermenu and added English and German.
    Now when I click on these the function should be called.
    Please help me in getting how setClientSideScript() can be used to call a function.
    or any other way to call the function after clicking on Hovermenu Item.
    Thanks in advance,
    Sumangala

  • ComboBox fullscreen issue

    Short version: ComboBox's dropdown works and renders  properly before fullscreen, but not during or after.
    I'm not  totally sure how to ask this, so I've actually made a page demonstrating the  error, with a very simple Flex app, and all three directions you  need to experience the problem yourself.
    For those of you not daring enough  to follow my link above, I'll do my best to explain here. I've built a  more extensive Flex application (not the one in the link) that has some  graphs and charts and checkboxes and other controls for those charts. At  the bottom of app in a few of the application States, there is a ComboBox.  Because this is at the very bottom, when you click it to access it's dropdown menu, Flex thoughtfully has it come out of the top.  Yay, Flex!
    This works  well until Fullscreen mode. Upon entering fullscreen, I scale everything  up with a stage.scaleMode = StageScaleMode.SHOW_ALL. Now when you  click on the ComboBox, the dropdown is astonishingly large, and  actually drops beneath the ComboBox, causing it to mostly disappear  off-screen. The best part is, once you exit fullscreen mode, the  dropdown insists on continuing to drop below the ComboBox, which is  positioned at the bottom of the app, and so continues to be cut off.
    Has anyone else run into this beast, stared into it's great maw, and come away victorious?  Am I doing fullscreen mode wrong?  Please help!
    You can get the source code via View Source from the Flash player in the link, and thank you so much for your time.

    Thanks for the prompt reply!
    Here is a link to my identical, but two week old post on the Flex forums: [Flex] ComboBox fullscreen issue.  I believe the answer to your question is "no".
    Additionally, I have filed a bug report under the Flash player category to this effect, as well as doppelganger posts on Stack Overflow and Flexcoders.  This is the first human response I've gotten on this issue to date, but I did earn an S.O. badge for having no responses for such an extended period of time.
    I posted here after this prolonged duration of nothing, and because I thought perhaps it wasn't an issue with the language, but rather the way it was rendered in the player.  I have no idea where I should be getting answers for this from, but the problem isn't going away on it's own or through my repeated attempts at a solution.  So if this helps me even get directed to the right place, I will be grateful.
    Thank you!

  • How i can make some components visible on comboBox selection change ?

    Hi
    Thank you for reading my post
    how i can make some of form component visible/ invisible when user changed a combobox selected item ?
    can we use partial rendering ?(i just read that ADF support partial rendering)
    thanks

    http://technology.amis.nl/blog/?p=1211

  • Menu selection issues in Flash CS4 for Mac

    I'm having a few menu selection issues in Flash. It seems some fields are de-selecting automatically (and quickly). For instance:
    1) When I double-click a layer to change it's name, it highlights then immediately de-selects. I can only rename by right-clicking and bringing up the Properties dialog.
    2) Fields highlight briefly then immediately de-select in the Properties menu when using the Tab button to advance or cycle thru fields. I have to click on each field individually to enter dimensions/characters.
    Possibly related...
    On occasion, I'm having an issue in Photoshop where the tools are off by 30 pixels or so. Examples:
    - Paint brush affects an area approximately 30px to the right and down from the brush head.
    - Selection tool selects an area approximately 30px to the right and down from the arrow head.
    This only happens on occasion and can be fixed by restarting Photoshop. I have not had any luck fixing the problems experienced within Flash.
    I'm experiencing this on two different machines that have CS4 installed. My only guess is a conflict with a Logitech driver OR a Wacom driver, but I have uninstalled the software and unplugged the Logitech mouse and Wacom tablet to no avail.
    Long time Flash/Photoshop user.... never had a problem like this.
    Anyone else have these issues or know a fix?
    Mac OS X 10.5.7
    Macbook Pro & iMac
    Logitech Control Center 2.7.0
    Wacom Driver 6.1.1-2(RC) for Mac OS X v. 10.4 & 10.5

    Hi there,
    This is a known issue, however we have not been able to reproduce it internally. The way to fix it (assuming it's the same problem) is to change your workspace (such as resetting to a default shipping layout, and then modifying from there), as it seems as though something about the workspace is causing the problem. It could be very specific to where its layed out on your monitor(s), some exact pixel size of a panel and/or grouping - and so on. However, we haven't been able to reproduce this internally yet - only reproed and fixed similar problems - so I cannot say for sure, however changing the workspace has fixed it for the other users I've talked to seeing this one.
    If you are able to share the following about one or both of your computers and send it to jdh (at) adobe, greatly appreciated:
    * workspace XML file from the Configuration directory (before changing the workspace!)
    * description monitor layout (ie: primary on left, secondary on right... or "one" )
    * monitor resolution(s)
    * screenshot(s) of your layout exhibiting the problem
    Thanks!

  • Datagrid select issue

    I am using flex builder 2.01 and have been using datagrids
    for a while now. I have recently ran into a weird situation where I
    have one datagrid out of three that just will not allow a manual
    selection. If I set the index to 0 for instance, the initial view
    of the datagrid shows the first item selected. If I go to select a
    different item, the first item becomes unselected and no other item
    can be selected. If I leave the initial state to be no item
    selected, I can never select an item. All other datagrids are
    working fine. I have tried to set selectable to true but that
    didn't help. This is really odd, any assistance would be greatly
    appreciated.

    Mmmm... Well the good news is I fixed it. The bad news is I
    have no clue why it fixed it. This particular datagrid is in a
    different tab in a tabnavigator panel. Attached is the expanded
    working code. On the line:
    <mx:Canvas label="Archived" width="100%" height="100%"
    id="ArchiveTab">
    I had a click="{GetPropertyArchive()}" to refresh the data on
    tab selection. This was old code that was made unnecessary at a
    later date but I did not remove the code. My guess is the datagrid
    assumed the characteristics of the parent tabnavigator and instead
    of ... wait that can't be right. If that was the case then changing
    the datasource would not have fixed the select issue because the
    'click' definition on the tabnavigator still existed. I would
    really like to understand why this mattered so I could avoid this
    issue in the future. Any ideas??

  • How set margin/padding top to combobox selected value

    Hi,
    Again I am facing new problem with combobox component, i need to set margin/padding top to combobox selected data using external AS file.
    I have tried the code --> combo_box.setStyle("marginTop", 5); and also used similar styles but its not working.
    Need your suggestions and help.
    Thanks.

    Hi,
    i strongly urge you to read some book about CSS and forget using deprecated HTML tags like FONT.
    Why am i saying that?
    Well, you don't want to change a page template or a report definition every time the user complains about the size of a font or the space between lines, do you?
    CSS is all about presenting the page the way you want, setting margins, spaces, fonts and so on.
    You should focus on the content, the data, leaving the task of formatting to one or more CSS stylesheet linked in the HTML header.
    I recommend reading some articles first, at least to have a general idea of mainstream techniques:
    http://www.alistapart.com/articles/goingtoprint/
    http://webdesign.about.com/cs/css/a/aa042103a.htm
    Or you can google around searching for "css formatting printer friendly" to get a bunch of pages.
    Flavio
    http://oraclequirks.blogspot.com

  • Changing variable with combobox selection - simple problem!

    Hi there,
    I have a search field when you click on search.
    I want to make it so i can change which field in a datagrid
    you search for depending on the choice in the Combbox. I'm not sure
    how to set the object name correctly depending on the combobox
    selection.
    I tried it like this, to no avail
    private var acOrder:ArrayCollection
    private var currentOrder:Object;
    ///////////////this is incorrect. What should i use instead
    of Object?//////
    private var whichArray:Object
    private function makeid():void
    whichArray = "orderid"
    private function makeemail():void
    whichArray = "email"
    private function filterByOrderid(item:Object):Boolean
    if (item.(whichArray) == filterTxt.text)
    ////I want this result to either be if (item.orderid ==
    filterTxt.text)
    ///or if (item.orderid == filterTxt.email)
    return true;
    else
    return false;
    private function doFilter():void
    if (filterTxt.text.length == 0)
    acOrder.filterFunction = null
    else
    acOrder.filterFunction = filterByOrderid;
    acOrder.refresh()
    i think answer is very simple. i just need to pass the name
    of the item inside the object correctly
    thanks very much for any help

    Hi,
    Try declaring whichArray as String and try this
    item[whichArray] instead of item.(whichArray).
    Hope this helps.

  • Combobox Selection Takes Action

    I am trying to learn how to use a combobox selection (two items in the list) to take and action such as changing the color of boxes I have acting as a border around my form or, better yet, possibly to hide or view a button. I am asking for help in devleoping a generic code into which I can insert the names of my fields I wish to hide or view.  Can anyone help?  I know NOTHING about Javascript.  Thanks in advance.
    Richard P

    The code below should work.  Each OPTION in each case is the name of your drop downs for the combobox.  You place the code in format under custom keystroke.  Everytime you choose one of the dropdowns it will run whatver code you placed for the case.  this.getField("YOURFIELDNAME").display = display.hidden should work for hiding, replace hidden with visible and voila.

  • Set PHTML ComboBox Selected Value in JavaScript?

    I've created a combobox as follows:
    <phtmlb:comboBox id                = "sdm_cnis"
      selection        = "<%= L_CIP_DETAILS_WA-GBSCIND %>"
       table             = "<%= l_cnis %>"
       readOnly       = "<%= l_display_mode %>"
       width             = "50px"
       nameOfKeyColumn   = "VALUE"
       nameOfValueColumn = "NAME"
       onClientSelect    = "javascript:sdm_toggle_required();return false;"
       behavior          = "DROPDOWNSELECT" />
    Based on the selected value of another dropdown combobox, I want to use JavaScript to select the value of this comboBox. For example, if the user changes the first comboBox, I want to automatically select the first option in this combobox. I really do not want to use dropdownListBoxes because they are not used anywhere else in our application. I also do not want to make a round trip to the server in order to resolve this issue as our uses will complain too much about that.
    Some other things I've learned/tried:
    I know I can get the selected value as follows:
    sapUrMapi_ComboBox_getSelectedKey('sdm_cnis');
    I have also tried to do the following, which sort of sets the value, but when you pull the list it appears as though the old selected value is still selected:
    window.document.getElementById('sdm_cnisKEY').value = cnis_key;
    window.document.getElementById('sdm_cnis').value = cnis_value;
    Any help is appreciated.
    Rick

    Managed to come up with a solution:
    window.document.getElementById('sdm_cnisKEY').value = cnis_key;
    window.document.getElementById('sdm_cnis').value = cnis_value;
    var o=sapUrMapi_ComboBox_getObject("sdm_cnis");
    o.txt.setAttribute("k",cnis_key);
    o.txt.setAttribute("ks",cnis_key);
    I'm not sure, but I would imagine that this solution is not supported by SAP and any patches or service pack upgrades could potentially break the code, so if you use it, be cautioned about this.
    I have tested it on our server, and it works for my current scenario. That said, if there is a better way to do this in JavaScript, I'd love to hear it. For now, I'll leave the question open and assign full points if someone can come up with something that I feel is better than this (i.e. a JavaScript solution that is supported by SAP).
    Rick

  • Combo Box Selection Issue in SBO 2007

    Hello.
    Here is one issue which I am facing now.
    I have just installed the 2007 Version of SBO in my machine. And using VB.Net.
    When I tried to retrieve the <i>Selected.Value</i> from a ComboBox, it is returning a wrong value.
    The real problem is this.
    Suppose there is two ValidValues in the Combo box
    1. <b>aaa</b>
    2. <b>bbb</b>
    and suppose we manually selected the value '<b>aaa</b>' in it.
    Then the combobox will show '<b>aaa</b>' as selected value.
    When we try to return it using the <i>Selected.Value</i> property, it returns <b>aaa</b>.
    then I tried to select '<b>bbb</b>' using a code which is here
    <i>oCombo.Select("bbb",SAPBouicom.BoSearchKey.psk_ByValue)</i>
    Now the combobox will show '<b>bbb</b>' as selected value. But,
    When we try to return it using <i>Selected.Value</i> property, It still returns <b>aaa</b>.
    If we select <b>bbb</b> manually, it will return <b>bbb</b>.
    IT ALWAYS RETURNS THE LAST MANUALLY SELECTED VALUE.
    here is the original Code which I tried in my application.
    <i>cboCategory.Select(CWRptMaint.ReportCategory, SAPbouiCOM.BoSearchKey.psk_ByValue)
    Dim s As String = cboCategory.Selected.Value
    Dim t As String = cboCategory.Selected.Description
    </i>
    Please Help me to solve this issue.
    Thank you
    Anoop

    HI
    I never had a problem about combobox not using datasource
    But here's the example code about combobox using datasource and not using datasource that i'm taken from one of my friend's project (VB6)
    '================================================================
    Public Type objectReportBA
        oComboBox As SAPbouiCOM.ComboBox
        oComboBox2 As SAPbouiCOM.ComboBox
        oUserDataSource As SAPbouiCOM.UserDataSource
    End Type
    Public oRBA As objectReportBA
    '==================================================================
        '// example Adding a Combo Box item not using user data source
        Set oItem = oFormReportBA.Items.Add("RCB1", it_COMBO_BOX)
        oItem.Left = 70
        oItem.Width = 85
        oItem.Top = 4
        oItem.Height = 18
        oItem.DisplayDesc = True
        Set oRBA.oComboBox = oItem.Specific
        oRBA.oComboBox.ValidValues.Add "1", "aaa"
        oRBA.oComboBox.ValidValues.Add "2", "bbb"
        oRBA.oComboBox.Select "bbb", psk_ByValue
        SBO_Application.MessageBox "Combo1->" & oRBA.oComboBox.Selected.Value       '<<<< will get a value = 2
        SBO_Application.MessageBox "Combo1->" & oRBA.oComboBox.Selected.Description '<<<< will get a description = bbb
    '==================================================================
        '// example Adding another Combo Box item and using datasource
        Set oItem = oFormReportBA.Items.Add("RCB2", it_COMBO_BOX)
        oItem.Left = 157
        oItem.Width = 163
        oItem.Top = 24
        oItem.Height = 14
        oItem.DisplayDesc = True
        Set oRBA.oComboBox2 = oItem.Specific
        oRBA.oComboBox2.ValidValues.Add "1", "aaa"
        oRBA.oComboBox2.ValidValues.Add "2", "bbb"
        oFormReportBA.DataSources.UserDataSources.Add "CombSource", dt_LONG_TEXT, 30
        oRBA.oComboBox2.DataBind.SetBound True, "", "CombSource"
        Set oRBA.oUserDataSource = oFormReportBA.DataSources.UserDataSources.Item("CombSource")
        oRBA.oUserDataSource.Value = "bbb"
        SBO_Application.MessageBox "Combo2->" & oRBA.oUserDataSource.Value  '<<< will get a value = bbb (but u will get diferent value if u click the combobox manually)
    '======================================================================
    'if you click the combobox manually using itemEvent
    Private Sub SBO_Application_ItemEvent(ByVal FormUID As String, pVal As SAPbouiCOM.IItemEvent, BubbleEvent As Boolean)
         Select Case pVal.ItemUID      
              Case "RCB1": '//combobox object not using datasource
                        If pVal.EventType = et_COMBO_SELECT Then
                            If pVal.BeforeAction = False Then
                                SBO_Application.MessageBox "combo1->" & oRBA.oComboBox.Selected.Description  '<<<< will get a description = aaa or bbb
                            End If
                        End If
              Case "RCB2": '//Combobox object that using datasource
                        If pVal.EventType = et_COMBO_SELECT Then
                            If pVal.BeforeAction = False Then
                                SBO_Application.MessageBox "combo2->" & oRBA.oUserDataSource.Value            '<<<< will get a descriptian = 1 or 2
                                SBO_Application.MessageBox "combo2->" & oRBA.oComboBox2.Selected.Description '<<<< will get a description = aaa or bbb
                            End If
                        End If
         end select
    end sub
    '===============================================================
    Hopefully this will Help You Anoop
    Regards
    Ancumen

  • Combobox selection changed

    Dear all,
    I'm newbie of javafx and I'm working on my first application.
    I found several issues, for now it doesnt' seems to me a very productive environment, due to lack of components and documentation.
    Now I stopped on a very basical question, but I can't go on.
    Iìve a combobox and I want to implement selection changed logic, that is basing on selected value some logic must be run.
    I didn't find any event like selection changed.
    Can you help me with some code or links?
    Thanks,
    Regards

    I guess you actually want to use a ChoiceBox (there is no ComboBox class in JavaFX :p).
    The best way I have in mind is binding the ChoiceBox.selectedItem to a variable and set an onreplace trigger on it. Like that:
    import javafx.stage.Stage;
    import javafx.scene.Scene;
    import javafx.scene.control.ChoiceBox;
    var choiceBox: ChoiceBox;
    var currentItem = bind choiceBox.selectedItem on replace{
        println("{currentItem} selected!");
    Stage {
        title: "MyApp"
        scene: Scene {
            width: 200
            height: 100
            content: [
                choiceBox = ChoiceBox {
                    items: ["Item1","Item2","Item3", "Item4"]
    }

  • ComboBox onEnterFrame Issue

    Hi,
    I have created an email form in one swf that is called into
    another swf. In this form there is a comboBox that will populate a
    text field when something is selected in it. Everything works fine
    with the comboBox in it's own swf but when it's called into another
    swf the comboBox is inactive. I'm not sure but I think it may have
    to do with the onEnterFrame.... here is the code from the swf that
    contains the comboBox and email information.
    import mx.remoting.Service;
    import mx.services.Log;
    import mx.rpc.RelayResponder;
    import mx.rpc.FaultEvent;
    import mx.rpc.ResultEvent;
    import mx.remoting.PendingCall;
    import mx.remoting.RecordSet;
    import mx.remoting.DataGlue;
    onEnterFrame = function(){
    area_ta.text = area_cb.value;
    submit_btn.onRelease = function() {
    if (question1_txt.text == "") {
    gotoAndStop ("error");
    }else{
    var pc:PendingCall = myService.mailSuggestion
    (question1_txt.text, area_cb.value);
    pc.responder = new RelayResponder (this,
    "mailSuggestion_Result","mailSuggestion_Fault");
    gotoAndStop ("correct");
    var myService : Service = new Service("
    http://******flashservices/gateway",
    new Log (Log.DEBUG),
    "tap.*******.emailfunction",
    null,
    null);
    stop();

    Thanks for helping me with this by the way...
    Ok I added the listener and that worked in it's own swf, but
    same issue when I pull from the main swf. I'll try putting it in
    the main swf but I would like to keep it in the one its in.
    Picture a website and when you click on Ask The Trainer
    button that calls a swf and in this swf there will be a combobox to
    select what area you are from and a text box that you will fill in
    your question in and then click submit. That sends an email
    containing the info from the combobox and the text field. So I
    would need them all in the same swf, wouldn't I?

  • Help with ComboBox Selection Update

    Hello,
    I am trying to make this application display all its labels in a different language depending on which locale the user picks from the ComboBox. The variables are being read from the ResourceBundles correctly (see command-line debugging statements) but I cannot get the pane to 'refresh' when the item is selected. I've tried everything I can think of! Please help! :)
    (This assignment was to internationalize a program we wrote for a previous assignment, so this program wasn't originally written to do this. I am trying to add this functionality to my existing project, so it's not ideal).
    Thank you for any advice, help or hints you can give!
    Program(PrjGUI)
    import java.awt.*;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.ItemEvent;
    import java.awt.event.ItemListener;
    import javax.swing.*;
    import java.text.DateFormat;
    import java.util.Calendar;
    import java.util.GregorianCalendar;
    import java.util.Locale;
    import java.util.ResourceBundle;
    import java.util.TimeZone;
    public class PrjGUI extends JFrame
       //**** Instance Variables for both classes
       private JRadioButton optGram, optOz;
       private JTextField txtWeightEnter, txtResult, txtDateTime;
       private JButton cmdConvert;
       private JComboBox comboSelectLocale;
            //arrays--one for combo box list, and the other for values to use when a particular list item is selected
       private String[] localeList = {"English, USA", "Fran\u00E7ais, France", "Espag\u00F1ol, M\u00E9xico"};
       private Locale[] localeCode = {(new Locale("en", "US")), (new Locale("fr", "FR")), (new Locale("es", "MX"))};
       private JLabel lblChoose, lblWeightEnter;
       protected String titleTxt, enterTxt, btnTxt, gramTxt, ozTxt, resultDisplayTxt, localeTimeZone, dateFormat;
       protected ResourceBundle res;
       protected Locale currentLocale;
       //declare Handler Object
       private CmdConvertWeight convertWeight;
       //**************main method******************
       public static void main(String[] args)
          PrjGUI convertWeight1 = new PrjGUI();
       }//end of main******************************
       //constructor
       public PrjGUI()
          //create panel for components
          Container pane = getContentPane();
          //set the layout
          pane.setLayout(new GridLayout(0, 1, 5, 5));
          //set the color
          pane.setBackground(Color.GREEN);
          //make a font to use in components
          Font font1 = new Font("SansSerif", Font.BOLD, 16);
          /**New calendar object to display the date and time*/
          GregorianCalendar calendar = new GregorianCalendar();
          DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL, Locale.US);
          /**currentLocale = localeCode[comboSelectLocale.getSelectedIndex()];
          DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL, currentLocale); //uses key for ResourceBundle*/
          TimeZone timeZone = TimeZone.getTimeZone("CST");
          //TimeZone timeZone = TimeZone.getTimeZone(localeTimeZone); //uses key for resourceBundle
          formatter.setTimeZone(timeZone);
          //***create UI objects***
          /**NEW OBJECTS FOR prjInternational:
           * a drop-down combobox, a label, and a txt field
          txtDateTime = new JTextField(formatter.format(calendar.getTime()));
          //txtDateTime = formatter.format(calendar.getTime());
          lblChoose = new JLabel("Please choose your language.");
          lblChoose.setFont(font1);
          lblChoose.setBackground(new Color(0, 212, 255)); //aqua blue
          comboSelectLocale = new JComboBox(localeList);
          comboSelectLocale.setFont(font1);
          comboSelectLocale.setBackground(new Color(0, 212, 255)); //aqua blue
          //comboSelectLocale.setSelectedIndex(0);
          //add a listener to the combo box to get the selected item
          /**default values for variables so I can debug--at the moment
           * I can't get the resouceBundle to work--it can't locate the
           * file.  So I will hard code these in for now.
          /*titleTxt="Food Weight Converter";
          enterTxt="Please enter the Weight you wish to convert.";
          btnTxt="Convert this weight!";
          gramTxt="grams";
          ozTxt="oz";
          resultDisplayTxt="Result will display here.";*/
          comboSelectLocale.addItemListener(new ItemListener()
               public void itemStateChanged(ItemEvent e)
                    res = setCurrentLocale(comboSelectLocale.getSelectedIndex());
                    System.out.println(res.getString("enterTxt"));
                    updateItems(res);
                  //set variables from Resource Bundle
                  /* titleTxt = res.getString("titleTxt");
                   System.out.println(res.getString("enterTxt")); //debug
                   enterTxt = res.getString("enterTxt");
                   btnTxt = res.getString("enterTxt");
                   gramTxt = res.getString("gramTxt");
                   ozTxt = res.getString("ozTxt");
                   resultDisplayTxt = res.getString("resultDisplayTxt");*/
          //2 radio buttons
          //optGram = new JRadioButton("grams", true);
          optGram = new JRadioButton(gramTxt, true);
          //optOz = new JRadioButton("oz.");
          optOz = new JRadioButton(ozTxt);
          optGram.setBackground(Color.GREEN);
          optGram.setFont(font1);
          optOz.setBackground(Color.GREEN);
          optOz.setFont(font1);
          //button group so only one can be chosen
          ButtonGroup weightUnit = new ButtonGroup();
          weightUnit.add(optGram);
          weightUnit.add(optOz);
          //label and text field for weight
          //JLabel lblWeightEnter = new JLabel("Please enter the weight you wish to convert:");
          JLabel lblWeightEnter = new JLabel(enterTxt);
          lblWeightEnter.setFont(font1);
          txtWeightEnter = new JTextField("20.05", 6);
          txtWeightEnter.setBackground(new Color(205, 255, 0)); //lime green
          txtWeightEnter.setFont(font1);
          //button to make conversion
          //cmdConvert = new JButton("Convert this weight!");
          cmdConvert = new JButton(btnTxt);
          cmdConvert.setFont(font1);
          //textfield to display result
          //txtResult = new JTextField("Result will display here");
          txtResult = new JTextField(resultDisplayTxt);
          txtResult.setBackground(new Color(205, 255, 0)); //lime green
          txtResult.setFont(font1);
          //register the handler
          convertWeight = new CmdConvertWeight();
          cmdConvert.addActionListener(convertWeight);
          //add content to pane
          pane.add(txtDateTime);
          pane.add(lblChoose);
          pane.add(comboSelectLocale);
          pane.add(lblWeightEnter);
          pane.add(txtWeightEnter);
          pane.add(optGram);
          pane.add(optOz);
          pane.add(cmdConvert);
          pane.add(txtResult);
          //create window for object
          setTitle(titleTxt);
          setSize(400, 300);
          setVisible(true);
          setLocationRelativeTo(null);
          setDefaultCloseOperation(EXIT_ON_CLOSE);
       }//end of constructor
       /**  ACTION LISTENER CLASS TO RESPOND TO USER'S INPUT (EVENTS) **/
       private class CmdConvertWeight implements ActionListener
          public void actionPerformed(ActionEvent e)
             //System.out.println("we made it to the Action Listener"); //debug
             //get info from fields
             double weight = Double.parseDouble(txtWeightEnter.getText());
             double weightConvert = 0;
             String weightConvertString;
             if (optGram.isSelected())//if user's weight is in grams, converting to oz
             weightConvert = weight/28.35;
             weightConvertString = Double.toString(weightConvert);
             txtResult.setText(txtWeightEnter.getText() + " grams is equal to " + weightConvertString + " oz.");
             }//end if gram select
             else if (optOz.isSelected())//if user's weight is in oz, converting to grams
             weightConvert = weight*28.35;
             weightConvertString = Double.toString(weightConvert);
             txtResult.setText(txtWeightEnter.getText() + " oz. is equal to " + weightConvertString + " grams.");
             }//end if oz select
         }//end actionPerformed
      }//end CmdConvertWeight
       /**setCurrentLocale method from combo box listener*/
       public ResourceBundle setCurrentLocale(int index)
            Locale currentLocale = localeCode[index];
            System.out.println(currentLocale); //debug
            System.out.println("MyResource_" + currentLocale); //debug
            ResourceBundle res = ResourceBundle.getBundle("MyResource_" + currentLocale);
            return res;
       }//end setCurrentLocale
       public void updateItems(ResourceBundle res)
            //convertWeight1.setTitle(res.getString(titleTxt));
            System.out.println(res.getString(btnTxt));//debug
            lblWeightEnter.setText(res.getString(enterTxt));
            optGram.setText(res.getString(gramTxt));
            optOz.setText(res.getString(ozTxt));
            cmdConvert.setText(res.getString(btnTxt));
            txtResult.setText(res.getString(resultDisplayTxt));
       }//end updateItems
    }//end of class PrjGUIResourceBundles(each in a different file)
    public class MyResource_fr_FR extends java.util.ListResourceBundle
         static final Object[][] contents =
              {"titleTxt", "Convertisseur de poids de nourriture"},
              {"enterTxt", "Veuillez \u00E9crire le poids que vous souhaitez convertir."},
              {"btnTxt", "Convertissez ce poids!"},
              {"gramTxt", "grammes"},
              {"ozTxt", "onces"},
              {"resultDisplayTxt", "Le r\u00E9sultat montrera ici."},
              {"localeTimeZone", "CET"},
              {"dateFormat", "Locale.FR"}
         public Object[][] getContents()
              return contents;
    public class MyResource_es_MX extends java.util.ListResourceBundle
         static final Object[][] contents =
              {"titleTxt", "Convertidor del peso del alimento"},
              {"enterTxt", "Incorpore por favor el peso que usted desea convertir."},
              {"btnTxt", "\u00F1convierta este peso!"},
              {"gramTxt", "gramos"},
              {"ozTxt", "onzas"},
              {"resultDisplayTxt", "El resultado exhibir\u00E1 aqu\u00ED."},
              {"localeTimeZone", "CST"},
              {"dateFormat", "Locale.MX"}     
         public Object[][] getContents()
              return contents;
    public class MyResource_en_US extends java.util.ListResourceBundle
         static final Object[][] contents =
              {"titleTxt", "Food Weight Converter"},
              {"enterTxt", "Please enter the weight you wish to convert."},
              {"btnTxt", "Convert this weight!"},
              {"gramTxt", "grams"},
              {"ozTxt", "oz"},
              {"resultDisplayTxt", "Result will display here."},
              {"localeTimeZone", "CST"},
              {"dateFormat", "Locale.US"}
         public Object[][] getContents()
              return contents;
    }Edited by: JessePhoenix on Nov 2, 2008 8:30 PM

    catman2u wrote:
    does anyone from Lenovo actually read this forum?
    From the Communiy Rules in the Welcome section....
     Objectives of Lenovo Discussion Forums
    These communities have been created to provide a high quality atmosphere in which users of Lenovo products and services may share experiences and expertise. While members from Lenovo may participate at intervals to engage in the discussions and offer advice and suggestions, this forum is not designed as a dedicated and staffed support channel. This is an informal and public forum, and Lenovo does not guarantee the accuracy of information and advice posted here -- see important Warranty information below.
    No amount of ranting is going to get you anything more than you will achieve with a clear exposition of your issue... so you might want to try doing that instead of ranting and assuming that everyone already knows what you know etc etc.
    Cheers,
    Bill
    I don't work for Lenovo

Maybe you are looking for