Making cell non editable on mouseevent or a data in coumn

hi friends
i have a Jtable which is having a Productprice column which is editable by default
when the Jtable is created from my custom model.
and there is a boolean(check box)-LockPrice column and quoteDate column
i want that when the value in the LockPrice of a particular row is set to true by mouse click or if the QuoteDate is entered then the value in the productprice cell of that row shud not be editable.
any ideas wud be great help
jags

Simply make a sub class of DefaultTableModel in the following style and over ride the isCellEditable() method and pass class "TempDefaultTableModel " as a model of the table. Method inside working you can define in your own style.
class TempDefaultTableModel extends DefaultTableModel{
public TempDefaultTableModel(Object[] columnNames, int rows){
super(columnNames, rows);
public boolean isCellEditable(int row, int column) {
return false;
}

Similar Messages

  • JTable cannot make cell non-editable

    I have create a JTable using the DefaultTablemodel. I want to make the cells non editable. I have overwritten the method isCellEditable with that shown below but when I double click any cell it still let me edit the cell. Someone please show me what is wrong.
    public boolean isCellEditable(int cellrow, int cellcol)
    return(false);
    // if (cellcol == 0)
    // return(false);
    // else
    // return(true);
    Regards
    pslloo

    Look at the tutorial! This sample works.
    Hope this help.
    import javax.swing.JTable;
    import javax.swing.table.AbstractTableModel;
    import javax.swing.JScrollPane;
    import javax.swing.JFrame;
    import javax.swing.SwingUtilities;
    import javax.swing.JOptionPane;
    import java.awt.*;
    import java.awt.event.*;
    public class TableDemo extends JFrame {
        private boolean DEBUG = true;
        public TableDemo() {
            super("TableDemo");
            MyTableModel myModel = new MyTableModel();
            JTable table = new JTable(myModel);
            table.setPreferredScrollableViewportSize(new Dimension(500, 70));
            //Create the scroll pane and add the table to it.
            JScrollPane scrollPane = new JScrollPane(table);
            //Add the scroll pane to this window.
            getContentPane().add(scrollPane, BorderLayout.CENTER);
            addWindowListener(new WindowAdapter() {
                public void windowClosing(WindowEvent e) {
                    System.exit(0);
        class MyTableModel extends AbstractTableModel {
            final String[] columnNames = {"First Name",
                                          "Last Name",
                                          "Sport",
                                          "# of Years",
                                          "Vegetarian",
                                          "essai"};
            final Object[][] data = {
                {"Mary", "Campione",
                 "Snowboarding", new Integer(5), new Boolean(false), new Integer(3)},
                {"Alison", "Huml",
                 "Rowing", new Integer(3), new Boolean(true), new Integer(3)},
                {"Kathy", "Walrath",
                 "Chasing toddlers", new Integer(2), new Boolean(false), new Integer(3)},
                {"Sharon", "Zakhour",
                 "Speed reading", new Integer(20), new Boolean(true), new Integer(3)},
                {"Angela", "Lih",
                 "Teaching high school", new Integer(4), new Boolean(false), new Integer(3)}
            public int getColumnCount() {
                return columnNames.length;
            public int getRowCount() {
                return data.length;
            public String getColumnName(int col) {
                return columnNames[col];
            public Object getValueAt(int row, int col) {
                return data[row][col];
             * JTable uses this method to determine the default renderer/
             * editor for each cell.  If we didn't implement this method,
             * then the last column would contain text ("true"/"false"),
             * rather than a check box.
            public Class getColumnClass(int c) {
                return getValueAt(0, c).getClass();
             * Don't need to implement this method unless your table's
             * editable.
            public boolean isCellEditable(int row, int col) {
                //Note that the data/cell address is constant,
                //no matter where the cell appears onscreen.
                if (col < 2) {
                    return false;
                } else {
                    return true;
             * Don't need to implement this method unless your table's
             * data can change.
            public void setValueAt(Object value, int row, int col) {
                if (DEBUG) {
                    System.out.println("Setting value at " + row + "," + col
                                       + " to " + value
                                       + " (an instance of "
                                       + value.getClass() + ")");
                if (data[0][col] instanceof Integer                       
                        && !(value instanceof Integer)) {                 
                    //With JFC/Swing 1.1 and JDK 1.2, we need to create   
                    //an Integer from the value; otherwise, the column    
                    //switches to contain Strings.  Starting with v 1.3,  
                    //the table automatically converts value to an Integer,
                    //so you only need the code in the 'else' part of this
                    //'if' block.                                         
                    //XXX: See TableEditDemo.java for a better solution!!!
                    try {
                        data[row][col] = new Integer(value.toString());
                        fireTableCellUpdated(row, col);
                    } catch (NumberFormatException e) {
                        JOptionPane.showMessageDialog(TableDemo.this,
                            "The \"" + getColumnName(col)
                            + "\" column accepts only integer values.");
                } else {
                    data[row][col] = value;
                    fireTableCellUpdated(row, col);
                if (DEBUG) {
                    System.out.println("New value of data:");
                    printDebugData();
            private void printDebugData() {
                int numRows = getRowCount();
                int numCols = getColumnCount();
                for (int i=0; i < numRows; i++) {
                    System.out.print("    row " + i + ":");
                    for (int j=0; j < numCols; j++) {
                        System.out.print("  " + data[i][j]);
                    System.out.println();
                System.out.println("--------------------------");
        public static void main(String[] args) {
            TableDemo frame = new TableDemo();
            frame.pack();
            frame.setVisible(true);
    [\code]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Making cell non editabale (of dynamic table) in alv

    Hi,
    I am working on a editable alv with a dynamic table <itab> .This table gets populated during runtime.Now I want to make few cell of this table not editabale (only few cell not the full columns) I knwo that the procedure is to
    declare my outtab like
    TYPES: BEGIN OF gs_outtab.
    TYPES: celltab TYPE lvc_t_styl.        "field to switch editability
            INCLUDE TYPE /npu/edmt_aa_eac.
    TYPES: END OF gs_outtab.
    and in the celltab i pass the information of cells which will be non editable...But the problem is as my outtab is a dynamic table I cannot INCLUDE IT IN ANOTHER types.
    Please help me how to do it???? Or is there any other way of doing it???

    Hi Priya
    Add the field of type lvc_t_styl while creating the field catalog.
    Now
    DATA lo_table TYPE REF TO data.
      cl_alv_table_create=>create_dynamic_table(
        EXPORTING
          it_fieldcatalog = lt_fieldcat  "the field catalog table
        IMPORTING
          ep_table = lo_table ). "the reference to the table gt_outtab with the style tab
    FIELD-SYMBOLS <tab> TYPE ANY TABLE.
    ASSIGN lo_table->* TO <tab> .
    Now you can fill your <tab>.
    Pushpraj

  • PO order confirmation maked field Non editable

    Dear All,
    We had just shifted to ECC 6.0. When we create the PO and after that enter the order acknowledegement in confirmation Tab the field like PR, Contract Numebr on line item gets grayed out meand non editable. WHile I had tested the same thing in 4.6C and found that in this version although we enter the Order Acknowledegement in COnfiramtion tab and save the PO the field like PR, Contact number at line item does not get garyed out means it is available for editing also.
    Please let me know is there is any settings in Configuration to be done. Or is this is STandard FUnctionality of ECC 6.0. Are there any notes or FAQ notes available on this which states this functionality.
    Please reply as earliest as possible.
    Thanks
    Shashi

    Hi ,
    Spro  - Materials Management - Purchasing - Define Screen Layout at document level - ME21 - Create Purchase order - Field Selection key
    Thanks & Regards,
    Senthil.

  • Non-editable mode for customer master data in VA01 and VA02

    Hi all,
    User requirement is they don't want to give permission to change customer master data (payer & ship-to ). I didn't find any user exit to do screen non-editable.
    Can any one help me in this..
    Regards,
    Sudhakara

    Hi Sudhakar Reddy,
    For this transaction code user exits available :
    SDTRM001  Reschedule schedule lines without a new ATP check
    V45A0001  Determine alternative materials for product selection
    V45A0002  Predefine sold-to party in sales document
    V45A0003  Collector for customer function modulpool MV45A
    V45A0004  Copy packing proposal
    V45E0001  Update the purchase order from the sales order
    V45E0002  Data transfer in procurement elements (PRreq., assembly
    V45L0001  SD component supplier processing (customer enhancements
    V45P0001  SD customer function for cross-company code sales
    V45S0001  Update sales document from configuration
    V45S0003  MRP-relevance for incomplete configuration
    V45S0004  Effectivity type in sales order
    V45W0001  SD Service Management: Forward Contract Data to Item
    V46H0001  SD Customer functions for resource-related billing
    V60F0001  SD Billing plan (customer enhancement) diff. to billing
    For ur requirement whixh exit is suitable plz check it out. other wise put breakpoint for userexit and check it out.
    Rewards somr points.
    Rgds,
    P.Nag

  • Non-editable JTable cells?

    Is there any way to make all the cells in a JTable non-editable? In the API I see the isEditable method, but no setEditable method. Any suggestions?

    You have to set it in the TableModel.
    TableModel model = new AbstractTableModel()
    public int getRowCount()
    return 10;
    public int getColumnCount()
    return 5;
    public Object getValueAt(int row, int column)
    return "( "+row+","+column+" )";
    public boolean isCellEditable(int row,int column)
    return false;
    The one given above is a sample to show you how to set a cell non-editable on the cell. You have to customize it for your table model.
    Thanks,
    Kalyan

  • CS6 - add non-editable region inside editable template region?

    I have the following in a template:
        <div class="main-content">
    <!-- TemplateBeginEditable name="main-content" -->
          <div class="content p7ehc-1"> <!-- from projectseven.com; don't change -->
            <h1 class="page-topper">Enter topic here</h1>
            <p>Enter content here</p>
          </div>
        <!-- TemplateEndEditable -->
       </div>
    Right now everything in main-content is editable. I'd like to add "Page last revised - " at the bottom of the page which would be non-editable. An editable date would follow.
    I already have a number of pages with content so any solution should not destroy the content of those pages. (If needed I'd be willing to manually add "Page last revised -" to each of those pages. However, I'd want this to be automatically added for any new pages that were based on the template.)
    I have tried putting "Page last revised -" in another div and making it non-editable but this creates other layout problems. I currently don't want to explore this option further.
    Thanks for any suggestions.

    You could always drop a server-side include or even a Dreamweaver Library item into that editable region (the latter method is a poor second choice, though). Is that a reasonable solution?
    Failing that, manually adding Ben's code both to the existing child pages and the current template will definitely place that code into newly created child pages. The beauty of his suggestion is that it's self maintaining, meaning that the code will always show the proper date on each page.

  • How to design ALV GRID with a column in NON-editable Mode and has F4 Help?

    Hello Friends,
      How to code for ALV GRID, which has a column that takes value only from F4 Help and does not accept any other user input?
    Can I have that column non-editable and yet has F4 Help?
    Please help ASAP.

    Hi,
      The examples in the mentioned programs do not suffice my problem.In these programs. They have made the cell non-editable but you cant even input value through F4 Help.
    I want to make a cell non-editable (which can be changed only through F4 Help), which do not accept user input.

  • How to make Date fields Editable or Non-Editable based on Call Staus

    Hi,
    We are using CRM2007 Web GUI for Service call creation. We are using date profile to populate the dates. Here my requirement is if call status is 'Call created' then some set of date fields to be appeared in display mode(Non Editable) and some set of date fields to be appeared in change mode(Editable). How to achieve this. Kindly suggest me.
    Regards,
    Steve

    Hello,
    Kindly check the following thread which is giving many solutions for your requirement:
    Re: how to make field non-editable (display mode)
    Kind regards,
    Nicolas Busson.

  • Make editable and non-editable some cells in ALV OO

    Hello Experts, i have a table like this:
    KUNNR DATE VALUE1
    And a search button that obtains data, and then display the information in the ALV, like this
    KUNNR DATE       VALUE1
    1000     1.1.2009    A
    1001     2.2.2009    B
    Also i have a button that append  an empty line to the ALV
    I want that the kunnr retrieved in the search be non-editable
    But i want that the kunnr cell in the appended line be editable
    How can i do this?
    THANKS!
    Edited by: Mariano Gallicchio on Jun 26, 2009 3:45 PM

    when (sy-ucomm for New row)
    LOOP AT <fcat> into <workarea>
       CASE <workarea>-fieldname.
          WHEN 'KUNNR'.
    * Making a column as Editable
            <workarea>-edit = 'X'.
        ENDCASE.
      ENDLOOP.
    Kanagaraja L
    Edited by: Kanagaraja  Lokanathan on Jun 26, 2009 4:01 PM
    Edited by: Kanagaraja  Lokanathan on Jun 26, 2009 4:02 PM

  • Making particular rows as non editable before displaying the TABLE

    Hi everyone,
                               I would like to know how to make a particular rows as non editable in UI element "TABLE" before it is displayed . The scenario is :
    On entering the Personnel number, I am getting family dependants in the table. Then, I am selecting any of the family members on some condition and saving each member with the request.
    Next time when i enter the same personnel number, I would like to show the table with already saved request for the family members rows as non editable & other members row as editable.????
    Please provide a feasible solution.

    Hi Pradeep,
    follow as per suggested. if not work use cell variants concept. it will work.
    Please check this wiki...
    http://wiki.sdn.sap.com/wiki/display/WDABAP/WebDynproforABAPCellVariants
    Cheers,
    Kris.

  • Making table cells non-focusable

    I have a JTable in which some of the cells should never receive the keyboard focus. I want the TAB key to skip over these non-editable cells, but I'm having trouble. I've tried using a cell renderer where getTableCellRendererComponent calls setFocusable(false). This has no effect at all. How can I get the focus to skip forward to the next editable cell when I press the TAB key?

    some of the cells should never receive the keyboard focus
    I want the TAB key to skip over these non-editable cellsThese a two separate and different requirements. Using the Tab key does not prevent the user from clicking on the cell. But if this is the real requirement then check out this posting for one solution:
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=657819

  • Making a particular Column Non Editable

    Hi all,
    My question is that ... i ahve created a jtable in default table model ........
    And i have maked a column as a row header .. by using table column model..And the problem is that the column which has been made as a rowheader is in editable mode .. i want to make it non editable .. it is possible or not
    here is my code
    TableColumnModel Tc1 = new DefaultTableColumnModel() {
                    boolean first = true;
                    public void addColumn(TableColumn tc) {
                      // Drop the first column . . . that'll be the row header
                      if (first) { first = false; return; }
                      tc.setMinWidth(110);
                     super.addColumn(tc);
              TableColumnModel rowHeader = new DefaultTableColumnModel() {
                    boolean first = true;
                    public void addColumn(TableColumn tc) {
                      if (first) {
                        tc.setMaxWidth(36);
                        super.addColumn(tc);
                        first = false;
              model1= new DefaultTableModel(100,10);
              tb=new JTable(model1,Tc1);
              tb.setRowHeight(20);
              tb.createDefaultColumnsFromModel();
              tb.setPreferredScrollableViewportSize(new Dimension(770,350));
              JTable headerColumn1 = new JTable(model1, rowHeader);
              headerColumn1.createDefaultColumnsFromModel();
               headerColumn1.setCellSelectionEnabled(false);
              headerColumn1.setRowHeight(20);
              headerColumn1.setBackground((Color)UIManager.get("TableHeader.background"));
              tb.setSelectionModel(headerColumn1.getSelectionModel());
              tb.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
             headerColumn1.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
             headerColumn1.setSelectionBackground(Color.lightGray);
             headerColumn1.setColumnSelectionAllowed(false);
             JViewport jv1 = new JViewport();
             jv1.setView(headerColumn1);
             jv1.setPreferredSize(headerColumn1.getMaximumSize());
              jsp = new JScrollPane(tb);
              jsp.setRowHeader(jv1);

    override isCellEditable(int row, int column) as:
    public boolean isCellEditable(int row, int column){
          return ( column != nonEditableColumnIndex ? true : false);
    }cheers
    DB

  • Making title as non editable for Mail

    Hi,
    I am sending mail by using FM 'SO_DYNP_OBJECT_SEND'. My need is to make title of the mail as non editable in dialog screen.
    How can I do this?
    Thanks,
    Suchender

    Hi Suchender,
             I tried it passing OBJECT_HD_CHANGE-OBJDES = 'test'
                                    OBJECT_HD_CHANGE-PRTCT = ' ',
                                      EDIT_TITLE-FLAG = ' '.
              But i was not successful to display as non editable.
              Please let me know if you got the answer.
    Thanks,
    Dinesh

  • Making a header field as non editable while creating PO using ME21n

    Hi Friends,
    Could any one tell me the BADI or screen exit to make a header field (for eg: EKGRP - Purchasing Group) as non editable after giving default value to it?
    Thanks in advance,
    Ram

    Hi Ram,
    goto se80 t-code and give 'ME' package, and now see the enhancements available.
    You l get a relavent one, if you go through all those.
    Hope this helps
    Regards,
    Sujatha

Maybe you are looking for