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

Similar Messages

  • Please help! How to add a combobox on a jtable

    Hi, I have seen on google and here many codes to add a combobox in a jtable but none of them seem to work, I need the urgently.
    My problem is that I must add a comboBox or a JComboBox to a cell inside a JTable on a predefined column. It means that on the column 2 I must add diferent comboboxes for eac row. How can I do it, please help.

    The celleditor is the component shown and the cellrenderer is the first render of a component in the cell and dont have to be the same jcombo box?
    The code on ther post does this:?
    returning a diferent combobox for all the cells on the column depending on the row selected, but as long as only one cell can be selected at a time it seems to hace different jcomboboxes added a time?
    Is there anyway to render any combobox with different values, my program must let the user chose the teacher it want to teach a definen subject, so the combo must have the teacher of a subject loaded on a database, the combos are not constants. I guess I can manage to use the way you showed me, but is there anyway to render a combo just by adding it to a cell! maybe doing changes to the tablemodel or things like that?

  • How to retrieve value from ComboBox inside a Jtable

    Hi everyone, I've this problem: I used the code that I founded to this link:
    [http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#combobox|http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#combobox]
    So I inserted a comboBox in my Jtable but I don't retrieve comboBox's values.
    I tried to retrieve these values in this way:
    myTable1.getModel().getValueAt(rowIndex, columnIndex).getClass();but this code produce a NullPointerException.
    thank you for helping me!!!!

    but I don't retrieve comboBox's valuesCorrect, because the combo box and its data is not part of the TableModel. The TableModel only stores the item that was selected from the combo box when the cell was edited.
    If you are getting an exception it is because you haven't set any data in your table model for the given cell.
    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.

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

  • ComboBox size in JTable

    How do you set the size of a combobox inside a JTable cell. I have used setPreferredWidth but the ccombo box is still huge. I have done searches and not found any answers.
    Thanks

    I've always let the UI take care of it. I don't set the minimum, maximum or preferred sizes and the UI sets the size to the size fo the cell.

  • Combobox Renderer in JTable

    Can someone please post code showing me how to make a renderer that would indicate a combobox in a JTable? I already have the combobox editor there, but I want the renderer to show a small down arrow, indicating to the user that the cell is a combobox.
    Thanks!

    public class ComboBoxRenderer extends JComboBox implements TableCellRenderer{
        public ComboBoxRenderer(Vector items) {
            super(items);
        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column){
            if (isSelected && !hasFocus){
                setBackground(table.getSelectionBackground());
                setForeground(table.getSelectionForeground());
            }else{
                setBackground(table.getBackground());
                setForeground(table.getForeground());
            setSelectedItem(value);
            return this;
    [/code[                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • 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

  • Multiple selection in JTable for deletion

    Dears,
    I'm using Jdeveloper 9.0.3.3 on 8.1.7 Oracle DB.
    I noticed that when a JTable is bound to a View object ==> only one row can be selected.
    My situation -which I think is very common- I have a screen with JTable where I can edit a row and commit my updates or select multiple selection in JTable and delete them at once ; thats what I need.
    It is very like the test of any application module but allow multiple selection and deletion in JTable for user's selected rows.
    How this could be done in JClient?
    Thankx in advance.

    Thanks for your suggestions! They both would work as workarounds, I think. I tried another way:
    Following code changes a TableBinding bound JTable's selection model to Multi select (thanks to Shailesh!!).
    void setMultiSelectionModel(JTable tbl)
    class MultiSelectionListListener implements javax.swing.event.ListSelectionListener
    ListSelectionModel defSelModel;
    MultiSelectionListListener(ListSelectionModel model)
    defSelModel = model;
    public void valueChanged(javax.swing.event.ListSelectionEvent e)
    if (!e.getValueIsAdjusting())
    ListSelectionModel listModel = (ListSelectionModel)e.getSource();
    int leadIndex = listModel.getLeadSelectionIndex();
    if (leadIndex == listModel.getAnchorSelectionIndex()
    && leadIndex == listModel.getMaxSelectionIndex()
    && leadIndex == listModel.getMinSelectionIndex())
    //change currency on the bound iterator only if
    //one row is being selected.
    defSelModel.setSelectionInterval(leadIndex, leadIndex);
    ListSelectionModel newModel = new DefaultListSelectionModel();
    newModel.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    newModel.addListSelectionListener(new MultiSelectionListListener(tbl.getSelectionModel()));
    tbl.setSelectionModel(newModel);
    This fixes the bug if you select some rows and then select a row before the first selected one. Seems to work great.

  • How to do Multi Cell Selection in JTable

    Dear Friends,
    Any body know Multi cell selection in jtable......
    Thanks

    Try overriding the changeSelection(....) method of JTable.
    public void changeSelection(int row, int column, boolean toggle, boolean extend)
         if (d.after(currentDate)
              super.changeSelection(row, column, toggle, extend);
    }

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

  • How to programatically select different JTable cells

    Dear all,
    I need to programatically select different JTable cells.
    I have to make the inverse selection. So if the user has a table of one column and 10 rows, and selects rows 3,6,8, the inverse selection should select all the other remainig cells and deselect 3,6, and 8.
    I tried using the following but it does not work ?
    for (int i = 0; i < table.getRowCount(); i++) {
    table.changeSelection(i, 0, true, false);
    Hope someone can help.
    Regards,
    Kanita

    Dear all,
    I need to programatically select different JTable cells.
    I have to make the inverse selection. So if the user has a table of one column and 10 rows, and selects rows 3,6,8, the inverse selection should select all the other remainig cells and deselect 3,6, and 8.
    I tried using the following but it does not work ?
    for (int i = 0; i < table.getRowCount(); i++) {
    table.changeSelection(i, 0, true, false);
    Hope someone can help.
    Regards,
    Kanita

  • I keep losing my Selection arrow functionalities on documents I've converted from CS2 to CS6. I reinstall preferences and it works for a few minutes but all is lost again. What to do?

    I keep losing my Selection arrow functionalities on documents I've converted from CS2 to CS6. I reinstall preferences and it works for a few minutes but all is lost again. What to do?

    What OS?
    Id you still have CS2 installed someplace, export the original files as .inx (InDesign Interchange) and convert that instead of the .indd.

Maybe you are looking for

  • Error -241741785​1 using Report generation toolkit

    I try to use the Report Generation toolkit (Version 1.0.1) for MS Office und the example "Generate Report from Template (Excel).vi" return an Error -2417417851 I run Labview 6.02, on Win2000 German, and use Office 97 (Everything is installed (include

  • Can I share my icloud account?

    can i share my icloud with my wife, or does she need a separate account? if she shares my account, i want to be able to email her from my address (she will want a separate email address, so for example, from [email protected] to [email protected].) 

  • If I would like to have all opened tabs in my browser stop loading a webpage is their a shortcut key that will allow this?

    If I open too many Bookmarked pages into tabs my browser will hang and then sometimes crash or close unexpectedly. If I bring up task manager or use the Alt + Tab I can navigate to the window and right-click and choose restore to allow me to see the

  • Smart Playlists Question

    Who knows a lot about Smart Playlists? I want to create a playlist that has all of my songs sorted first by "Play Count", then by song title. Does anyone know how to do this? I could write a MySQL query to do this in 2 minutes, but I don't know enoug

  • SDM deployment hangs

    We are running NW2004S ABAP instance on WIndows 2003 x64 and SQL 2005 (x64) and I just added the Java instance for BI reporting. The install went just fine with no errors or surprises. Now that its been added I was planning on updating all the java c