Focus shifted to next component after selecting item in combobox.....

I have Table and a textfield as only two UI components.
For the table i am using my custom editor(NewComboEditor.java), for this i am extending the "DefaultCellEditor" and applying this editor for my jTables first column. My custom editor simply prepares the editor by instantiating the jCombobox and sets the selected value and return it (in overwridden "getTableCellEditorComponent" method).
I have made my combobox editable by setting "combobox.setEditable(true)" in constructor of editor while creating the instance of combobox.
Now everything works fine except whenever i tried to select an item from the combobox , after the item selection, focus is assigned to textfield which is the nextfocusable component to jTable on which the comboboxes are rendered.
If my jcomboboxes are not editable then selection remains on combobox only.
The implemetation for the comboEditor and comboRenderer is as follows.
=========================== Main frame having all compenents =================================
public class CreateAndShowComboBoxes extends JFrame {
    protected JTable table;
     * Default constructor..
    public CreateAndShowComboBoxes() {
      Container pane = getContentPane();
      pane.setLayout(new BorderLayout());
      //create table model, this table model extends AbstractTableModel.
      MyTableModel tableModel = new MyTableModel();
      table = new JTable(tableModel);
      TableColumnModel tcm = table.getColumnModel();
      TableColumn tc = tcm.getColumn(MyTableModel.LAST_NAME);//set to column 1.
      //specify the renderer and editor.
      tc.setCellRenderer(new ComboRenderer());     
      tc.setCellEditor(new NewComboEditor());
      JScrollPane jsp = new JScrollPane(table);
      pane.add(jsp, BorderLayout.CENTER);
      JTextField textField = new JTextField();
      table.setNextFocusableComponent(textField);
      pane.add(textField, BorderLayout.SOUTH);
     * Create a frame and make it visible.
    public static void main(String[] args) {
        CreateAndShowComboBoxes stt = new CreateAndShowComboBoxes();
        stt.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        stt.setSize(400, 300);
        stt.setVisible(true);
============================================ComboEditor =========================================
public class NewComboEditor extends DefaultCellEditor{
     *Default constructor.
    public NewComboEditor() {
        super(getComboBox());
        JComboBox combobox = (JComboBox)getComponent();
        combobox.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                //fireEditingStopped();
                //stopCellEditing();
     * Override to invoke setValue on the formatted text field.
    public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected,
                                                    int row, int column) {
        JComboBox cb = (JComboBox)super.getTableCellEditorComponent
                                        ( table, value, isSelected, row, column);
        cb.setSelectedItem(value);
        return cb;
     * @return object
    public Object getCellEditorValue() {
        JComboBox cb = (JComboBox)getComponent();
        Object o = cb.getSelectedItem();
        return o;
     * @return true
    public boolean stopCellEditing(){
        JComboBox cb = (JComboBox)getComponent();
        cb.requestFocus(true);
        return super.stopCellEditing();
     * @return combobox instance
    public static JComboBox getComboBox(){
        JComboBox combobox = new JComboBox();
        combobox.setEditable(true);
        combobox.addItem("khan");
        combobox.addItem("rawal");
        combobox.addItem("shetti");
        combobox.addItem("more");
        combobox.addItem("sohel");
        combobox.addItem("kambli");
        combobox.addItem("warne");
        return combobox;
========================================= ComboRenderer ====================================
public class ComboRenderer extends JComboBox implements TableCellRenderer {
     *Default constructor.
    public ComboRenderer(){
        super();
        addItem("khan");
        addItem("rawal");
        addItem("shetti");
        addItem("more");
        addItem("sohel");
        addItem("kambli");
        addItem("warne");
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
        boolean hasFocus, int row, int column) {
      setSelectedItem(value);
      return this;
======================================================================================Message was edited by:
yuvi
Message was edited by:
yuvi

Hi Pravin Ghadge,
Please Use this code for focus.
oMat.Columns.Item("Column_UID").Cells.Item(oMat.VisualRowCount).Click(SAPbouiCOM.BoCellClickType.ct_Regular)
I hope it will work.
Thanks,
P.T.Sampath.

Similar Messages

  • Getting selected item from combobox itemrenderer and storing in object

    Hi Guys,
    Can anyone help me in this regard. Its very urgent.
    I have a combo box itemrenderer in datagrid column. I want to get the user selected item from the dropdown of the row(s) (User may select values from combo box from multiple rows of datagrid) and corressponding values of all other columns of the rows and store it in an object . Then pass this object to database to update only those rows that user has changed.
    I am able to get the selected item from combo box using "event.currentTarget.selectedItem" and corressponding values of all other columns of the rows using "valueSelect.ID", etc where valueSelect is object which contains data for datagrid. But am stuck up with, how to store the selected item value of the combobox  and corressponding values of all other columns of the rows into an Object ?.
    Can anybody help me with sample to store selected item from combobox and its corressponding values of all other columns into an object which i can send to db...?
    Kindly help me in this regard.
    Thanks,
    Anand.

    Hi!
    Are you using a collection of VO or DTO as the dataprovider of the combobox component?
    If so, have you created some attribute there to control the user's selection in the combobox?
    For instance:
    private var selected:Boolean = false;
    If your solution fits this approach, you may create a new collection that contains just the objects that were selected by the user, it means you can loop through the datagrid's dataprovider and only insert in this new collection those objects that have the attribute "selected" set to true.
    For instance:
    private function getSelectedRecords(datagridDataProvider:ArrayCollection):ArrayCollection
        var newCollection:ArrayCollection = new ArrayCollection();
        for each (var item:Object in datagridDataProvider)
            if (item.selected)
                newCollection.addItem(item)
        return newCollection;
    Afterwards, you may serialize this new collection with your back-end.
    Hope it helps you!
    Cheers,
    @Pablo_Souza

  • Set focus to a report region after select value (user) report region

    Hello,
    On my page I have 4 report SQL Query report regions (among themselves). After selecting (user) of a value (report region number 3 with column link), the result shown in report region number 4. However, the focus is on report region number 1. The user sees the results do need to scroll down to see the answer(in report region number 4).
    Does anyone have a solution for me with an example. Thanks.

    Hi Varad,
    sorry for the delayed response.
    Please check the page:- 9999 of App:-964
    I have made 2 simple reports with a button in each region.
    SUCCESS MESSAGE of first one:- first process run by first report
    SUCESSS MESSAGE of second one:- Saved Data..process run for second report
    when first process is run by clicking the <b>SUBMIT</b> button in the first region, we will see the same first region back. But, when we click the <b>SAVE</b> button of second region, page submits and we will see the first region and user should scroll down to see the second region.
    so, I am trying to see if I can have user see the same region back[second region,when SAVE button clicked, in this case] if he has done any operations on second region. My actual page has around 6 regions where scrolling down might be pain full for a end user.
    Have created this page in a hurry .. My actual pages and processes are doing some use full job, the page I have given here is only for our testing purpose. please do not mind.
    Thanks a lot for helping me..
    Chaitu..
    Edited by: Chaitu_Apex on Apr 14, 2010 9:51 AM

  • Application import halts on clicking at "Next" Button after selecting file

    Hi,
    I'm trying to import an application to another server but import hangs after clicking at the "Next" button after I have selected the file to be uploaded.
    I do can import the application on apex.oracle.com and in the same server
    version for toolkit is 10.1.2.0.6
    database version 9.2.0.7
    The javascript error showing on the page complains on a function( x_Show ).
    Any ideas about what's wrong?
    / Jannis

    Thanks for letting us know what fixed it for you. You just made me realise why my install of Apex 3.0 on XE didn't work - I had the same symptoms as you. I hadn't set up the image folders, which I've read about elsewhere since then, but I hadn't connected the two before.
    Cheers
    Richard

  • Disable listbox after selecting item.

    Hello
    I want to disable the listbox after selecting some item from that list..
    for example :
    first the user select item from the list (at this time listbox is not disable) then after selecting, it should not allow user to change it (so i want to disable it).
    I tried "loop at screen" in which i did screen-input = 0. but its not working.
    Please help me...
    Regards
    Virendra

    Hi,
    TYPE-POOLS vrm.
    PARAMETERS : lb TYPE char10 VISIBLE LENGTH 15 AS LISTBOX USER-COMMAND lb.
    DATA :  vrm_id TYPE vrm_value-text,
              vrm_values TYPE vrm_value OCCURS 0 WITH HEADER LINE.
    AT SELECTION-SCREEN OUTPUT.
      IF NOT lb IS INITIAL.
        LOOP AT SCREEN.
          IF screen-name = 'LB'.
            screen-input = 0.
    "        MODIFY SCREEN. --> You forgot add this Code
    "  This is a tested piece of Code Just Execute and Check
          ENDIF.
        ENDLOOP.
      ENDIF.
      LOOP AT SCREEN.
        IF screen-group1 = 'AA' OR
          screen-group1 = 'BB' OR
          screen-group1 = 'CC'.
          screen-invisible = 1.
          screen-active = 0.
          MODIFY SCREEN.
        ENDIF.
      ENDLOOP.
      REFRESH vrm_values.
      vrm_values-key = 'VBELN'.
      vrm_values     = 'VBELN'.
      APPEND vrm_values.
      vrm_values-key = 'MATNR'.
      vrm_values     = 'MATNR'.
      APPEND vrm_values.
      vrm_values-key = 'AUFNR'.
      vrm_values     = 'AUFNR'.
      APPEND vrm_values.
      vrm_id = 'LB'.
      CALL FUNCTION 'VRM_SET_VALUES'
        EXPORTING
          id              = vrm_id
          values          = vrm_values[]
        EXCEPTIONS
          id_illegal_name = 1
          OTHERS          = 2.
    Cheerz
    Ram

  • Remember selected item with ComboBox

    Hey All,
    I was just wondering how other pople solve this issue.
    I have a combobox with a XX number of items in there. Now
    when I re-populate the combobox the selected item get's lost. I
    also would like to remember the selected item during sessions. For
    instance when A user selected item XX on monday. I would like to
    have it automatically set XX again when a user comes back on
    tuesday.
    Is there a meganism in adobe flex that allows me to remember
    a 'state' of a object, or is that custom programming?
    Ideally I would like to have a component that can do teh work
    for me rather then my application handles the logic, some sort of a
    state manager?
    Ries

    Use a SharedObject, and write to it in the ComboBox change
    handler. See SharedObject in FB3 help sys.

  • How to select item in combobox using database?

    I inserted some data in oracle database using comboboxes and to retrieve that data from oracle database.my problem, How to select the item in combobox using that data(retrieve data)?

    Not quite sure what you're asking; do you want to show some value in the combo box selected when the page loads? Then you need to use the "selected" key word in the correspoding <option> element.
    People on the forum help others voluntarily, it's not their job.
    Help them help you.
    Learn how to ask questions first: http://faq.javaranch.com/java/HowToAskQuestionsOnJavaRanch
    (Yes I know it's on JavaRanch but I think it applies everywhere)
    ----------------------------------------------------------------

  • Editable Datagrid: focus shifts to next row on click : Urgent

    I have an editable datagrid and when I change the value of a cell and then instead of tab I click on the cell adjacent to it, the focus automatic shifts to the next row. I have no freaking idea why?
    Any help is appreciated. Thanks a ton in advance.

    Issue Resolved 
    Need to set lead selection to next element in the node using MOVE_NEXT method of IF_WD_CONTEXT_NODE interface.
    rest of the code remains same.

  • Move to next field after typing item code in a document

    Hello experts,
    In a marketing document we type 1000 in item code field and press tab.
    we would like the cursor to move to next field but instead a list of items is being opened.
    in the list there are two items 1000 and 10001
    in another company we can do it but we couldnt find what is the difference between the two companies setup definitions.
    Thank you,
    Rinat

    Hi,
    Please make sure item number fully entered at item code. If not complete, then list of items window will open.
    If possible please post screen shot above window
    Thanks & Regards,
    Nagarajan

  • Focus lost  after selecting an item from combobox

    After I select an item from combobox first component is focused even though it is invisible. But if I press tab or enter without selecting any item, next component is focused as expected.
    How can I solve the problem?

    If you need further help then you need to create a [Short, Self Contained, Compilable and Executable, Example Program (SSCCE)|http://homepage1.nifty.com/algafield/sscce.html], that demonstrates the incorrect behaviour.
    Don't forget to use the Code Formatting Tags so the posted code retains its original formatting. That is done by selecting the code and then clicking on the "Code" button above the question input area.

  • Customize "Tab" key for JTextArea to focus next component.

    Hi,
    I am trying to change the "TAB" key behaviour for JTextArea, by using CustomAction configured via InputMap() and ActionMap(). When the user presses the Tab key, the focus should go the next component instead of tabbing in the same JTextArea component. Here is the code for the CustomAction().
        public static class CustomTabAction extends AbstractAction {
            private JComponent comp;
            public CustomTabAction (JComponent comp) {
                this.comp = comp;
                this.comp.getInputMap().put(KeyStroke.getKeyStroke("TAB"), "TABPressed");
                this.comp.getActionMap().put("TABPressed", this);
            public void actionPerformed(ActionEvent evt) {
                Object source = evt.getSource();
                if (source instanceof Component) {
                    FocusManager.getCurrentKeyboardFocusManager().
                            focusNextComponent((Component) source);
        }This works for most of the cases in my applicaiton. The problem is that it doesn't work with JTable which has a custom cell editor (JTextArea). In JTextArea field of JTable, if the Tab is pressed, nothing happens and the cursor remains in the custom JTextArea exactly at the same place, without even tabbing spaces. Here is the CustomCellEditor code.
        public class DescColCellEditor extends AbstractCellEditor implements TableCellEditor {
    //prepare the component.
            JComponent comp = new JTextArea();
            public Component getTableCellEditorComponent(JTable table, Object value,
                    boolean isSelected, int rowIndex, int vColIndex) {
                // Configure Tab key to focus to next component
                CustomActions.setCustomAction("CustomTabAction", comp);
                // Configure the component with the specified value
                ((JTextArea)comp).setText((String)value);
                // Return the configured component
                return comp;
            // This method is called when editing is completed.
            // It must return the new value to be stored in the cell.
            public Object getCellEditorValue() {
                return ((JTextArea)comp).getText();
        }regards,
    nirvan

    >
    textArea.getInputMap().remove(....);but that won't work because the binding is actually defined in the parent InputMap. So I think you need to use code like:
    textArea.getInputMap().getParent().remove(...);But I'm not sure about this as I've never tried it.I tried removing the VK_TAB key from both the input map and parent input map as shown below. But I still have to press "TAB" twice in order to get out of the JTextArea column in JTable.
                comp.getInputMap().getParent().remove(
                            KeyStroke.getKeyStroke(KeyEvent.VK_TAB,0));
                comp.getInputMap().remove(
                            KeyStroke.getKeyStroke(KeyEvent.VK_TAB,0));after coding this, I am using the setFocusTraversalKeys for adding only "TAB" key as ForwardTraversalKey as given below.
            Set newForwardKeys = new HashSet();
            newForwardKeys.add(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0));
            comp.setFocusTraversalKeys(
                        KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS,newForwardKeys);
            Set newBackwardKeys = new HashSet();
            newBackwardKeys.add(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, KeyEvent.SHIFT_DOWN_MASK));
            comp.setFocusTraversalKeys(
                        KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS,newBackwardKeys);The only problem that remains now is that I have to press the "TAB" twice in order to get out of the JTextArea column
    regards,
    nirvan.

  • How to move to the next Selected Item in a list.

    *Edited*
    I was just wondering how I could make a button which would move the currently selected item to the next in the array loaded into a List component. I would think to do it through AS or an event, but I'm not sure what I would reference in accordance to that component. The help would be appreciated, thank you.

    You can set the selectedIndex. When next button is clicked increment the selectedIndex.
    If( list.selectedIndex < list.dataProvider.length - 1 )
         list.selectedIndex++;

  • How to refresh page after selecting value from LOV item , in a tabular form

    Hi ,
    I have a tabular form, which contains 2 items(columns), of type "Select List - named LoV".
    Now, couple of issues here.
    1.
    2nd item(column) in tabular form, that LoV should get populated based user's selection value in first item LoV. So how do i refer to the value, that user selected in first item's LoV? I will have to use this reference in LoV query of my 2nd item ( on this tabular form)
    2.
    How can we refresh the page, when user selectes value in first item ( from LoV). As this is a tabular form, here item type is Select List, we dont have an option to pick item type as Select List with Submit. So problem is that when user selects value for item 1, refresh does not happen and item 2 LoV does not get populated as per user's selection in item 1.
    Please help here. Would be really appreciated.
    Thanks and Regards,
    Rave.

    Thanks Ben and Dan for your responses.
    Ben, your solution helped me with refresh of page, as page got submitted.
    This answers to my 2nd question. However, I still need to know first question, which basically is, how do i refer to the value, that user selected in first item LoV.
    Issue is, I selected the value in first item LoV, it got submitted and page fot refreshed. But after page refresh, first item LoV loses its value that I had selected last time. It does not retain the selected value after refresh.
    I have an unconditional process, that on every submit(refresh) of page, I set my items with their corresponding values. But problem is what do i mention there to refer to this item.
    I looked in view source of my page, this item is referred as f03.
    So i used "apex_application.g_f03", to set this item to its value, in my uncoditional submit process. But it did not work. I tried to refer this item as "f03" in this unconditional submit process. But still it did not help, the selected item loses its value after page refresh(submit).
    Any help here would be really appreciated. Please suggest how do we refer to this item's selected value.
    Thanks and Regards,
    Ravi.

  • How i can set the selected item of a dropDown component from java code

    Hi
    Thank you for reading my post
    How i can set the slected item of a DropDown component from backing beans java code ?
    it is binded with a database , so one field determine its display and one other field determine its value , I want to set the selected item of this combobox
    In back code i have both value and display values to use them .
    can some one give me some help ?
    Thanks ,

    See code sample 3 at http://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/2/helloweb.html
    See also, the selection components row in the table under http://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/2/helloweb.html
    It says
    One way to preselect items is to call setSelectedValue(Object[]) or setSelectedValue(Object) from the prerender() method. You pass in the return values of the items that you want preselected. Be sure to verify that getSelected() returns null before setting the default options, or you will overwrite the user's selections on a post-back.

  • Selecting item in combo box itemEditor, after passing it's dataprovider from a popup window

    Hi..
    I have a datagrid which has a combo box itemeditor in the first column. When I click on the combobox, there is an item called 'Search'. When this is selected, a pop up window appears where we can search for some contact names. The search results are populated in List component, within the pop up and on double click of any of the names from the list, all of the list content is passed on as dataprovider to the combobox itemeditor of the grid. It works fine till here. Now, how can I highlight the selected name(name on which I double click, in the list of the pop up window), as the 'selectedItem' of the combobox itemeditor? ie., as soon as I double click the name, that name should appear on that combo box. As of now, wehn I double click, the search result names are passed on as dataprovider to the combobox, but a blank entry will be selected in th combobox, instead of the selected name from teh list of the pop up window. Can you please help me out on how to achieve this? I had been cracking my head for 2days now, hasn't worked out yet for me

    Hi...
    there are two events which have been used, one is doubleclick event and the other one is on selecting the item from the list and clicking on OK button(this will be the most frequently used function, i cannot use event target event for this OK button... ) . I have attached the screen shot. Please have a look at it and let me know how can i achieve that...
    I can use custom event, but the main problem is that the inline itemeditor's details are not accessible in the code.... I can access some function from within the inline itemeditor combo box using outerDocument.myFunction() (this is something like GET). Is there a similar way, to SET the data into this itemeditor?

Maybe you are looking for

  • VPN client cannot access inside hosts

    Hello,     I have an ASA 5505 device with the attached configuration and my vpn clients can connect to it fine.  Although, once a vpn client is connected they cannot RDP, ping, or telnet any internal hosts.  The goal is to have a connected vpn client

  • 1st gen ipod touch microphone isnt working

    i use my ipod touch to record my dj sets with numark mixdeck. it worked for months. no the ipod is saying no microphone is connect to use the voice memo. HELP please

  • Dynamic tabstrips and table control in custom infotype

    Dear Experts, I have a requirement to create a custom infotype using tabstrips and table control. The tabstripes should also be dynamically populated. For example we have infty 8(Basic pay) used table control and 24(Qualifications) for tabstripes. Co

  • Photo effects in Garageband

    Is there a way to dissolve between photos in a Garageband podcast? Or is a cut between photos the only way to show the photos? I'm matching photos to a pre-recorded narration and can't create a slideshow first.

  • Table Compression on Partitions

    Hi, Can any help how to implement Table compression on Partitions? Thanks in advance