How to set JTable cell editable/non-editable dynamically using NetBean?

I am using NetBean 6.5, create a database desktop application, I using the persistence entity manager to bind my JTable with database.
Now, I want to set practicular cells which are enable and disable, I tried to create my own table model and override the isEditable() method, which it seems didn't work. I guessed the problem is the persistence connection between my Table and database.
How can I solve it? Any example? I just googled the web and can't find example which use netbean combined with database. I know that a single JTable would work when creating your own model.
thx.

I know what coding i did, Yes u r right but im new to GUI programming only,
That's why i posted it to forums, I gone through the Control Flow Statements link what u have given.
U didnt get my question at all.
Again the problem im facing is the table is already displayed with 2nd column uneditable.
When some Action done on table, i need to make 2nd column editable at run time.
Thanks if u provide me the solution instead of deciding what type of programmer im.

Similar Messages

  • How to set JTable cells to uneditable

    I was trying to set the cells in my Jtable to uneditable.
    I overrided the isCellEditable method. Here is what I did. But the
    cells remain editable. Any ideas?
    private class MyTableModel extends DefaultTableModel
    public MyTableModel(Vector vectRow,Vector vecColumn)
    super(vecVector,vecColumn);
    public boolean isCellEditable(int row, int col)
    if (col >= 0) {
    return false;
    }

    Just Use:
    public boolean isCellEditable(int r, int c) { return false; }

  • How to set jtable editable?

    how to set jtable editable?

    Hi,
    Doubleclick on a particular cell to get the cellEditor for editing.
    Cheers :)
    Nagaraj

  • Set editable/non-editable checkbox in alv grid

    Hi all,
    How to set a checkbox in alv grid in editable/non-editable. i am using alv gird display function module for this. i tried to used method  cl_gui_alv_grid=>mc_style_disabled. but its not working. is it possible to have this functionality in grid? please help. thanks in advance.

    Hi,
    Try like this.
    CALL METHOD gr_alvgrid->set_table_for_first_display
    EXPORTING
    I_BUFFER_ACTIVE =
    I_CONSISTENCY_CHECK =
    I_STRUCTURE_NAME =
    IS_VARIANT =
    I_SAVE =
    I_DEFAULT = 'X'
    is_layout = gs_layout
    IS_PRINT =
    IT_SPECIAL_GROUPS =
    IT_TOOLBAR_EXCLUDING =
    IT_HYPERLINK =
    CHANGING
    it_outtab = gt_list[]
    it_fieldcatalog = gt_fieldcat
    IT_SORT =
    IT_FILTER =
    EXCEPTIONS
    invalid_parameter_combination = 1
    program_error = 2
    too_many_lines = 3
    OTHERS = 4
    regards
    Rajesh kumar

  • I dont know how to set a site setup and edit some ready html files

    how to set up a site in dreamweaver when using a WAMP SERVER and edit some html files

    Is it a PHP or ASP site or does it have SSI components?
    If not you don't need to seet up a server. You can preview pages offline in a browser window.
    If it IS a PHP, ASP or SSI site, you need to copy it (the site folder)  to your "www" folder of the WAMP folder and then define the site using the folder you placed in the "www" folder as the root.

  • Setting JTable cell editor

    Hallo,
    I have troubles setting jtable cell edtior. when i run code below, editor stays unchnaged.
    Do you know where's the problem, please (except in programmer^_^) ???
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.table.DefaultTableModel;
    public class Test extends JFrame {
        JTable table;
        Test() {
            // Create table model
            table = new JTable();
            table.setModel(new DefaultTableModel(
                new Object[][] {
                    { Boolean.TRUE, Integer.valueOf(10) },
                    { "Hallo!", Boolean.FALSE },
                }, new String[] { "Col1", "Col2" }));
            // Setup frame a little
            setLayout(new BorderLayout());
            setBounds(new Rectangle(300,300,200,100));
            setDefaultCloseOperation(EXIT_ON_CLOSE);
            add(table,BorderLayout.CENTER);
             * Two calls below have no effect:-(
             * What did i wrong?
            // set cell editor for all cells
            table.setCellEditor(new DefaultCellEditor(
                    new JComboBox(new String[] { "0", "1" }) ));
            // Use checkbox for booleans
            table.setDefaultEditor(Boolean.class, new DefaultCellEditor(
                    new JCheckBox() ));
            // Use combobox for strings
            table.setDefaultEditor(String.class, new DefaultCellEditor(
                    new JComboBox( new String[] { "Hallo!", "Bye!" } ) ));
        public static void main(String[] arg) {
            Test test = new Test();
            test.setVisible(true);
    }

    Hi again,
    yes it works when i set it for single column, but i'd like to use default editor, because column count is not fixed.
    According to documentation: "Sets a default cell editor to be used if no editor has been set in a TableColumn. If no editing is required in a table, or a particular column in a table, uses the isCellEditable method in the TableModel interface to ensure that this JTable will not start an editor in these columns. If editor is null, removes the default editor for this column class."
    So when i call
    column.setCellEditor(null); in TableColumnModelListener columnAdded event. But still it's not working. See sample below (i've changed it to cell renderer coz result is clear on single view, but problem stays same)
    More over problem seems to be with algoritm that decide which class to use. Object takes preference any time. W/o it npe arries.
    Regards
    Adam
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.table.DefaultTableCellRenderer;
    import javax.swing.table.DefaultTableModel;
    public class Test extends JFrame {
        JTable table;
        Test() {
            // Create table model
            table = new JTable();
            table.setModel(new DefaultTableModel(
                new Object[][] {
                    { Boolean.TRUE, Integer.valueOf(10) },
                    { "Hallo!", Boolean.FALSE },
                }, new String[] { "Col1", "Col2" }));
            // Setup frame a little
            setLayout(new BorderLayout());
            setBounds(new Rectangle(300,300,200,100));
            setDefaultCloseOperation(EXIT_ON_CLOSE);
            add(table,BorderLayout.CENTER);
            table.setDefaultRenderer(Object.class,new Renderer(Color.YELLOW));
            table.setDefaultRenderer(String.class,new Renderer(Color.BLUE));
            table.setDefaultRenderer(Boolean.class,new Renderer(Color.RED));
            table.setDefaultRenderer(Integer.class,new Renderer(Color.GREEN));
            // use default renderer in all columns
            table.getColumn(table.getColumnName(0)).setCellRenderer(null);
            table.getColumn(table.getColumnName(0)).setCellRenderer(null);       
        public static void main(String[] arg) {
            Test test = new Test();
            test.setVisible(true);
        class Renderer extends DefaultTableCellRenderer {
            Color color;
            Renderer(Color color) { this.color = color; }
            public Component getTableCellRendererComponent(JTable table, Object value,
                    boolean isSelected, boolean hasFocus, int row, int column) {
                super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
                setBackground(color);
                setToolTipText("Class is "+value.getClass().getName());
                return this;
    }Message was edited by:
    a3cchan

  • ALV grid field editable/non editable at runtime

    Hi All,
    I am working on alv grid using containers. I have to make few cells in grid to editable and few othres to non editable which I did using styles by defining table type lvc_t_styl and updating my main internal table. Now once grid is displayed for first time (using set_table_for_first_display) it has required fields in editable and non editable as required. But now on triggering of data_changed event I have to change the editable cells to non editable and the non editable cells to editable. I tried doing this as same way as I have done before calling set_table_for_first_display method i.e. by  defining table of type lvc_t_styl in data_changed event and modifying my main internal table but this time the editable fields are changed to non editable and again becomes editable. Same problem with non editable cells also. They become editable and again becomes non ediatble of there own. Can anyone suggest any solution.
    <b>Note: Points awarded for helpful answers</b>
    null

    Hi,
    Check this link.I am explaining the steps for this.
    Kindly reward points by clicking the star on the left of reply,if it helps.<a href="https://wiki.sdn.sap.com/wiki/display/Snippets/ALV-Editingandsavingtheeditedvaluesin+Database(OOPS)">Editing OOPS ALV</a>

  • How to set table cell renderer in a specific cell?

    how to set table cell renderer in a specific cell?
    i want set a cell to be a button in renderer!
    how to do?
    any link or document can read>?
    thx!

    Take a look at :
    http://www2.gol.com/users/tame/swing/examples/SwingExamples.html
    It is very interesting, and I think your answer is here.
    Denis

  • Could anyone please let me know how to set a ICC profile with Acrobat dlls using Csharp or VB

    Could anyone please let me know how to set a ICC profile with Acrobat dlls using Csharp or VB

    Cant we even use the dlls in an application?
    In order to automate Acrobat, you need to have Acrobat installed. There is
    nothing you can do with just the DLLs. As was already stated, Acrobat is
    not licensed for use on a server, but regardless of that, it's also
    not technically suitable for server use. You need to find a solution
    outside of Acrobat to solve your problem.
    It also seems that you don't have a good understanding of what is going in
    inside a PDF file. PDF is a very complex file format, and based on
    your questions
    and followup questions, you need to spend a considerable amount of time
    getting familiar with the PDF file format to understand how color works in
    the PDF context. Reader the PDF spec, while paying special attention to the
    section about color. You will find out that if you want to convert the
    color space of a "PDF file", you actually need to convert the color space
    associated with every single object in your PDF file. That is fairly simple
    for vector graphic and text, but when it comes to images, you may have to
    convert the image data. Once you have a good understanding of what it is
    you need to do within the PDF file, then you can start looking for tools
    that allow you to do that. Again, Acrobat and therefore the Acrobat SDK is
    not suitable for this task. If you want to stay with Adobe products take a
    serious look at the PDF Library, which his licensed through Datalogics (
    http://www.datalogics.com/products/pdf/pdflibrary/). As you've mentioned,
    there are other, non-Adobe PDF libraries that you can also use, but this is
    the Acrobat SDK forum, so I won't discuss any of those 3rd party solutions.
    You are wasting your time while looking for a simple solution that does not
    exist.

  • How to set my own gui status when i use selection-screen

    how to set my own gui status when i use selection-screen command
    and
    how to set the names in the application tool bar when function keys are created

    Make sure that you do this in event "AT SELECTION-SCREEN OUTPUT".
    Run Txn ABAPDOCU and check 'DEMO_SEL_SCREEN_STATUS' for sample.
    Also check out following discussion -
    Selection Screen PF-STATUS
    Cheers,
    Sanjeev

  • How to set a cell editable at runtime for jtable

    Hi evry body
    i need to set a cell as editable during runtime and set some value for the cell and make it non editable after setting value
    how can i do it? urgent help appreciated
    regards
    anil

    You could override the methods isCellEditable(...) and setValueAt(...) in your JTable's TableModel to get the effect desired
    // Assuming that each element of the array will be false initially
    boolean[][] valueSet = new boolean[noRows][noCols];
    public boolean isCellEditable(int row, int col) {
      return !valueSet[row][col];
    public void setValueAt(Object obj, int row, int col) {
      super.setValueAt(obj, row, col);
      valueSet[row][col] = true;
    }

  • Setting ComboBox editable/non-editable in JTable

    Hi,
    I had a problem I am having a JTable and one of the column in ComboBox.Basing on a cell value the ComboBox should be editabl.e/Non-editable.
    I used the setValueAt() method of JTable to set the comboBox and also implemented the cellChangeListener.But it did not work while loading the data intially..Plz help me....
    Regards
    Kiran

    Kiran,
    You ignore the words of a goddess at your peril: http://forum.java.sun.com/thread.jsp?forum=57&thread=556061&tstart=15&trange=15
    It sounds like some of the values in your TableModel are JComboBoxes, no? That's seems an odd thing.
    Are you confusing the data with cell editors? What is your data design?

  • Editable / Non editable input field CELL (individually) on ALV dynamically

    Hi again,
    I need more help with an issue.
    I have an ALV table with three columns that is necessary put values into input field cell editors, but these cells should be editable or not depending of business logic. I've got make editable or non in entire ROW LEVEL (method set_read_only_fieldname( 'READ_ONLY' )., but ¿how can I set editable or non at individual cells?
    Any idea to do that?
    Regards
    Edited by: vanbelal on Mar 24, 2010 3:33 PM

    Can you paste any example source code?
    I don't know how can I bind enabled property dynamically to individual CELL, I'm setting properties to whole column.
    lt_columns = lr_column_settings->get_columns( ).
      LOOP AT lt_columns INTO ls_columns.
             if ls_columns-id = 'COLUMN1' or 'COLUMN2' or 'COLUMN3'.
              CREATE OBJECT lr_input_field
                EXPORTING
                  value_fieldname = ls_columns-id.
              ls_columns-r_column->set_cell_editor( lr_input_field ).
    Should I put business logic here? how can I set enabled or not on CELL, at this point I'm processing whole column!!
              lr_input_field->set_enabled( abap_true ).
            endif.
      ENDLOOP.
    Edited by: vanbelal on Mar 24, 2010 4:12 PM

  • How to grey out ( make it non editable ) one line in ALV

    hi i am working on a report which is ALV o/p report .the report has some editable and some non editable fields. based on the value of 1 column field i need to make the full line non editable . how is this possible.
    please guide me.
    Thanks,
    Shiva.
    Edited by: Alvaro Tejada Galindo on Mar 19, 2008 5:07 PM

    Hi,
        Try using the structure LVC_S_STYLE.
    Declare a field of type LVC_S_STYLE in ur internal table,
    Now,in ur new PERFORM chk this code:
    ls_stylerow type LVC_S_STYLE.
    LOOP AT it_itab INTO wa_itab.
    IF wa_itab-field1(this will be the field by which u will validate) =  'X'.
    ls_stylerow-fieldname = 'FIELD2' .   "Field which you want to grey
    ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled.  "set field to disabled
    APPEND ls_stylerow TO wa_itab-field_style.
    MODIFY it_itab FROM wa_itab.
    ENDIF.
    ENDLOOP.

  • How to make Resource Forms fields non editable (OIM)

    Hi all!
    I would like to know if there's any way to make some resource fileds non editable.
    I have one resource which is getting 3 fileds from the oim user profile. When i change the oim user profile, these values are updated on the resource form associated.
    But i want to prevent the situation in which those fields are directly updated on the resouce form.
    I now i can propagate those changes back to oim profile but it will be much appropiate for what we want if we just could prevent anyone from changing those values on the resource form.
    Is it possible to make those fields non editable? How?
    OIM version is 9.1.0.1.
    Thanks in advance.

    Hi, thanks.
    Finally i found this: http://kr.forums.oracle.com/forums/thread.jspa?threadID=591683
    and after setting the fields to required=false, it worked without any errors ("The Resource has not been configured properly" because of the prepopulate adapters)
    Bye

Maybe you are looking for

  • Where can I learn about this?

    In my iTunes preferences I see these options for importing music. Does anyone know of a document that I can read that explains the pros and cons of each type? Thanks! mp3 aiff aac apple lossless wav

  • Object name that already exists on the local directory service

    Hi, We have 3 domain controllers with Windows 2008 R2 all GC, and the forrest and domain level 2008 R2. We replaced one domain controller with a windows server 2012 r2, and kept the name and ip. Every thing seems ok with dcdiag and repadmin, but I ca

  • Text fields populated from lov mapping are not saved to database

    Hi Everyone, I'm having a wierd problem. My requirement is to autopopulate two text fields field 2 and field 3 when a value is selected from lov in field1 and save all the values to database on click of a submit button. Using lov mapping i'm able to

  • How to fix missing entries in the printing preferences of Adobe PDF

    Hi all, we are on Acrobat Pro 8 (8.16) as part of the CS3 Design Standard package. A colleague of mine is missing some of the entries in the printing preferences of the Adobe PDF printer: The Adobe PDF Security dropdown is empty and he can't set the

  • Server Proxy --time out.

    Hi,   How can we process large amount of data in server proxy. Is there any parameter that can make server proxy run in background mode. currently the server proxy is timing out in ECC. Thanks, Viswas.