Combobox selection

Hi
I have a combo which is populated with some items. When I drop down and keep scrolling and, on my mouse movement over the listed items I should get a tool tip text and not when an item is selected.
My getSelectedItem works fine only when a selection is made with the click of the mouse and my setToolTipText is working fine after the getSelectedItem(), which is not all I want !
All I want is... Tool tip should be displayed before a selection is made by the click of mouse, i.e. when a drop down is made !!
Kindly help me out before I pluck every hair of mine
Thanx in advance
Mahadevan

In Handeling Events on a ComboBox in
http://java.sun.com/docs/books/tutorial/uiswing/components/combobox.html
It is recommended that we do not listen for low-level events like MouseEvents on ComboBoxes which are compound components. Low-level events are look-and-feel dependent.
See Concepts: Low-Level Events and Semantic Events in
http://java.sun.com/docs/books/tutorial/uiswing/events/generalrules.html
and finally, problem number three here
http://java.sun.com/docs/books/tutorial/uiswing/events/problems.html

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

  • 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

  • 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.

  • Problem with userdefined combobox selection

    Hi guys,
    Have an "AutoSearchComboBox" as follows for searching the combolist fast.Have some problems with the selection in the AutoSearchComboBox.
    *public class AutoSearchComboBox extends JComboBox {*
    private static final long serialVersionUID = 1L;
    *public AutoSearchComboBox(){*
    setEditable(true);
    setModel(new AutoSearchComboBoxModel());
    setEditor(new MyComboBoxEditor());
    public class AutoSearchComboBoxModel extends AbstractListModel
    *implements MutableComboBoxModel{*
    private static final long serialVersionUID = 1L;
    private Vector items,filteredItems;
    private Filter filter;
    private Object selectedItem;
    *public AutoSearchComboBoxModel(){*
    this.items = new Vector();
    this.filteredItems = new Vector();
    this.filter = null;
    updateFilteredItems();
    *public void addElement(Object obj) {*
    items.add(obj);
    updateFilteredItems();
    public void insertElementAt(Object obj, int index) {}
    *public void removeElement(Object obj) {*
    items.remove(obj);
    updateFilteredItems();
    *public void removeElementAt(int index) {*
    items.remove(index);
    updateFilteredItems();
    *public Object getSelectedItem() {*
    return selectedItem;
    *public void setSelectedItem(Object anItem) {*
    if ((selectedItem==null) && (anItem==null))
    return;
    if ((selectedItem != null) && (selectedItem.equals(anItem)))
    return;
    if(anItem!= null && anItem.equals(selectedItem))
    return;
    selectedItem = anItem;
    fireContentsChanged(this, -1,-1);
    *public Object getElementAt(int index) {*
    return filteredItems.get(index);
    *public int getSize() {*
    return filteredItems.size();
    *public void setFilter(Filter filter){*
    this.filter = filter;
    updateFilteredItems();
    *public void updateFilteredItems(){*
    fireIntervalRemoved(this,0,filteredItems.size());
    filteredItems.clear();
    if(filter==null)
    filteredItems.addAll(items);
    else
    *for(Iterator iter = items.iterator(); iter.hasNext();){*
    Object item = iter.next();
    if (filter.accept(item))
    filteredItems.add(item);
    fireIntervalAdded(this,0, filteredItems.size());
    *public static interface Filter{*
    public boolean accept(Object obj);
    *class FilterItems implements Filter{*
    private String prefix;
    *public FilterItems(String prefix){*
    this.prefix = prefix;
    *public boolean accept(Object obj){*
    return doesStartsWithThePrefix(obj.toString(),prefix);
    *private boolean doesStartsWithThePrefix(String str1,String str2){*
    return str1.toUpperCase().startsWith(str2.toUpperCase());
    *public class MyComboBoxEditor implements ComboBoxEditor,DocumentListener{*
    private JTextField text;
    private volatile boolean filtering = false;
    private volatile boolean setting = false;
    *public MyComboBoxEditor(){*
    text = new JTextField(15);
    text.getDocument().addDocumentListener(this);
    *public void addActionListener(ActionListener l) {*
    *// TODO Auto-generated method stub*
    *public void removeActionListener(ActionListener l) {*
    *// TODO Auto-generated method stub*
    *public Component getEditorComponent() {*
    return text;
    *public void setItem(Object anObject) {*
    if(filtering)
    return;
    setting = true;
    String newText = (anObject==null)? "":anObject.toString();
    text.setText(newText);
    setting = false;
    *public Object getItem() {*
    return text.getText();
    *public void selectAll() {*
    text.selectAll();
    *public void changedUpdate(DocumentEvent e) {*
    *// TODO Auto-generated method stub*
    *public void insertUpdate(DocumentEvent e) {*
    handleChange();
    *public void removeUpdate(DocumentEvent e) {*
    handleChange();
    *public void handleChange(){*
    if(setting)
    return;
    filtering = true;
    Filter filter = null;
    if(text.getText().length()>0)
    filter = new FilterItems(text.getText());
    *((AutoSearchComboBoxModel)getModel()).setFilter(filter);*
    setPopupVisible(false);
    if (getModel().getSize()>0)
    setPopupVisible(true);
    filtering = false;
    Iam creating the combo boxes as follows from another source file.
    private AutoSearchComboBox indexTagCombo,indexValueCombo
    //The following function is called for loading the comboBoxes.
    private void loadInitialIndexTagValues()
    indexTagCombo.removeAllItems();
    //Getting values to be fiiled in the comboBox.
    Set tags = this.model.getAvailableIndexTags();
    // Iterating over the elements in the set
    Iterator tagIter = tags.iterator();
    while (tagIter.hasNext()) {
    indexTagCombo.addItem(tagIter.next());
    //Loading index values.
    String currTag = (String)indexTagCombo.getSelectedItem(); //Selection problem 1
    The statement above returns me null & the follwing code doesnt fill the other comboBox.
    Set values = model.getAllValues(currTag);
    indexValueCombo.removeAllItems();
    Iterator valIter = values.iterator();
    while (valIter.hasNext()) {
    indexValueCombo.addItem(valIter.next());
    Have added an "itemListener" to the indexTagCombo as follows:
    indexTagCombo.addItemListener(new ItemListener(){
    public void itemStateChanged(ItemEvent e)
    indexTagSelection(e);
    private void indexTagSelection(ItemEvent e) {
    if (e.getStateChange() == ItemEvent.SELECTED)
    //The "getStateChange" is never ItemEvent.SELECTED,so that it never gets in to this loop.//Another problem
    //code goes Here
    There is some problem with the defined "AutoSearchComboBox" with selection.When I change the privately defined "AutoSearchComboBox" to JComboBox and make it editable,all the selection problems are gone.
    In short all the "getSelectedItem" from the "AutoSearchComboBox" and the "itemstate" events defined are not going to the "ItemEvent.SELECTED"
    What should I fix in the "AutoSearchComboBox" so that the selections work.
    Any help is greatly appreciated.
    Thanks
    P

    Hi Smita,
    When you create the Transaction code either thru Se80 or thru Se93... please see that you are giving the screen number asked there as 1000, which is the default screen number for the selection screen.
    Also, please see if the checkboxes for the GUI Support are ticked. I think it iwll solve you problem.
    Regards,
    Jayant

  • 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

  • 2007A - Problem with Combobox.Selected with an empty value

    Hi all,
    I 've tried to launch my add-on created with SBO 2005 SP1
    on 2007 client.
    I've a problem when I try to do
    myCombobox.Selected.Value
    when the valid value is empty.
    Selected is null and I've an error.
    So I must test each Combobox by doing this :
    if( myCombobox.Selected is null)
    But I've hundreds of this case in my code.
    Does an another solution exists?
    Thanks

    you have the same problem in every business one version.
    you first have to check if the property is not null/nothing
    the only other way is that you use try / catch
    value = oform.Items.Item("cmb1").Specific.selected.value()
    Catch ex As Exception
       value = ""
    End Try
    but the effort is the same for you

  • Losing comboBox selection in JTable

    I have a JTable where one column consists of comboBoxes. It is possible to add and remove rows from this table using the associated buttons.
    Unfortunately if I have made a choice from a comboBox, yet not selected another cell in the table, then I use the 'add' button to add a new row, I lose the selection just made in the comboBox.
    If I first select another cell in the table this is not a problem and it works fine.
    Any help much appreciated....

    thanks for that, but I'm afraid it was no help.
    I'm using Java 1.1.7 and the getCellEditor(int, int) method doesn't exist. doing the same with getCellEditor() doesn't produce the required results.
    The comboBoxModel is updated when a new selection is made, but the cellEditor isn't updated until you click on another location in the table. Unfortunately I don't know how it goes about doing this, so I can't imitate it in my 'add' method

  • 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.

  • 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"]
    }

  • 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

  • Binding textbox to combobox selected value when the selected value is blank

    I have a simple form that binds data to a combobox and when one of the values in the combobox is selected it fills a textbox with the corresponding column in that table.  However, if that combobox value is empty(meaning that table cell is empty) then
    the textbox will not fill with the correct value.  I am finding this hard to explain so I will lay it out.
    The table[COA] is as follows:
    ID
    Fund
    Fund Description
    Bus Unit
    Bus Unit Description
    Obj
    Obj Description
    Sub
    PEC
    1
    2789
    Account Refund
    10000
    General Fund
    1500
    ASC Voucher
    10
    2
    2789
    Account Refund
    10000
    General Fund
    1500
    Voucher
    The following is my code:
    private void subComboBox_SelectedIndexChanged(object sender, EventArgs e)
    pECTextBox.Clear();
    using (SqlConnection connection = new SqlConnection(@"Data Source=MARYANNEBORJA\SQLEXPRESS;Initial Catalog=jdeDatabase;Persist Security Info=True;User ID=Jordan;Password=*****"))
    SqlCommand command = new SqlCommand("SELECT * FROM [COA] WHERE [Bus Unit]='" + bus_UnitComboBox.Text + "' AND [Obj] ='" + objComboBox.Text + "'AND [Sub] ='" + subComboBox.Text + "'");
    command.Connection = connection;
    connection.Open();
    SqlDataReader read = command.ExecuteReader();
    while (read.Read())
    if (!read.IsDBNull(8))
    pECTextBox.Text = (read["PEC"].ToString());
    else
    pECTextBox.Text = "";
    obj_DescriptionTextBox.Text = (read["Obj Description"].ToString());
    read.Close();
    I fill my combobox with Sub values based on the Bus Unit and Obj.  Since the Bus Unit and the Obj in both rows are the same the combobox is filled with 10 and "".  
    Here is where the problem occurs.  When I select "10" in the combobox I want a textbox to fill with correct Obj Description field.  So selecting "10" would give me 'ASC Voucher' in the textbox and selecting "" should
    give me 'Voucher' in the textbox, but this is not the case.  I can only get 'ASC Voucher' to fill the textbox.  When I select "" it keeps the textbox at 'ASC Voucher'.
    My guess us that is has something to do with the value being empty in that table cell because when I am selecting other values it works.  
    Any guess as to what I should do?

    Hi objectifyThat,
    When Your subComboBox.Text is null, you should use "Sub is null" in your SQL like below.
    private void comboBox3_SelectedIndexChanged(object sender, EventArgs e)
    pECTextBox.Clear();
    using (SqlConnection connection = new SqlConnection(@"Data Source=MARYANNEBORJA\SQLEXPRESS;Initial Catalog=jdeDatabase;Persist Security Info=True;User ID=Jordan;Password=*****"))
    string cmdstring = "SELECT * FROM [COA] WHERE [Bus Unit]='" + bus_UnitComboBox.Text + "' AND [Obj] ='" + objComboBox.Text + "'AND [Sub] ='" + subComboBox.Text + "'";
    if (string.IsNullOrEmpty(subComboBox.Text))
    cmdstring = "SELECT * FROM [COA] WHERE [Bus Unit]='" + bus_UnitComboBox.Text + "' AND [Obj] ='" + objComboBox.Text + "'AND [Sub] Is Null";
    SqlCommand command = new SqlCommand(cmdstring);
    command.Connection = connection;
    connection.Open();
    SqlDataReader read = command.ExecuteReader();
    while (read.Read())
    if (!read.IsDBNull(8))
    pECTextBox.Text = (read["PEC"].ToString());
    else
    pECTextBox.Text = "";
    obj_DescriptionTextBox.Text = (read["Obj Description"].ToString());
    read.Close();
    If you have any other concern regarding this issue, please feel free to let me know.
    Best regards,
    Youjun Tang
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

Maybe you are looking for