Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: How do i make My Jbutton Edit selected Row in Jtable

  1. #1
    Junior Member
    Join Date
    Jan 2013
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How do i make My Jbutton Edit selected Row in Jtable

    what I want:
    When I select a row I would like to be able to edit/update the information within it when I click my button.


    My table
    String columns[] = { "First Name", "Last Name", "Phone Number", "Email" };
     
    		tableModel = new DefaultTableModel(0, 4) {
    			@Override
    			public boolean isCellEditable(int row, int column) {
    				return false;
    			}
    		};
     
    		tableModel.setColumnIdentifiers(columns);


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: How do i make My Jbutton Edit selected Row in Jtable

    1) have the isCellEditable method return true for the cells which are editable 2) override the setValueAt method to actually set the value the user entered. If you still have problems, post an SSCCE

  3. #3
    Junior Member
    Join Date
    Jan 2013
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How do i make My Jbutton Edit selected Row in Jtable

    Quote Originally Posted by copeg View Post
    1) have the isCellEditable method return true for the cells which are editable 2) override the setValueAt method to actually set the value the user entered. If you still have problems, post an SSCCE

    i'm not sure how to do that i've look everywhere, but no luck. i'm not very experience in using j table.


    This is what I have for my edit button
    Editbutton.addActionListener(new ActionListener() {
    																				                                                                                                     public void actionPerformed(ActionEvent e) {
     
    																					                                                                                              boolean isCellEditable = true;
    																					                                                                        table.setValueAt(aValue, row, column);
     
       }
    																			                                                                                                                  });

Similar Threads

  1. Replies: 21
    Last Post: November 27th, 2012, 10:58 PM
  2. JTable Row Color
    By ellias2007 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: January 23rd, 2012, 01:29 PM
  3. JTable Row Color
    By aussiemcgr in forum Java Theory & Questions
    Replies: 2
    Last Post: October 8th, 2010, 03:59 PM