Select a value in JComboBox by key stroke

Hi all,
I m trying to create a GUI with comboxes, in which users can select the value by pressing keys. e.g.
ComboBox:
Apple
Boy
Cat
Dog
when press 'A', it should go to "Apple", and something like this.
In my case, the objects in the Combo box are not Strings, they are bean objects, e.g.
public class Apple{
   private String name;
   private double weight;
   public Apple() {}
   public void setName(String name) {
      this.name = name;
   public String getName() {
      return this.name;
   public void setWeight(double weight) {
      this.weight = weight;
   public double getWeight() {
      return this.weight;
   public String toString() {
      return this.name;
}in this Object, its 'toString' value is the value it's gona display in the ComboBox. Othger entries in combo box are likewise.
I m not sure this is the problem or not, i just couldn't get the right value selected by key stroke.
Anyone can help?
Thanks!
best regards

Works fine for me in this example:
http://forum.java.sun.com/thread.jspa?forumID=57&threadID=613731

Similar Messages

  • Multiple key strokes in editable JComboBox for sorting

    I want to sort values of JComboBox based on key strokes in the combo. By default, JComboBox traps only one character "public int selectionForKey(char aKey,ComboBoxModel aModel)". I want to have this behaviour based on multiple character typed, e.g.
    Combo has following values:
    South - Ana
    Scotland - Ana
    Scotland - DTT
    SuperMacro
    My requirement is if the user types S, then the values should be sorted by S, if the user types C after S, then the values should be sorted by SC, if the user types O after S, then the values should be sorted by SO.
    Ravindra

    try implementing key listener instead.

  • Error while selecting NULL value from Popup Key LOV(numeric or value error)

    Hi,
    I have a item P1_DEPTNO with following properties.
    P1_DEPTNO - Popup Key LOV (Displays description, returns key value)
    LOV - P1_DEPT_LOV
    select deptname d, deptno r from deptP1_DEPTNO item properties
    List of Values
      Named LOV - P1_DEPT_LOV
      Display Null - Yes // changed to Yes, so that it can accept NULL values.
      Null display value - NULL
      Null return value -   (blank)PL\SQL Process -
    declare
    v1 number;
    begin
    if :P1_DEPTNO is null OR :P1_DEPTNO = '' then
        v1 := 0;
    else
        v1 := :P1_DEPTNO;
    end if;
    // rest of the PL\SQL process
    end;Now, when I run the page and select NULL value from Popup LOV and submit, I get the following error.
    ORA-06502: PL/SQL: numeric or value error: character to number conversion error.When, I select any other value other than NULL, then it's working perfectly fine.
    Only in case of NULL value, I am getting this error.
    ANY idea, why this error is coming??
    Thanks,
    Deepak

    Hi Varad,
    I did the following change
    Null display value - (blank) // by default it is displaying '%' in the select this
    Null return value - -1
    but when I select % (null value) from the popup list, it displays the return value -1 in the text field.
    My question is why it is displaying the return value -1 in the text field...*It should display the display value in the text field (i.e blank in this case)*
    then, I did the following change
    Null display value - (blank) // by default it is displaying '%' in the select this
    Null return value - // a single space, so that when I select %(null value) from the list, it should display blank in the text field...
    then I did the following change in the PL\SQL process.
    PL\SQL process
    declare
    v1 number;
    begin
    if :P1_DEPTNO = ' ' then // -- checking the value of single space ' ' when we select %(null) in the popup list, BUT even I select %(null), control is not coming here.
        v1 := 0;
    else
        v1 := :P1_DEPTNO;
    end if;
    // rest of the PL\SQL process
    end;Thanks,
    Deepak

  • Selection screen value to reflect only on one key figure.

    Dear all,
    I have a query in which there are 3 key figures - for example Complaint qty,production qty and the PPM, this query is to be executed for a range of months - hence i have added the variable calmonth/year in the column and also i have restricted using a selection variable so that a range of months can be provided when the query is executed.
    My problem is when the query is executed with the above condition, the range of months affects all the key figures - but i want the range of month value only for the key figure PPM.
    Is there any way in which my requirement can be met.
    Your experts advice will be helpful.
    Regards,
    M.M

    Hi Sam,
    Thank you for your reply. I will be happy if you could provide me the step by step process - so that i can check whether my requirement gets fulfilled.
    Expecting your Expert opinion.
    Regards,
    M.M

  • Using key strokes as command in AT LINE SELECTION section.

    Hi all,
    I created a small report which do a refresh every X seconds. In every refresh, the form "print_panel" is performed. In this form I used some icons as buttons of my user interface in this way:
    ..."skipping code that's not relevant w.r.t to the question.
    SKIP TO LINE myline.
    WRITE AT mycolumn(2) ICON_COLUMN_LEFT AS ICON NO-GAP.
    This allows in my report to use such an expression to associate a dbl click on that icon to a certain block of code:
    AT LINE-SELECTION.
        DATA: FIELD(30).
        GET CURSOR FIELD FIELD.
        IF FIELD = 'ICON_COLUMN_LEFT'.      
           PERFORM myformthatdoessomething.
    I'm wondering if there's a way to associate this behaviour also to a key stroke. For example, pressing the "A" key is equivalent to do a double click on that icon. How can i manage this  ?
    Thanks in advance

    Hi Ravi,
    Ravi,
    Thanks for the response.
    The requirement is :
    When the START OF SELECTION section is executed a write statement displaying the number of incomplete sales Orders is displayed. When you click on that output statement(as in drill down repoting) the code below comes into picture:
    AT LINE-SELECTION.
    PERFORM disp_blkd_bill.
    PERFORM start_of_selection.
    LEAVE SCREEN.
    Now the alv list displays incomplete Sales Orders. The user using the HOTSPOT feature completes/processes the sales Order and wants the ALV report to refresh when she hits the back button and returns to the ALV list which I do so. Now when she again hits the back button she wants to view the updated statement displaying the number of incomplete Sales orders which happens when the routine 'start_of_selection' is excuted again. But then If I do not use the LEAVE SCREEN command it takes her back to the old displaing the previous incomplete number of sales orders and then back to the selection screen. We do not want that old statement to be displayed on the way back to the selection screen.
    Please let me know if you still need further clarifications.
    Thanks,
    ALAM.

  • In mini bridge is there a key stroke to "select all" images?

    Hello,
    In mini bridge is there a key stroke to “select all” images? I’d prefer a key stroke instead of having to use the View drop down menu to select all, and "Ctl A" doesn't do anything.
    Thank you.

    Select a message in the mailbox or highlight a mailbox, then keys command-a to select all.

  • Select-option value is not getting captured in at selection-screen on value

    In Selection screen , we have Select-option and  a parameter.
    Based on the values given in Select-option, the values of Parameter should get populate.
    To achieve this functionality,
    I  used  At selection u2013screen  on value request  for <parameter>  EVENT and 'F4IF_INT_TABLE_VALUE_REQUEST' Function Module.
    But the Select-option values are not getting captured in this event,unless u press Enter key.
    Is there any other way to achieve this functionality.
    Please Guide me.

    When you call function 'F4IF_INT_TABLE_VALUE_REQUEST'. make sure you send it the name of the screen variable - the F4IF_INT_TABLE_VALUE_REQUEST function calls DYNP_VALUES_READ itself if you tell it the name of your report, screen number, and the variable name... snippet below.
    Jonathan
      data:
        l_repid             type syrepid.
      l_repid = sy-repid.
      call function 'F4IF_INT_TABLE_VALUE_REQUEST'
        exporting
          dynpprog         = l_repid
          dynpnr           = '1000'
          dynprofield      = 'S_FIELD-LOW'  "Select options - low value
    * etc

  • How to get selection criteria value in method IF_POWL_FEEDER~HANDLE_ACTION

    hi:
    As you know, we could get the leading selected POWL result data through parameter  c_selected and  c_selected in this method.
    but moreever, I want to get the selection criterai values in this method too just like the paramter i_selcrit_values in the method IF_POWL_FEEDER~GET_OBJECTS, how to do it?
    I have tried to define a attribute in my POWL class and save i_selcrit_values into this attribute in the method IF_POWL_FEEDERGET_OBJECTS, but in method IF_POWL_FEEDERHANDLE_ACTION, this attribute is still empty, so this workaround failed.
    thanks.

    hi guys:
    I have founded how to do it:
    METHOD get_selcrit.
      DATA ls_query TYPE powl_query_sty.
      DATA lt_selcrit TYPE rsparams_tt.
      FIELD-SYMBOLS <ls_selcrit> LIKE LINE OF lt_selcrit.
      CALL METHOD cl_powl_runtime_services=>get_current_query
        RECEIVING
          rs_query = ls_query.
      CALL METHOD cl_powl_query_accessor=>get_cached_selcrit
        EXPORTING
          i_query     = ls_query-query
        IMPORTING
          e_crit_para = lt_selcrit.
      READ TABLE lt_selcrit WITH KEY selname = iv_selname
        ASSIGNING <ls_selcrit>.
      IF <ls_selcrit> IS ASSIGNED.
        ev_selcrit = <ls_selcrit>-low.
      ENDIF.
    ENDMETHOD.

  • Getting selected row values of a classic report

    Hi Guys,
    i'm using Apex 4.1,
    I have a classic report on my apex page. First column of this report is check box for row selection. and its binded to primary key of a table. i know that i can get the selected row's primary key (Check box value) using APPLICATION_ITEM.G_FO1() function. What i need is how can i get the other cell values of the selected row ?
    Appreciate if someone can help on this,
    Thanks.

    Apex-Ape wrote:
    i'm using Apex 4.1,
    I have a classic report on my apex page. First column of this report is check box for row selection. and its binded to primary key of a table. i know that i can get the selected row's primary key (Check box value) using APPLICATION_ITEM.G_FO1() function. What i need is how can i get the other cell values of the selected row ?If you really have a report with just one checkbox column and the rest of the data standard read-only report columns then it's not clear exactly what the requirement is. What do you want to do with them when you get them?
    I can think of 2 possible approaches:
    <li>Stick with the current report. On page submit you get an array of zero or more PKs. Create a collection with a row containing each PK. Whatever it is that you want to do next can then use a query that is a clone of the original report query plus a join to the PK values in the collection.
    <li>Recreate the report with shadow <tt>apex_item.hidden</tt> columns in the query for each value. In the report column attributes, do not display the <tt>apex_item.hidden</tt> columns, but include them with each displayed column (or stuff them all into one column for convenience) using HTML Expressions. The values will then be available in <tt>apex_application.g_fxx</tt> arrays like the row selector checkbox.
    I prefer the first one, but really it depends on what the next step is...
    (If it's actually a tabular form then the values will be in other <tt>apex_application.g_fxx</tt> arrays.)

  • How to get the selected node value of a tree which is build on java code

    Hi Experts,
    How can i get the selected node value if I build the tree programatically.
    I am using the following code in selectionListener but it is throwing error.
    RichTreeTable treeTable = (RichTreeTable)getQaReasontreeTable();
    CollectionModel _tableModel =
    (CollectionModel)treeTable.getValue();
    RowKeySet _selectedRowData = treeTable.getSelectedRowKeys();
    Iterator rksIterator = _selectedRowData.iterator();
    String selectedQaCode ="";
    while (rksIterator.hasNext()) {
    List key = (List)rksIterator.next();
    JUCtrlHierBinding treeTableBinding =
    (JUCtrlHierBinding)((CollectionModel)treeTable.getValue()).getWrappedData();
    JUCtrlHierNodeBinding nodeBinding =
    treeTableBinding.findNodeByKeyPath(key);
    String nodeStuctureDefname =
    nodeBinding.getHierTypeBinding().getStructureDefName();
    selectedQaCode = selectedQaCode + nodeBinding.getAttribute(0);
    where I am using following link to create a tree with java code.
    http://one-size-doesnt-fit-all.blogspot.com/2007/05/back-to-programming-programmatic-adf.html
    Please help me in resolving this issue.
    Regards
    Gayaz

    Hi,
    you should also move
    JUCtrlHierBinding treeTableBinding =
    (JUCtrlHierBinding)((CollectionModel)treeTable.getValue()).getWrappedData();
    out of the while loop as this is not necessary to be repeated for each key in the set
    Frank

  • InfoSet Query - Long Description while selecting variable values

    Dear Experts,
    We have an InfoSet Query on different InfoObjects like 0CUSTOMER, 0CUST_COMPC etc and the common link between these InfoObjects is CUSTOMER.
    We have a variable created on this CUSTOMER. The requirement is that when this query is executed, user should be able to select a value of Customer (F4 help) and at that time, he should be able to view both Key and Long Text of Customer.
    We know that if we change the CUSTOMER InfoObject --> BEx Properties tab, then we can display Long Text and Key in Query Selection Screens. However we can not do that because it would affect all queries in which this InfoObject is used.
    If we go to Query Design, and choose "Long Text and Key" in properties of Customer, then system displays Long Text and Key of Customer but after the report execution is done.
    We want to display the Long Text of Customer to User at the time of selection and that too without making any InfoObject level change.
    If it was InfoProvider, we could have done it using "Provider specific properties of Characteristic" option. But this is InfoSet and that option does not appear here.
    Please suggest the solution.
    Regards
    P

    Rohit,
    Are you looking to display long text for infoobject instead of short description ?
    Then go tp rsd1>infoobject>display/change-->master data/texts -->text table properties -->check long text exists.
    It supports a long text field with a length of 60 characters
    Activate the infoobject
    --Doodle
    Message was edited by: Doodle

  • Query Panel LOV Selecting first value

    Hi all,
    I created a LOV to use for one of my VOs. I created it as an Input Text with List of Values. I updated the AF Table using this view to use the new list of values and it works correctly. However in the query panel for the table when you try and select a value from the LOV it always chooses the first record in the LOV no matter which one you select. The query panel is implemented as a separate pop-up/dialog for the AF table.
    I'm not sure why it is working fine on the actual table but not working correctly in the query panel.
    Any help is appreciated.
    Thanks
    Jdev 11.1.2.2.0

    Found the solution to this one.. I did not specified which were the key columns in the VOs that I created to reference in the LOV.
    Once I specified the key column in the VO, the LOV returned the correct value in the Query Panel too.

  • Changing value in JcomboBox

    hi, i am new learner in java programming language.
    i trying to develop a Greenwich inn resort reservation system.
    i am adding 2 JCombobox in the JFrame and adding 2 Action listener to the 2 created JCombobox in oder to reset the value in Jcombobox.
    jComboBox1.addActionListener(jcb1);
    jComboBox2.addActionListener(jcb2); i am create a class which call as timemanager to control the time
    public class timemanager {
    int Year;
    int Month;
    int Date;
    Calendar calendar = Calendar.getInstance();
        public timemanager(){
           Date today = new Date();
           Year = (today.getYear() +1900);
           Month = today.getMonth();
           Date = today.getDate();
        public int getmaxday(){
            calendar.set(Year,Month,Date);
            int maxday = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
            return maxday;
        }i poiting the object in as timemanager time1 = new timemanager();
    and i am adding the listener command which is
    public ActionListener jcb1=new ActionListener(){
        public void actionPerformed(ActionEvent ae){
            if ((Integer)jComboBox1.getSelectedItem()== (new Date().getYear()+1900)){
             time1.Year = (Integer)jComboBox1.getSelectedItem();
                reservationstartingshowingdate();//method which i call to change the value
             }else{
             time1.Year = (Integer)jComboBox1.getSelectedItem();
             changestartingdatevalue();//method which i call to change the value
        public ActionListener jcb2=new ActionListener(){
        public void actionPerformed(ActionEvent a){
            for(int x =0;x<fullmonth.length;x++){
            if (jComboBox2.getSelectedItem()== fullmonth[x]){
                if (new Date().getMonth()==x){
                    if (time1.Year== (new Date().getYear()+1900)){
                            time1.Month = x;
                         reservationstartingshowingdate(); //method which i call to change the value
                    }else{
                        time1.Month = x;
                        //System.out.println(time1.Month);
                        changestartingdatevalue();
                }else{
                     time1.Month = x;
                     System.out.println(time1.Month);
                     changestartingdatevalue();
        };and my reservationstartingshowingdate() method are
    private void reservationstartingshowingdate() {
                    int date = time1.Date;
                  int month = time1.Month;
                  int year = time1.Year;
                  int maxday = time1.getmaxday();
                  //System.out.println("item count combobox1 ="+jComboBox2.getItemCount());
                  if (jComboBox2.getItemCount()>=0){
                    System.out.println("item count combobox2 ="+jComboBox2.getItemCount());
                      jComboBox2.removeAllItems();
                      jComboBox3.removeAllItems();
                  if(jComboBox1.getItemCount()<=0){
                  for (int x = 0;x<fullyear.length-1;x++){
                        this.jComboBox1.addItem(fullyear[x]);
                  for(int x=month;x<fullmonth.length;x++){
                      System.out.println(x);
                      this.jComboBox2.addItem(fullmonth[x]);
                  System.out.println("finish insert month");
                   for(int x = date;x<=maxday;x++ ){
                         this.jComboBox3.addItem(x);
    //System.out.print(year);
                  this.jComboBox1.setSelectedItem(year);
                }why when i select the same item that with my current year in JCombobox1, Jcombobox2 value will become double? i and calling one time reservationstartingshowingdate() only in jbc1. but why it apper double same data? i am trying to understand the code in action listener. hope you all can explain and solve this problem. thank
    Edited by: yjho on Aug 27, 2010 2:54 AM

    In the future, Swing related questions should be posted in the Swing forum.
    MoreOver, when some other window hides frame, string value in hidden portion of frame get erased.Thats because your painting code is in the actionPerformed() method. Everytime a component is repainted the painting is done from scratch, but of course the code in the actionPerformed() method is not executed.
    You need to do your custom painting by extending JComponent or JPanel. All the actionPerformed method does is tell the component to repaint() itself.
    Read the Swing tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/14painting/index.html]Custom Painting.

  • Getting the UPDATEd value and its primary key

    I have two procedures, proc1 and proc2.
    In proc1 there is an update happening like
    CREATE OR REPLACE procedure proc1
    as
    TYPE NumList IS TABLE OF employees.employee_id%TYPE;
    enums NumList;
    TYPE NameList IS TABLE OF employees.last_name%TYPE;
    names NameList;
    BEGIN
    UPDATE emp set sal=900 WHERE department_id = 30
    RETURNING employee_id, last_name BULK COLLECT INTO enums, names;
    DBMS_OUTPUT.PUT_LINE('Updated ' || SQL%ROWCOUNT || ' rows:');
    FOR i IN enums.FIRST .. enums.LAST
    LOOP
    DBMS_OUTPUT.PUT_LINE('Employee #' || enums(i) || ': ' || names(i));
    END LOOP;
    END;
    /In proc2 which is getting executed just after proc2 i want to SELECT the sal column values and its primary keys(employee_id) which got updated in proc 1.
    How can i achieve this?

    add two out parameters from proc1 so that you can pass them into proc2 (obv. you'd need to add two in parameters to proc2 if they aren't there already)

  • Adding select-option value in selection screen of FBL5N tcode.

    Hi Experts,
    I have one requirement that to add a Header Text Field(BKPF-BKTXT) in section screen of standard program RFITEMAR(tcode : FBL5N), i tried to add that field but it was not displayed where i required, i mentioned below  where i required.
    Customer account                     
    Company code   
    i required under company code select option value in same selection screen block.
    Please do the needful.
    thanks in advance.
    gsreddy.

    Hi,
    If you get the access key it is possible to edit the standard program,
    How u tried to add the field???
    regards,
    Mullai

Maybe you are looking for

  • Pink Screen with 17" ADC and DVI converter

    This issue could be with the Apple ADC to DVI convertor box or cable, but I can't confirm if it is that or my monitor. I am using a 17" clear ACD with a mac mini, and I started to get intermittant bright pink screens, which has progressed into pink a

  • Vendor's withholding tax code changing

    Hi Can we change the vendor's withholding tax code in mid year...... regards

  • Changing default target namespace for a JPD

    Hi, Is there a way in Workshop 8.1 to change the target namespace used when a WSDL is generated from a JPD? Currently, Workshop uses http://www.openuri.org. I have tried to use the @common:target-namespace annotation in my JPD, but that appears to on

  • WCS and WLC AP values not fully in sync.

    I have recently added several new aps on my network,after they connect to the controller, I set a hostname, and change the ip address to a static. However, WCS still sees the aps by the old ip and host name despite going into each one, hitting audit,

  • POPUP WINDOW generation

    i'd like to generate a popup window, much like how on apple's website, the close-up pictures pop up ( http://www.apple.com/keyboard/), or something similar. basically, i'd like my viewer to be able to click on a small picture and have a bigger pictur