How to insert checkbox at a particular  cell  in jtable

hello,
I am a user of jdeveloper using jclient/swing .
question:
i am using jtable. i want that whenever i click on a specified cell then text at that particular cell get clear and a checkbox inserted in that cell . whenever i click on that checkbox i.e check the checkbox,
again a text is inserted in that cell.
thank you

Did you ever get this to work? If I bind a JCheckbox to my attribute and add the checkbox to my JClient panel, the attribute value is properly bound to the checkbox with everything working correctly. Adding the checkbox as the TableCellEditor for the column doesn't work.
Also, the link to using a Combobox as a table cell editor works, but the link doesn't tell where to donwload the sample code from. Doesn't anyone know the link?

Similar Messages

  • How to disable a particular cell in JTable ?

    I having a problem on how to set disable a particular cell in JTable. At the first place to load the JTable, I want to set some of the cell to disabled, it only will run at the first time, is there anyway to do it ?

    This is the function that disable/enable cells in JTables.
    Are you looking for this?
    public boolean isCellEditable(int row, int col)
      if(((new Integer((String)(getValueAt(row,0)).toString()).intValue()>9))&&(col==1))
        return true;
      if(row!=4&&col!=5)
        return true;
      return false;
         this metod belong to the TableModel function
    and what I gave you is only an example of what you can do with it.
    if it return false it disable and if true it enable the cell...but I think this you allready know!
    Regards Amnon

  • Setting Focus to a particular cell in JTable

    Hi, can i know how to set the focus to a particular cell in JTable.
    Say I have a table with 2 rows and 10 columns. The focus now is at position (1, 9) which is the last cell in the table. But I want to set the focus to (1, 3). How can i achieve this ? Pls help. Thanks

    OK. It's partially working. The right methods to use are setRowSelectionInterval and setColumnSelectionInterval. Jeanette was right. Mine didn't work because of a thread issue. I put the those two methods in a block such as:
    SwingUtilities.invokeLater(new Runnable(){
    public void run()
    table.setRowSelectionInterval(tblLineItem.getRowCount()-1,
    table.getRowCount()-1);
    table.setColumnSelectionInterval(0,0);
    Then it worked.
    But after I finished editing the first cell of the newly created row and press ENTER, the selection went back to the cell that's next to the originally editing cell on the first(old) row, instead of staying at the current row and going to the second cell.
    Can anybody shed a light on what I'm missing?

  • HOW TO GET VALUE OF A PARTICULAR CELL IN ALV GRID

    I HAVE 2 ALV GRID. IWANT WHEN I DOUBLE CLICK ON ANY PARTICULAR CELL OF FIRST GRID I WILL GET THE VALUE DISPLAYED ON THAT PARTICULAR CELL.
    THANKS IN ADVANCE

    Hi,
    If you are using a class alv, you only need to create a local class to control event and, before setting the screen to present the alv, you need to assign the class as a handler, like this:
        CREATE OBJECT event_handler.
        SET HANDLER event_handler->double_click FOR alv_grid.
    This event handler was defined before like below and a object was created for it:
    CLASS cl_event_handler DEFINITION.
      PUBLIC SECTION.
        METHODS double_click FOR EVENT double_click OF cl_gui_alv_grid
          IMPORTING e_row e_column.
    ENDCLASS.                    "cl_event_handler DEFINITION
    Then you need to implement this class, creating the method double click and do a READ TABLE to the itab you presented in the alv to recover the data, like this:
        READ TABLE itab INTO wk_itab
          INDEX e_row-index.
    The e_row structure was sent to the method by the handler, setting it with the line index that you double clicked in the alv. After that, you can manipulate the data that you selected in your internal table to generate the data to the other ALV.
    Best Regards,
    -h

  • How to display an image in particular cell editor

    Hi All,
    I want to display an image as the background for the table cell.
    I searched in sdn and found the solution only for link to action.
    I have created a dynamic table and if i click on apply button one more row is getting added according to my requirement.
    I want to differentiate this row from rest.  So I need to display image for the last row in the table which is added newly. 
    Can anyone suggest the procedure for adding an image in a particular cell editor along with the table data?
    Hope I am clear with my requirement.
    Pls suggest.
    Regards,
    subashini

    Hi,
    IF iam not wrong then for some rows u need to show text data and for some rows u need to show image data.
    follow the following steps.
    1. In ur table add cell editor of type Image.
    2.Create a value node with one more than required attributes.
    3.Suppose if need to show only one column then i will create  
       value node with two attributes.One attribute will be for text
      data and one will for Image.
    4.now access ur table cell editor dynamically.For image type
      cell editor we need to play only with two properties source
    and alt.Bind this alt property of editor wid that attribute which u
    need use for text data and source wid that attribute which u
    need to use for image.
    5.  Now suppose I need to show text data then
    I will create one element of that value node.In case of Image
    type cell editor source property  is given prefrence over alt
    property.
    set attribute which is bound to alt to the actual text data
    i.e setText("Actual text data");
    and set attribute which is bound to source to some dummy
    image name
    i.e setImage("dummy.gif");
    add this to node.
    during execution as source property of editor is bound to
    Image attribute of node  which in turn is set to dummy value it
    wont find actual source and will set Image cell editor with
    watever is bound to alt property which in turn set with actual
    text value..
    6.  Now suppose I need to show Image data then
    I will create one element of that value node.In case of Image
    type cell editor source property  is given prefrence over alt
    property.
    set attribute which is bound to alt to blank value 
    i.e setText("");
    and set attribute which is bound to source to some Actual 
    image name
    i.e setImage("Image.gif");
    add this to node.
    during execution as source property of editor is bound to
    Image attribute of node which in turn is set to Actual image file
    it will  set Image cell editor with that image name  and wont look for alt property.
    Copy all ur images in src->mimes->components->ur package
    Regards
    Surender Dahiya

  • How to insert the data to selected cell in multicolumn

    Hello Labviewer
    I am new for labview, and have a problem when i am using a multicolumn listboxes, how can i insert the data to my selected cell,
    something like
    header      XXX   

    mengyi
    The property node of the listbox has a "Item Names" property. This is a two dimensional array corresponding accordingly to the row by column listbox. You can modify this array to change the listed string for the selected cell(s).
    --Russ

  • How to Disable CheckBox for a Particular Condition

    Hi All,
    In my application, iam using one table having 5rows , with checkboxes,
    based on one condition i want to  make few checkboxes as default disable in the same table, and some checkboxes i shud make it as enable, so experts please help me how to disable some checkboxes.
    disable means even if we select it shud not get selected, like that is it possible,

    Hi Sushma,
    You can have one more attribute in the same node from where you are populating the table and bind this boolean attribute to the enabled property of your CheckBox.
    and by looping thriugh the table you can check for conditions and based on it set the Enability of the checkbox.
    for (int iRowsCount =0;iRowsCount < wdContext.node<name>().size();iRowsCount++)
    if (condition)
    // Disabling the Checkbox based on the condition
    wdContext.node<name>().get<name>ElementAt(iRowsCount).set<BooleanAttributeName>(false);
    Hope this helps!!
    Cheers,
    Arafat

  • How do I set background color of cell using JTable?

    Hello all!
    I have a question on the use of JTables. I am using a JDialog consisting of a JTable and a number of buttons to insert and to select OK or cancel. Everything is working perfectly, but I now must add editing capabilities to prevent invalid data being used in a SQL query to update or insert rows.
    So far I can't figure out how to get at a cell to set the background to red if the user inputs a Date incorrectly. Upon setValueAt(), I take this value and check for standard format errors. I hope to someday convert the column altogether to a Data object (or some form since Date is deprecated):-) For the time being, I know when an error occurs, but don't have the foggiest idea how to render the error (set backround to red).
    I need to give you more info too, since the way we do things is to make it as complicated as possible for job security and to impress the newbies(or scare them back to COBOL). When I setValueAt(), I have a DefaultDataElement object that houses everything for a given column in DB2. It has column name, length, data type, is it new, original value, current value, etc. If one doesn't exist, then I create one. After all said and done, I parse thru these elements and build my update/insert query and then execute the query.
    The event starts as soon as the user presses the OK button. But, if a date cell contains an invalid date, I need to halt processing (which I've done) and somehow let the user know which cell was invalid. We consider our users dumb (they really aren't, but the assumption is made), so I can't just say "error occurred in table. Verify data and try again". That won't work:-) Gotta be able to show them what cell is bad.
    Any ideas?
    Thanks,
    Patrick

    I finally figured it out. I was always close, but it wasn't until late yesterday that the light bulb came on. I was setting the background on the component in getTableCellEditorComponent() by grabbing the super.getTableCellEditorComponent(). The problem was all this was located in an editor, not renderer. So what happened was as I edited the cell the check would be performed then, not as focus was lost. When focus was lost, the red background went back to normal.
    I ripped the code out and made a custom renderer and got closer. Problem was the whole column had a red background. Even specifying the row and column in getTableCellRendererComponent didn't apply just to that cell. That row and column is only for obtaining the data in the cell, but anything affecting the component will affect the column, since I added the renderer to my TableColumn:-) I need to add error logic to my model and when an error occurs, set a boolean flag in a 2 dimensional array where the row and column is used to get to it from the renderer.
    Thanks for the help!!!

  • How to set the width of a cell in JTable?

    I have created a JTable and I want to set the width of cells.How can I do that?

    This is now the third person to tell you that Swing questions should be posted in the Swing forum.
    You have several postings out there where you have been given an answer but you haven't bothered to respond to the posting. Indicating whether the suggestion was helpfull or not. I guess you really don't want help from people in the future.

  • How to get the value from a cell in jTable without click "enter" or "tab"

    Hi guys,
    I have a simple question. I have a jTable in my screen and when editing a value, but without click "enter" or "tab" I want to get the new value. I have a button update and after editing the value I click the button "update" and I want the new value to be store in my table. If try to get the selected value it is giving the old value. How can I implement this? Any idea? I hope I was clear.
    Thanks

    [Table Stop Editing|http://www.camick.com/java/blog.html?name=table-stop-editing]

  • URGENT!!! How to set focus to a required cell in JTable with ENTER

    Hello everybody,
    I want to change the focus to the cell(identified by row, column) while pressing ENTER. Pleas help me on this issue.

    Hello Venkatesh. Yes that code does work. First I tried it on a table cell that was already rendered and it did work. The next time I tried it on a table row that was being added and it did not work there. So I added an on after rendering function for the table and added that code there. That did not work until I added a delay (timeout) to do a context switch before calling the focus and that worked.
    Once last thing though sometimes when I call focus on an input field (actually in a table row cell) if the field has text in it already the flashing cursor is at the beginning of the text and other times it is at the end of the text (which is the desired way). It depends on where I click in the row. Is there anyway to make sure the flashing cursor is at the end of the text when the focus is applied to a field that contains text?

  • Insert a JComboBox in a cell of JTable

    Hi,
    I have 3 comboboxes having different items, I want to add them in different rows of a JTable. I can add a JComboBox into a column using DefaultCellEditor but it will show either all items or the Items in the last ComboBox (if I call removeAll). What can I do? Can any one help me?
    Regards,
    Akhil

    I think
    you have to look for the XXXRenderer class or XXXCellEditor classes

  • How to insert jcheckbox in jtable

    hello
    i am user of oracle9i jdeveloper using jclient/swing .
    question:
    how to insert jcheckbox at a particular cell in jtable.
    please reply to me if anyone amongst you know the solution.
    thank you

    Please continue the discussion here: how to insert checkbox at a particular  cell  in jtable
    Correct me if this is not about the same subject.

  • How to insert textfield in a cell of a jtable ?

    Hi,
    i m not sure how to insert a textfield into a cell of a jtable which already contains some text in the cell .. Can anyone juz show mi a simple program to do this ??? thanks in advance =)

    Hi Michael,
    i get wad u r trying to say ermm actually i did that already. But wad i need to do is such that in a cell, there will b some text displayed (which i have done so) but i also need to add an additional box for user to enter the values n in this case i haf choosen to add the jtextfield box .. But i m not sure how to ... sorry for the misunderstanding ~~~ n thanks for ya reply =)

  • Exception -arrayindexoutobound  while inserting checkbox in a jtable

    hello,
    i am using oracle as backend. As you might be knowing that oracle doesn't store boolean datatype.
    so now please tell me how to insert checkbox in a jtable.
    please do help me if you can.

    HELLO camickr
    ONE INTERESTING THING IS HAPPENING->
    i had created 2 table in my form 1) jtable1 2) jtable2
    i had declared the listener on JTABLE1 as->
    jTable1.addMouseListener(new Mousehandler())
    I HAD WRITTEN THE METHOD AS->
    public class Mousehandler extends MouseAdapter
    public void mouseClicked(MouseEvent me)
    //NOTE ->HERE IS THE CODE TO ADD CHECKBOX ON A COLUMN FOR JTABLE1
    TableColumn sport= jTable1.getColumnModel().getColumn(1);
    // str=jTable1.getCellEditor();
    JCheckBox jCheckBox1 = new JCheckBox();
    sport.setCellEditor(new DefaultCellEditor(jCheckBox1));
    //NOTE-> HERE IS THE CODE TO ADD JCHECKBOX ON A JTABLE2
    TableColumn sportcol = jTable2.getColumnModel().getColumn(1);
    JCheckBox jCheckBox2 = new JCheckBox();
    sportcol.setCellEditor(new DefaultCellEditor(jCheckBox2));
    now when i click on JTABLE1 IT IS THROWING EXCEPTION BUT WHEN FUNCTIONING WITH jTable2 WHEN I CLICK ON THE COLUMN IN WHICH I HAD INSERTED CHECKBOX IT IS FUNCTIONING PROPERLY WITHOUT ANY ERROR.
    NOTE-> I HAD TO CLICK ONCE ON JTABLE1 THEN ONLY JTABLE2
    FUNCTION BECAUSE I HAD DECLARED LISTENER FOR JTABLE1 ONLY.(JTABLE1 IS THROWING AN EXCEPTION ARRAYINDEXOUTOFBOUND when i click on the column in which i had inserted jcheckbox im my jtable1)
    PLEASE DO HELP ME IF YOU CAN.
    THANK YOU.

Maybe you are looking for

  • Find not working in firefox

    In the last 2 days firefox updated auromatically. Current version is 24.0 When I select conmand F on Mac OS X. Usually the find box appears on the bottom left of the page. Which it does. Usually once I select command F I can then type a search term i

  • Upload an excel file in the server  with a background job

    I am trying to upload an excel file in the server, but i only can upload flat files, i can upload files in local with the function ALSM_EXCEL_TO_INTERNAL_TABLE, can i use this function reading an excel file in the server, or is there another possibil

  • Editing ABAP Program with out using ABAP Editor

    Dear Gurus, I know that ABAP Programs like SAPMSSY1, etc. are stored in Table D010S or REPOSRC as per the version of the SAP Released. my problem is that whem i open the table REPOSRC (Having around 34 colums), no doubt thati found the program list b

  • Isometric grid

    I need to be able to easily make an isometric grid so I can use it as a guide.  It doesn't need to have lock into position or anything, I just need a back ground image so i can layout isometric objects for an isometric game.  I need something that wi

  • Light Weight JCE Provider with RSA implementation

    Hi all, I'm working on an applet that requires RSA encryption, but I have size constraints so I canno tuse the BouncyCastle provider (891 KBs) Does anyone know where to find a light weight JCE provider with an implementation of RSA, I've been searchi