Results 1 to 3 of 3
  1. #1
    iNko is offline Member
    Join Date
    Dec 2012
    Posts
    55
    Rep Power
    0

    Default How do i make jTable not resizable and so i cant change values in it?

    Hello, i got a code that gets all the data i need from database and puts it in a jtable:

    Java Code:
    private void EsamiPranesimaiTableMethod(){
    
    try{
    
     String sql = "BIG SQL CODE, THAT TAKES ALL THE DATA I NEED";
     pst = conn.prepareStatement(sql);
     rs = pst.executeQuery(sql);
     Table_EsamiPranesimai.setModel(DbUtils.resultSetToTableModel(rs));
    
        } 
        catch (Exception e){
            JOptionPane.showMessageDialog(null, e);
        }
    }
    So yeah, this code displays data from database into my jtable, heres a pic:


    Heres the problem:


    As you can see, i can double click on any value, and then type anything in there.. i want it to be 'un-editable', how do i do that?

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,386
    Blog Entries
    7
    Rep Power
    20

    Default Re: How do i make jTable not resizable and so i cant change values in it?

    A JTable uses a TableModel that manages the data for the JTable. It's the model that decides whether or not the data is editable.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,184
    Rep Power
    19

    Default Re: How do i make jTable not resizable and so i cant change values in it?

    Moved from New to Java.

    Have you gone through the tutorial linked from the JTable API?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Replies: 11
    Last Post: 11-14-2012, 07:48 PM
  2. Why does the values of JTable rows change?
    By reevosoft in forum AWT / Swing
    Replies: 6
    Last Post: 11-07-2012, 01:40 PM
  3. Values change when they're not supposed to
    By m00nchile in forum New To Java
    Replies: 7
    Last Post: 05-15-2010, 04:16 PM
  4. have an eventlistener change values
    By klmdb in forum New To Java
    Replies: 1
    Last Post: 03-20-2009, 12:42 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •