Disable editing in JTable

Hello,
While building an application i found myself needed to make a doubleclick event.
This is working however, not 100%.
this is becouse the defoult doubleclick action (editing the table) isn't set off.
i looked over the internet but found nothing that helped
yes i even tried:
import javax.swing.table.DefaultTableModel;
class MyTableModel extends DefaultTableModel {
// Insert the instantiator methods I use here
public boolean isCellEditable(int row, int column) {
return false; // Super returns true.
}but it doesn't work.
any and all help would be appriciated.
thanx in advance,
reefclaw
p.s. for those that are interested in my doubleclick function:
TA_Results.addMouseListener(new MouseAdapter()
     public void mouseClicked(MouseEvent e)
//         if (e.getClickCount() == 2)
          if(clickedCount == 0)
              Date now = new Date();
              startTijd = now.getTime();
          if(clickedCount == 1)
              Date now = new Date();
              eindTijd = now.getTime();
          clickedCount ++;
          if(clickedCount == 2 )
              clickedCount = 0;
              if(startTijd - eindTijd < 250)
                  JTable target = (JTable) e.getSource();
                  int row = target.getSelectedRow();
                  int column = target.getSelectedColumn();
                  bekijken();
  });

this you can run:
MAINGUI:
import java.awt.*;
import java.awt.color.*;
import java.awt.event.*;
import java.awt.image.*;
import java.awt.print.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.plaf.*;
import javax.swing.table.*;
import javax.swing.border.TitledBorder;
import java.util.*;
import java.text.SimpleDateFormat;
public class MAINGUI extends JFrame {
    public static void main(String[] args)
        LookAndFeel lf = UIManager.getLookAndFeel();
        try
            UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
        catch(InstantiationException e)
        catch(ClassNotFoundException e)
        catch(UnsupportedLookAndFeelException e)
        catch(IllegalAccessException e)
        Toolkit tk = Toolkit.getDefaultToolkit();
        Dimension screenSize = tk.getScreenSize();
        int screenHeight = screenSize.height;
        int screenWidth = screenSize.width;
        MAINGUI mainframe = new MAINGUI();
        mainframe.setSize(800, 600);
        mainframe.setLocation( (screenWidth - 480) / 2, (screenHeight - 700) / 2);
        mainframe.setTitle("Huurcontracten - main");
        mainframe.setVisible(true);
    public MAINGUI() {
        try {
            jbInit();
        } catch (Exception ex) {
            ex.printStackTrace();
    private void jbInit() throws Exception {
        this.getContentPane().setLayout(null);
        this.setBounds(0, 0, 800, 600);
        TA_Results.setEnabled(false);
        TA_Results.setAutoscrolls(false);
        TA_Results.setBorder(BorderFactory.createLoweredBevelBorder());
        TA_Results.setBounds(new Rectangle(20, 44, 760, 472));
        TA_Results.getModel().addTableModelListener(TA_Results);
        TA_Results.removeEditor();
        this.getContentPane().add(TA_Results);
        kolommen[0] = "ContractNummer";
        kolommen[1] = "FilliaalNummer";
        kolommen[2] = "LandNaam";
        kolommen[3] = "Plaats";
        kolommen[4] = "StraatNaam";
        kolommen[5] = "IngangsDatum";
        kolommen[6] = "EindDatum";
        kolommen[7] = "OpzegDatum";
        comboBox[7] = "Alles";
        comboBox[1] = "LandNaam";
        comboBox[2] = "ContractNummer";
        comboBox[3] = "IngangsDatum";
        comboBox[4] = "EindDatum";
        comboBox[5] = "Plaats";
        comboBox[6] = "FilliaalNummer";
        comboBox[0] = "Maanden voor afloop";
        S_C_Order[1] = "LandNaam";
        S_C_Order[0] = "ContractNummer";
        S_C_Order[2] = "IngangsDatum";
        S_C_Order[3] = "EindDatum";
        S_C_Order[4] = "Plaats";
        S_C_Order[5] = "FilliaalNummer";
        S_C_Order[6] = "Apple";
        S_C_Order[7] = "Tomaat";
        zoeken();
TA_Results.addMouseListener(new MouseAdapter()
     public void mouseClicked(MouseEvent e)
          if(clickedCount == 0)
              Date now = new Date();
              startTijd = now.getTime();
          if(clickedCount == 1)
              Date now = new Date();
              eindTijd = now.getTime();
          clickedCount ++;
          if(clickedCount == 2 )
              clickedCount = 0;
              if(startTijd - eindTijd < 400)
                  JTable target = (JTable) e.getSource();
                  int row = target.getSelectedRow();
                  int column = target.getSelectedColumn();
                  System.out.println("Dubbleclicked");
    JTable TA_Results = new JTable(new MyTableModel());
    String[] kolommen = new String[8];
    String[] comboBox = new String[8];
    String[] S_C_Order = new String[8];
    int clickedCount = 0;
    long startTijd;
    long eindTijd;
    private void zoeken()
        String[] results = new String[kolommen.length];
        Object[] kolomshit = kolommen;
        Object[] comboBox2 = comboBox;
        Object[] row3 = S_C_Order;
            Object[][] rowData = new Object[3][kolommen.length];
            rowData[0] = kolomshit;
            rowData[1] = comboBox2;
            rowData[2] = row3;
            remakeTable(rowData, kolommen);
    private void remakeTable(Object[][] rowData, Object[] columnNames)
        this.getContentPane().remove(TA_Results);
        TA_Results = new JTable(rowData, columnNames);
        TA_Results.setBorder(BorderFactory.createLoweredBevelBorder());
        TA_Results.setBounds(new Rectangle(20, 44, 760, 472));
        this.getContentPane().add(TA_Results);
        TA_Results.revalidate();
}MyTableModel:
import javax.swing.table.DefaultTableModel;
class MyTableModel extends DefaultTableModel {
// Insert the instantiator methods I use here
public boolean isCellEditable(int row, int column) {
return false; // Super returns true.
}

Similar Messages

  • Disable editing of jtable

    plz help me how to disable the editing of a jtable

    You create a class which implements an AbstractTableModel and implement this method:
    class MyTableModel implements AbstractTableModel {
         public boolean isCellEditable(int row, int col) {
              return false;
    }And then:
    yourTable.setTableModel(new MyTableModel());Hope this is helpful

  • JTable- how can i disable editing

    hi
    could anyone please lemme know if there is any way to disable editing in a jtable. i tried disabling it, but ;) hehe, well that diables selecting a row also then. One more thing, is there any simpler method to add scroll bars to a panel or frame without having to place the panel itself into a jscrlolpane, 'cos im having too many other problems when i make a nested panel. if anyone has a solution , please do tell me
    thankyou

    u can do it when u use model for the table.
    use AbstractTable model and over ride isCellEditable method returning false..
    Check sun demo examples how to use AbstractTableModel...
    very simple right....hihihi..

  • Disable Editing in GL a/c in VKOA

    Hi experts,
    My PRD Server in transaction code vkoa have privilege to edit GL accounts.
    but client setting is disable.
    How can i disable edit GL accounts in VKOA.
    Regards,

    Actually the settings will be controlled by BASIS team
    It is not suggested to keep the VKOA settings in EDITABLE mode, which will impact a lot if something goes wrong.
    Ask your BASIS team to disable, if chages required do it through DEV - QAS - PROD
    Thanks

  • Disable EDIT AUTHORIZATIONS in PI 7.1

    Hi all,
    In PI 7.1 we can define and edit authorizations for access to objects in the Enterprise Services Repository.
    Is there any way that i can disable EDIT AUTHORIZATIONS  option of the context menu at the Software component level.
    regards
    Gangaprasad

    Sebastian,
    I found these Actions in Identity-Managements, where I can do settings for a virtual Provider.
         jms.default          topic.all.all
         jms.default          temp.topic.all.all
         jms.default          administration.all.all     
         jms.default          queue.all.all
         jms.default          temp.queue.all.all
    So I will create a new Virtual Provider "myProvider" assing my JMS-Queue to this provider and play around with the parameter settings "jms.myProvider" and assign these actions to a test user.
    Furthermore I found these actions in Identy Management. I think in the first step I won't change anything at these parameters.
         jms_provider          topic.all.all
         jms_provider          temp.topic.all.all
         jms_provider          administration.all.all
         jms_provider          queue.all.all
         jms_provider          temp.queue.all.all
    I let you know the result of my tests.
    regards
    Barbara

  • How to disable edit link in interactive report

    Hi,
    How to disable edit(e3.gif image) link interactive report.
    Thanks,
    nr

    Hi Jari,
    Apex Version:3.2
    I created on Interactive report on emp table I have created edit link on empno using Icon5 image.
    Report Attributes>Column Attributes>Column Link.
    I can Hide the Icon5 using following script but I need to disable only. I did not get any disable() method in Jquery.
    Region Id:R812581842900385833
    $(document).ready(function() {
    var viewOnly=document.getElementById('P1_ITEM1').value;
    if(viewOnly == "0")
    $("#R812581842900385833 img").hide();
    thanks,
    Nr
    Edited by: pnr on Mar 13, 2012 6:09 AM

  • Disable editing PDF before email to others

    How can I sign a PDF document or disable editing feature of PDF document before sending to my customer?

    With Reader...  you can't. You'd need Acrobat or CreatePDF to restrict editing.

  • Edit a JTable cell, click save button, value isn't stored in JTable

    I'm editing a JTable cell, just using default editor provided by JTable
    I click a save button elsewhere in my GUI
    The value typed into the cell so far isn't stored in the TableModel yet and so doesn't get saved.
    How can I make sure the value gets stored in the JTable in the above scenario when the JButton is pressed but before saving.
    Preferably I'd like the code with the JButton not to have to know about the JTable at all.
    Cheers,
    D

    I the forums 100s of times.Many thanks. If they had a decent search on this forum I might have found it as I did try.
    Come to think of it - Sun have completely fcukd up this forum.

  • ADF DI : Need to disable edit on a column in excel spread sheet

    Hi,
    I need to make a column disable for edit in ADF table in excel.I tried making read only property to true but , user can still edit that column but will get update failed error.I want my column to be completely disabled even for editing.Is there any way to disable edit on the column and makes it grey out??
    Thanks in Advance,
    Alekhya

    I have enabled worksheet protection, with only the Column i need to be
    made read only. Accodring to the ADF DI Dev guide, "The end user can insert a
    full row or column. However, once inserted, they cannot be deleted.". But
    even full row insert shows up disabled. Its not allowing me to insert a new row at all.

  • How to Disable edit option in Logon pad

    Hi,
    How to disable edit option in logon pad
    thanks

    Actually if you are looking to disable the "Edit" option so end users cannot change or modify the existing  Logon Pad options systems, you can.
    What version are you using for SAP GUI?
    7.10 has icons to the right which allow changes. (New, edit, etc)
    7.20 has icons across the toolbar at the top. (pencil, paper, trashcan)
    For both versions, Navigate to C:\Program Files\SAP\FrontEnd\SAPgui (Default location)
    In there you will find 2 executeables:
    saplgpad.exe
    saplogon.exe
    If you run the saplogon.exe it will allow edit, delete and modify
    If you run the saplgpad.exe:
    On the 7.10 version the buttons are gone.
    On the 7.20 version, the buttons are grayed out.
    Hope this is what you are looking for.
    Regards,
    Zecher

  • Disable editing of column in advanceddatagrid

    I'm having problems disabling editing in the advanced
    datagrid The code for the column is below. It is using an
    itemRender. I wouldn't think this would be the problem, but perhaps
    I need to disable it at the item renderer level and not the
    datagrid. Any ideas?
    <mx:AdvancedDataGridColumn width="10" id="DGColumn_X"
    editable="false" visible="true" sortable="false" headerText="X"
    dataField="hasPermission" itemRenderer="mx.controls.CheckBox"
    />

    It looks like the class you are losing doesn't support what you are trying to do; you can only toggle whether columns are sortable on a global basis. At least, that's my impression after looking at the first API which Google coughed up for that class.
    I guess you could turn the sorting on/off depending upon which column is clicked, though I'm not sure how well that will work.
    The columnMoved should be called when columns are moved from one index to another. The event will have a 'from' and a 'to' index on it.
    I think you may want to try using a mouse listener on the TableHeader, figure out the column that we clicked on, and then act accordingly:
            JTableHeader tableHeader = table.getTableHeader();
            tableHeader.addMouseListener(new MouseAdapter() {
                public void mousePressed(MouseEvent event) {
                    JTableHeader header = (JTableHeader) (event.getSource());
                    int index = header.columnAtPoint(event.getPoint());
                    // do stuff based on index
            });You may want to play with that, as I'm not sure how it will work with that class, particularly as I assume it toggles sorting through ascending, descending, no sorting.

  • How can I disable edit on a UITextField after editing once

    I have a UITextfield and I want to disable editing after the phrase is entered. Basically once I press done on the keyboard I want to disable editing this field again.
    Can anyone give me suggestions on how I can do this?
    thanks,
    Max

    UITextField_Name.enabled = FALSE;

  • Disable editing of part of table

    Hello,
    i need to disable editing on some rows in table. Also i need to change style of some rows, is it possible in webdynpro (some sample code?) or i have to use PDK?
    thanks
    JJ

    Jiri,
    Let us assume your attribute CHAR1 name is Flag. So:
    1. Right under the node with attribute Flag create sub-node with cardinality 1..1, singleton=flase, name it UISettings
    2. In this sub-node create boolean attribute EditorEnabled
    3. Mark EditorEnabled attribute readOnly=true, calculated=true
    4. Switch to source editor, and write the following for method getUISettingsEditorEnabled:
    return "X".equalsIgnoreCase(element.getParentElement().getAttribute("Flag");
    5. Bind "enabled" properties of cell renderers to EditorEnabled attribute.
    Make sure to rename "Flag" in code to actuall property name from BAPI!
    Valery Silaev
    EPAM Systems
    http://www.NetWeaverTeam.com

  • Disable EDIT in Maintenance View - How ?

    I coded this function in PBO.
    There are 2 screens.
    0100 - all records listing
    0200 - double click on the record in 0100 screen and then, go into specific record details.
    i allow modification in  this screen.
    MODULE disable_inputs OUTPUT.
    If SY-DYNNR eq '0100'.
       LOOP AT SCREEN.
          screen-input = '0'.
          screen-active = '0'.
        ENDIF.
       ENDLOOP.
       modify screen.
    endif.
    ENDMODULE.                 " disable_inputs  OUTPUT
    Can somebody enlighten me on how to disable edit in the first screen ?
    Thanks.

    Try to change this way
    MODULE disable_inputs OUTPUT.
    If SY-DYNNR eq '0100'.
    LOOP AT SCREEN.
    screen-input = '0'.
    screen-active = '0'.
    modify screen.   " <<<<
    ENDLOOP.
    endif.
    ENDMODULE.

  • Not editable in JTable..

    I want to make not-editable cell in JTable.
    so I was searching for source code and posts in forums..
    I found perfect source code..
    but I don't know the difference between my source code and perfect code...
    could you explain me the difference two of sources
    Especially, isCellEditabel function....
    In advance thank you
    perfect code
    Test()
    JTable myTable = new JTable(data, headers)
    @Override
    public boolean isCellEditable(int row, int column)
    return false;
    add(new JScrollPane(myTable));
    my source code
    field_vc.add("Hotel Name");
    field_vc.add("City");
    field_vc.add("Maximum");
    field_vc.add("Smoking");
    field_vc.add("Price per Night");
    field_vc.add("Date");
    field_vc.add("Customer ID");
    field_vc.add("Select");
    view_jt = new JTable(data_vc , field_vc)
    @Override
    public boolean isCellEditable(int row, int column)
         return false;
    view_jsp = new JScrollPane(view_jt);
    perfect source code is not editable in JTable
    But my source code is editable in JTable
    Plz help me
    Edited by: KIMJINHO on Feb 22, 2008 8:33 AM

    But my source code is editable in JTableprove it by posting a demo program that we can copy/paste/compile/run and double click a cell to edit

Maybe you are looking for