Updating a sorted table when a cell editor is open

In Sun's table sorter demo, if you are in the middle of editing a cell and you toggle the sort on any column, the editor automatically cancels the edit, closes the editor and the table sorts appropriately. I am guessing that the cancelEditing method on the editor is called somehow by the table when the table data changes.
For some reason, in my application, when the sort is toggled, the editor remains open and does not cancel. As a result, when the table sorts, the value you are editing is not for the correct row anymore.
The custom cell editors I am using are not the problem because I removed them and I still have this problem.
Unfortunately, it would be extremely difficult for me to provide a sample application to demonstrate my problem because there is so much proprietary stuff mixed into my tables. I am hoping someone else is familiar with the problem I am having and can offer some solution.
Thanks in advance for any assistance.

Actually I do have this setup on the table and when sorting is toggled, the focus remains in the editor so it does not terminate.
Any other possibilities?

Similar Messages

  • Problem sorting JTable with custom cell editor

    Greetings,
    I have created a JTable with a JComboBox as the cell editor for the first column. However, I couldn't simply set the default cell editor for the column to be a JComboBox, since the values within the list were different for each row. So instead, I implemented a custom cell editor that is basically just a hashtable of cell editors that allows you to have a different editor for each row in the table (based on the ideas in the EachRowEditor I've seen in some FAQs - see the code below). I also used a custom table model that is essentially like the JDBCAdapter in the Java examples that populates the table with a query to a database.
    The problem comes when I try to sort the table using the TableSorter and TableMap classes recommended in the Java Tutorials on JTables. All of the static (uneditable) columns in the JTable sort fine, but the custom cell editor column doesn't sort at all. I think that the problem is that the hashtable storing the cell editors never gets re-ordered, but I can't see a simple way to do that (how to know the old row index verses the new row index after a sort). I think that I could implement this manually, if I knew the old/new indexes...
    Here's the code I use to create the JTable:
    // Create the Table Model
    modelCRM = new ContactTableModel();
    // Create the Table Sorter
    sorterCRM = new TableSorter(modelCRM);
    // Create the table
    tblCRM = new JTable(sorterCRM);
    // Add the event listener for the sorter
    sorterCRM.addMouseListenerToHeaderInTable(tblCRM);
    Then, I populate the column for the custom cell editor like this:
    // Add the combo box for editing company
    TableColumn matchColumn = getTable().getColumn("Match");
    RowCellEditor rowEditor = new RowCellEditor();
    // loop through and build the combobox for each row
    for (int i = 0; i < getTable().getRowCount(); i++) {
    JComboBox cb = new JComboBox();
    cb.addItem("New");
    //... code to populate the combo box (removed for clarity)
    rowEditor.add(i,new DefaultCellEditor(cb, i))); //TF
    } // end for
    matchColumn.setCellEditor(rowEditor);
    Any ideas how to do this, or is there a better way to either sort the JTable or use a combobox with different values for each row? Please let me know if more code would help make this clearer...
    Thanks,
    Ted
    import java.util.*;
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.table.*;
    import javax.swing.event.*;
    public class RowCellEditor implements TableCellEditor
    protected Hashtable editors;
    protected TableCellEditor editor, defaultEditor;
    public RowCellEditor()
    editors = new Hashtable();
    defaultEditor = new DefaultCellEditor(new JTextField());
    public void add(int row, TableCellEditor editor)
    editors.put(new Integer(row), editor);
    public Component getTableCellEditorComponent(JTable table,
    Object value,
    boolean isSelected,
    int row,
    int column)
    editor = (TableCellEditor) editors.get(new Integer(row));
    if (editor == null)
    editor = defaultEditor;
    return editor.getTableCellEditorComponent(table,
    value,
    isSelected,
    row,
    column);
    public Object getCellEditorValue() {
    return editor.getCellEditorValue();
    public boolean stopCellEditing() {
    return editor.stopCellEditing();
    public void cancelCellEditing() {
    editor.cancelCellEditing();
    public boolean isCellEditable(EventObject anEvent) {
    return true; //TF
    //return editor.isCellEditable(anEvent);
    public void addCellEditorListener(CellEditorListener l) {
    editor.addCellEditorListener(l);
    public void removeCellEditorListener(CellEditorListener l) {
    editor.removeCellEditorListener(l);
    public boolean shouldSelectCell(EventObject anEvent) {
    return editor.shouldSelectCell(anEvent);
    -------------------

    Well, I found a solution in another post
    (see http://forum.java.sun.com/thread.jsp?forum=57&thread=175984&message=953833#955064 for more details).
    Basically, I use the table sorter to translate the row index for the hashtable of my custom cell editors. I did this by adding this method to the sorter:
    // This method is used to get the correct row for the custom cell
    // editor (after the table has been sorted)
    public int translateRow(int sortedRowIndex)
    checkModel();
    return indexes[sortedRowIndex];
    } // end translateRow()
    Then, when I create the custom cell editor, I pass in a reference to the sorter so that when the getTableCellEditorComponent() method is called I can translate the row to the newly sorted row before returning the editor from the hashtable.

  • Updating a vendor table when address changes in infotype 6

    hello all,
    when an employee changes his personal information in the PZ02 service, it updates the infotype 6, as soon as the update is done it has to update the LFA1 or LFB! vendor table.
    is there a workaround for this
    BR
    venu

    thanks for the reply.
    whenever there is an address change in IT6 it should update the vendor table(for eg: if changes are done in PA30 and not from ess, so its kind of generic version that i have to create to update the vendor table either from ess or PA30).
    i am already using the HR_ESS_ADDRESSDETAIL and HR_ESS_ADDRESSLIST for changing the fields on the iview.
    (t77www_sc)and linking it to pz02.so what u mean is i can go ahead and write the code in the same module for updates.
    is this is the only way to do it, or we can do it by BAPI_address_change.
    I am trying to know all the different ways it can be done.
    a)can i use a BAPI if so which one?
    b) can i do it thru workflow.
    c)or user exit.
    Please help me out with details
    thanks
    venu

  • How to update two database tables when using DatabaseProvider

    I'm a begginer and I've made an application which uses a database. In one page, I have a table which I've took it from "woodstock basic" palette. I was using DatabaseProvider to populate the table with data from a database table called "copii". My code is:
    //i'm check all the rows in the table to see if the field "IDCOPIIC" =0 and if true I will put the value of "newCopiiId"
    do {
    if (copiiDataProvider.getValue("IDCOPIIC").equals
    (new Long(0))) {
    copiiDataProvider.setValue("IDCOPIIC", new Long(newCopiiId));
    newCopiiId++;
    } while (copiiDataProvider.cursorNext());
    copiiDataProvider.commitChanges();
    My problem comes now because I have another database table tided with a foreign key by this one and I want to update this one too when I'm updating the "copii" table. I don't know how to do it ...I've tried in many ways but is impossible. Can anyone help me ! I'm desperate...I cannot figure it out how I could insert, update in two tables in the same time when I'm using DataProvider .
    Thanks in advance!

    Hmm.
    Not sure where your going with the <select> menu.
    The description you made:
    "Both have an id column, which is presumably the record's primary key, but you need to create a relationship by storing the primary key of one table as a foreign key in the child (related) table. For example, you should insert the primary key of the first table in the second table as user_id. That enables you to identify which username and password are related to an individual listed in the second table"
    Seems to be the direction that I'm looking for.
    Now my question is how do I insert the primary key of the first table in the second table as user_id?
    >
    >"For example, you should insert the primary key of the first table in the second table as user_id"
    Since both tables have an id column and they both are the primary key, do I just change the name of the second tables id column to "user_id" then?
    Or is there an actual "insert the primary key to another table" function that I don't know about?

  • Table with Linktoaction cell editor VS ALV with Link to action cell editor

    Hi,
    i am replacing table UI with ALV, i am encountering series of problems one of them is below.
    when i click on linktoaction cell in table i can see wdevent has context_element which is element reference, which is being used in action handler to perform some logic...
    however when i replace with alv where i displayed one column with link to action cells using CL_SALV_WD_UIE_LINK_TO_ACTION class, however when i click on any particular cell i only get information related to that cell like column name, attribute name, value and position.
    however as i said i need context element reference to work with which is not coming with alv.
    please suggest.

    yes, that is right, you have to get the context element from the node based on the Index you get.

  • How to update a fact table when a dimension table is reloaded

    We have implemented BI Apps 796. Insertion into W_EMPLOYEE_D table which stores all the employee information had stopped one year back as some company security policy restricted the informatica worklfows to pick up the data. (PER_ALL_PEOPLE_F was a HRMS table and it contained sensitive information line SSN and salary, was inaccessible to the user which informatica uses and the SDE mapping used to return 0 rows).
    Now we have the approval to see those rows and the dimension table is loaded with some 100 new employees who joined in last one year.
    The ROW_WID of W_EMPLOYEE_D is referenced in lot of fact tables and for all those missing employees the WID in the fact table is 0.
    Now that we have all employees, how to make the FACT table point to the correct WID and not store 0. Has anyone faced this problem before?? Writing an update statement will be a tedious task as there are so many fact tables that join to w_employee_d. Also our company uses Sales, Procurement, Finance modules of OB Apps (which constitutes atleast 20 fact tables)
    Any guidance is appreciated. Thanks in advance

    Hello Kostis,
    thank you for your answer. I don't fully understand you. Can you show me short example, please? I create alias table for time dimension on Physical Layer - original table is TimeDayDim and I create aliases TimeDayDim1, TimeDayDim2, TimeDayDim3, TimeDayDim4. Then I create foreign key Fact.Time1 -> TimeDayDim1, Fact.Time2 -> TimeDayDim2, Fact.Time3 -> TimeDayDim3, Fact.Time4 -> TimeDayDim4. And what now? Must I create these table api Bussines Model and create new time dimensions at bussiness model????
    I need in Answers ONE Time dimension. I think I must split my fact table to four tables ... (time1, place1 ...) (time2, place2 ...) (time3 place3...) (time4 place4...) then link those tables to Time dimension (but I dont know where I can split those tables - on Physical Layer or on Bussines Layer).
    I suppose that I will have in Answers one time dimension and four facts tables and I will be able to query them. (for example: Time.Days, Fact1.Place1, Fact3.Speed, Fact4.Count Criteria: Time.Year = 2008)
    Best Regards Vlada

  • How do i update a db table using one JSP page

    I created a JSP Form page and I want to update a db table when the user hit submit. Please help my job depends on it Send me small code example below is what I have (very new to JSP)
    <%@ page language="java" import="java.sql.*" import="java.io.*" %>
    <html>
    <head><title>accessing database</title></head>
    <body bgcolor="white">
    <%     Connection con =null;
         try {
    // Load Driver Class File
         Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    //Make a connection to Data table
    con = DriverManager.getConnection("jdbc:odbc:SportsbookTables", "developer", "developer");
    Statement statement =con.createStatement();
    String SQL = new String("INSERT INTO tblLines (gameID,leagueType) VALUES (5,'gam')");
    statement.executeUpdate(SQL);
    statement.executeUpdate("INSERT INTO tblLines (gameID,leagueType) VALUES (6,'lea')");
    %>
    <table border=1 cellspacing=1 cellpadding=1>
    <form method="POST">
    <p><font color="#800000" size="5">Enter your name:</font><input name="leagueType" size="4"></p>
    <p><input type="submit" value="Submit"></p>
    </form>
    <%
    catch (IOException ioe)
    out.println("IO Exception:");
    out.println(ioe.getMessage());
    catch (SQLException sqle)
    out.println("SQL Exception:");
    out.println(sqle.getMessage());
    catch (ClassNotFoundException cnfe)
    out.println("Class Not Found Exception:");
    out.println(cnfe.getMessage());
    catch (Exception e)
    out.println("General Exception:");
    out.println(e.getMessage());
    finally {
    try
    if (con!=null) {
    con.close();
    catch(SQLException sqle)
    out.println(sqle.getMessage());
    %>
    </table>
    </Body>
    </HTML>

    First I would remove all the JDBC code you have in the JSP and place it in a servlet (or other Java) class, and have your form action call the servlet on submission. Then use the servlet API to extract the form data from the request and pass it to the JDBC in the servlet to update the DB. Once complete have it branch to another JSP/HTML to let the user know if they were successful or not.
    Take a look at some of the online tutorials as they will be helpful with regards to code examples.
    Depending on the size of your project, and deadlines naturally, you may also want to have a look at an MVC architecture and custom tags like Struts from Apache. These can make your job a lot eaiser.

  • Track which attributes/column are updated of a table

    Hi All,
    How can i track that which columns are updated of a table when update statement is executed on that particular table. I want to track it in update trigger.
    Suppose table name is T1 and has columns A,b,c, ...... z.
    One way is compare values of all columns using if statement like
    if :new.a <> :old.a then
    but this method is quite code expensive particular for table having 100 plus column.
    Is there exist any dictionary view which can provide this info.

    if (UPDATING('YOUR_COLUMN_NAME'))
    then
      your_code_for_this_col_update ;
    end if ;

  • On submit perform an insert on one table and an update on aother table

    I am trying to perform and insert on the table one table (the wizard created my form the insert is going against the table that I created using the wizard) and on the form is on field that is also in another table. Therefore, I am trying to perform an update on one attribute of one table and a insert into another table. How do I do this in apex?

    If you have used wizard to create form, then you may see a process of type 'Automatic Row Processing (DML)' in your page which will perform INSERT/UPDATE/DELETE on your form table. Here you can see APEX performs INSERT only when REQUEST is in 'INSERT, CREATE, CREATE_AGAIN, CREATEAGAIN'
    So create one more PL/SQL page process which will execute at 'on Submit after validations' and write update process as follows
    begin
    -- pseudo table/columns
    update tbl_second
    set col1 = :p1_item
    where pk_col = :p1_pk_item;
    end;Make this process conditional so that it will perform UPDATE only when request value is in 'INSERT, CREATE, CREATE_AGAIN, CREATEAGAIN' ( i.e. only when you are inserting into your form table)
    Cheers,
    Hari
    p.s. I think you may also need to update the second table when some-one updates your form table.
    Edited by: Hari_639 on Oct 26, 2009 9:46 AM

  • When I clicked on Firefox, the update bar started but when it stopped Firfox would not open. The blue screen of death popped up and said something about a new installation. We restarted the computer and now Firefox will not open. Help!

    When I clicked to open Firefox the update bar appeared and an update loaded. Usually when this happens Firefox will open up when the update is finished. This time it did not open. when I clicked on the icon again the blue screen opened and said something about a new installation and if this was the first time you have seen this screen restart your computer and try again. I restarted the computer and when I clicked on the Firefox icon the "hour glass" would appear like it was trying to open but it never would open. I don't know what else to do.

    See below -- the way I asked the question the first time may not be clear. This post was a goof but I can't figure out how to delete it

  • How to create a context menu in ALV table cell editor(Webdynpro abap )

    Hello Experts,
    I am having a problem in creating a context menu in a table cell editor in the ALV table output.I have assigned a 'lta' as the cell editor.But befor assigning the lta as cell editor I have assigned the menu to the lta.But when the view is rendered I can see the lta with the actioned assigned to it.But I cannot see the context menu.
    The code snippet below:
      "Create menu for each coloumn
      create OBJECT lo_menu_actions type CL_SALV_WD_VE_MENU EXPORTING
          id = 'MITM_ACTIONS'.
      lo_menu_actions->set_visible( value = abap_true ). 
      lo_menu_actions->set_visible_fieldname( value = 'ACTIONS' ).
      "ADd menu items
      CREATE OBJECT lo_menu_item_create type CL_SALV_WD_VE_MENU
      exporting
        id = 'MITM_CREATE_EXPRESSION'.
      lo_menu_item_create->set_visible( value = abap_true ).
      lo_menu_item_create->set_visible_fieldname( value = 'Create' ).
      "Add item 1
      lo_menu_actions->ADD_ITEM( VALUE = lo_menu_item_create ). 
      "  Set the cell editor for each column cell(link to an action)
      LOOP AT lt_node_dec_tab_cols INTO ls_node_dec_tab_cols .
        lv_column_name = ls_node_dec_tab_cols-object_name.
        lr_column = lr_column_settings->get_column( lv_column_name ).
       "Create 'lta' Ui item
        CREATE OBJECT lo_lta TYPE cl_salv_wd_uie_link_to_action.
        lo_lta->set_menu( value = lo_menu_actions ).
        lo_lta->set_text_fieldname( lv_column_name ).
        lr_column->set_cell_editor( lo_lta ).
        IF ls_node_dec_tab_cols-is_result EQ abap_true.
          lr_column->set_cell_design( value =
                      cl_wd_table_column=>e_cell_design-key_medium ).
        ENDIF.
      ENDLOOP.

    Hi Prakash,
    I have not come across this requirement till now to have context menu in a cell editor of alv.
    Unfortunately  the implementation of method SET_MENU of alv ui elements ( ex: cl_salv_wd_uie_text_view ) is not updating alv configurable table, instead it just stores in a global attribute as string. Hence has no effect on context menu.
    If your user is very particular about this requirement of having context menu in cell editor, you can go for a normal table. Because, normal table's cell editor has the property to set the menuID as we do it for other ui elements.
    Regards,
    Rama

  • List UIBB - Access to cell editor for a certain table line possible

    Hi,
    I am looking for a way to access the cell editor of the last table line as I want to mark it as a special - summary - line.
    I intend a similar approach like in WebDynrpo ABAP when accessing the node info and modifying the "CELL DESIGN" attribute like in the following code (copied from WD Comp WDR_TEST_TABLE, View CELL DESIGN, method FILL_CELL_DESIGNS) :
      data tab type IF_CELL_DESIGN=>Elements_Cell_Designs.
      data line type IF_CELL_DESIGN=>Element_Cell_Designs.
      data node_info type ref to if_wd_context_node_info.
      data attribute_info type wdr_context_attribute_info.
      data attr_value type WDR_CONTEXT_ATTR_VALUE.
      node_info = node->get_node_info( ).
      attribute_info = node_info->get_attribute( 'CELL_DESIGN' ).
      line-is_expanded = abap_true.
      line-is_leaf     = abap_false.
      line-key         = 'FIRST'.
      loop at attribute_info-value_set into attr_value.
        line-text = sy-tabix.
        concatenate 'Text #' line-text into line-text. "#EC NOTEXT
        line-cell_design = attr_value-value.
        insert line into table tab.
        line-is_leaf = abap_true.
        line-key = attr_value-value.
        line-parent_key = 'FIRST'.
      endloop.
      node->bind_table( tab ).
    I suspect the method IF_FPM_GUIBB_LISTGET_DATA (or IF_FPM_GUIBB_LISTGET_DEFINITION) of my feeder class to be the right access point.
    But unfortunately, I have not yet found out how to change the cell design for specific lines, only for whole columns.
    Can anyone give me a hint here?
    BTW: The "summary" line is not a sum of the lines above, but determined by backend logic, so not ALV-summary line for me.
    Kind Regards

    Hi,
    A short update for all interested:
    My current work around is to always set the lead selection to the summary line. It does in a kind "mark" that line as special as long as I cannot mark it using a different cell design.
    How do I assure this?
    I have implemented the following code in a redefinition of the method ADJUST_SELECTION:
    *- alter selection
      DATA:
       ls_size TYPE rstabix.
      "get index of summary line
      ls_size-tabix = mo_collection->size( ).
      "change only if there are any cash conc. proposals
      IF ls_size-tabix > 0.
        "do FPM selection
        CLEAR: ev_lead_index, et_selection.
        ev_lead_index = ls_size-tabix.
        APPEND ls_size TO et_selection.
        "do BOL selection
        mo_collection->if_bol_bo_col_multi_sel~unmark_all( ).
        mo_collection->if_bol_bo_col_multi_sel~mark( iv_index = ls_size-tabix ).
      ENDIF.
    The general downside is, that no other selection is possible!
    The selection is always reset to the summary line with each roundtrip.
    Waiting for a better solution...
    Kind Regards,
    Robert

  • Table Cell Editor

    Hi All,
    I created JTable. For one column I have given Combo box as editor.
    when the program is run, if I select any value in first row in combo box,
    the same value will be chosen for other rows also.That is if I just click in the other row's combo box, then the value which I choose in the first row will be updated wherever I clicked.
    How to rectify this problem.
    Thanks in advance.

    Hi,
    Thanks all for the reply.
    Actually during the new operation, it is working correctly.
    But it gives the issue in edit.Let me explain this with the example.
    In the combo box cell editor I have the following values.
    Red,Green,Blue,Yellow.
    During the edit opertion, for the specific user ,I fill his details from the database.For example in text box, I filled his name and in table his shirts in one column and the corresponding colors in combo box as second column.
    So shirt1 - red,shirt2 - Green....it goes like this....
    In the edit mode,I select Blue for shirt1.
    If I click in the second row's combo box, by default it selects Blue.But it should retain its original value(Green) only.
    But it sets the value which the first column gets selected......
    How to retain the old value....

  • Small issue with custom table cell editor and unwanted table row selection

    I'm using a custom table cell editor to display a JTree. Thing i notice is that when i select a value in the tree pop-up, the pop-up closes (as it should) but then every table row, from the editing row to the row behind the pop-up when i selected the value becomes highlighted. I'm thinking this is a focus issue, but it thought i took care of that. To clairfy, look at this: Before . Notice how the "Straightening" tree item is roughly above the "Stock Thickness" table row? When i select Straightening, this is what happens to my table: After .
    My TreeComboBox component:
    public class TreeComboBox extends JPanel implements MouseListener {
        private JTextField itemField;
        private TreeModel treeModel;
        private ArrayList<ActionListener> actionListeners = new ArrayList<ActionListener>();
        private Object selectedItem;
         * Creates a new <code>TreeComboBox</code> instance.
         * @param treeModel the tree model to be used in the drop-down selector.
        public TreeComboBox(TreeModel treeModel) {
            this(treeModel, null);
         * Creates a new <code>TreeComboBox</code> instance.
         * @param treeModel the tree model to be used in the drop-down selector.
         * @param selectedItem tree will expand and highlight this item.
        public TreeComboBox(TreeModel treeModel, Object selectedItem) {
            this.treeModel = treeModel;
            this.selectedItem = selectedItem;
            initComponents();
         * Returns the current drop-down tree model.
         * @return the current <code>TreeModel</code> instance.
        public TreeModel getTreeModel() {
            return treeModel;
         * Sets the tree model.
         * @param treeModel a <code>TreeModel</code> instance.
        public void setTreeModel(TreeModel treeModel) {
            this.treeModel = treeModel;
         * Returns the selected item from the drop-down selector.
         * @return the selected tree object.
        public Object getSelectedItem() {
            return selectedItem;
         * Sets the selected item in the drop-down selector.
         * @param selectedItem tree will expand and highlight this item.
        public void setSelectedItem(Object selectedItem) {
            this.selectedItem = selectedItem;
            String text = selectedItem != null ? selectedItem.toString() : "";
            itemField.setText(text);
            setToolTipText(text);
         * Overridden to enable/disable all child components.
         * @param enabled flat to enable or disable this component.
        public void setEnabled(boolean enabled) {
            itemField.setEnabled(enabled);
            super.setEnabled(enabled);
        public void addActionListener(ActionListener listener) {
            actionListeners.add(listener);
        public void removeActionListener(ActionListener listener) {
            actionListeners.remove(listener);
        // MouseListener implementation
        public void mouseClicked(MouseEvent e) {
        public void mouseEntered(MouseEvent e) {
        public void mouseExited(MouseEvent e) {
        public void mousePressed(MouseEvent e) {
        public void mouseReleased(MouseEvent e) {
            showPopup();
        private void initComponents() {
            setLayout(new GridBagLayout());
            itemField = new JTextField();
            itemField.setEditable(false);
            itemField.setText(selectedItem != null ? selectedItem.toString() : "");
            itemField.addMouseListener(this);
            add(itemField, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0,
                    GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
        private void showPopup() {
            final TreePopup popup = new TreePopup();
            final TreeComboBox tcb = this;
            final int x = itemField.getX();
            final int y = itemField.getY() + itemField.getHeight();
            int width = itemField.getWidth() + popupButton.getWidth();
            Dimension prefSize = popup.getPreferredSize();
            prefSize.width = width;
            popup.setPreferredSize(prefSize);
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    popup.show(tcb, x, y);
                    popup.requestFocusInWindow();
        private void fireActionPerformed() {
            ActionEvent e = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "TreeComboBoxSelection");
            for (ActionListener listener : actionListeners) {
                listener.actionPerformed(e);
        private class TreePopup extends JPopupMenu {
            private JTree tree;
            private JScrollPane scrollPane;
            public TreePopup() {
                initComponents();
                initData();
            private void initData() {
                if (treeModel != null) {
                    tree.setModel(treeModel);
            private void initComponents() {
                setFocusable(true);
                setFocusCycleRoot(true);
                tree = new JTree();
                tree.setRootVisible(false);
                tree.setShowsRootHandles(true);
                tree.setFocusable(true);
                tree.setFocusCycleRoot(true);
                tree.addTreeSelectionListener(new TreeSelectionListener() {
                    public void valueChanged(TreeSelectionEvent e) {
                        tree_valueChanged(e);
                scrollPane = new JScrollPane(tree);
                add(scrollPane);
            private void tree_valueChanged(TreeSelectionEvent e) {
                DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
                setSelectedItem(node.getUserObject());
                fireActionPerformed();
                this.setVisible(false);
    }My TreeComboBoxTableCellEditor:
    public class TreeComboBoxTableCellEditor extends AbstractCellEditor implements TableCellEditor, ActionListener {
        protected TreeComboBox treeComboBox;
        protected ArrayList<CellEditorListener> cellEditorListeners = new ArrayList<CellEditorListener>();
        public TreeComboBoxTableCellEditor(TreeComboBox treeComboBox) {
            this.treeComboBox = treeComboBox;
            treeComboBox.addActionListener(this);
        public Object getCellEditorValue() {
            return treeComboBox.getSelectedItem();
        public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
            treeComboBox.setSelectedItem(value);
            return treeComboBox;
        public void actionPerformed(ActionEvent e) {
            stopCellEditing();
    }Any thoughts?
    Edited by: MiseryMachine on Apr 3, 2008 1:21 PM
    Edited by: MiseryMachine on Apr 3, 2008 1:27 PM

    As I said, you have to have empty context elements before additional rows will be open for input.
    For instance if you want to start with 5 rows available for input do the following to your internal table that you will bind:
    data itab type standard table of sflight.
    do 5 times.
      append initial line to itab.
    enddo.
    context_node->bind_table( itab ).
    The other option if you need n number of rows is to add a button to the table toolbar for adding more rows. When this button is pressed, you add a new context element to the node - thereby creating a new empty row in the table.

  • How can one resize a cell editor when in use in a JTree?

    It is possible to resize, for example, a JTextArea cell editor while it is being used in a JTable by having a document listener check the preferred height and then changing the rowHeight of the table to fit that. This gives the nice effect of the table expanding and contracting in size as required while it is being edited.
    I would also like to this this for a Jtree. But one cannot reset the height of an individual JTree row, and although it can be set up to get the correct height when the editor or renderer is installed (via setRowHeight(0)), there does not seem to be a way to dynamically adjust this height while editing.
    This would be very nice to be able to do. (I would say it should be required of a good tree component that it allow this).
    Is there some way I am missing? It seems like there is no difficult constraint on the design of Jtree which should make this difficult in principle.

    You cannot download apps from another country's store unless you have an account in that country which means having a credit card that is tied to a physical address in that country.
    AFAIK, you cannot add more dictionaries to the collection that. Apple has provided. There is no way to add any plug ins, or enhancements to any of the built to in apps or iOS functions.

Maybe you are looking for