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 2 of 2

Thread: Why is the value of the selected row stays the same in textfield?

  1. #1
    Junior Member
    Join Date
    Dec 2013
    Posts
    24
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default Why is the value of the selected row stays the same in textfield?

    try {
    System.out.println("1");
    int row = jTable4.getSelectedRow();
    System.out.println("row");
    String str = (jTable4.getModel().getValueAt(row, 0).toString());
    System.out.println("model");
    String query = "select idclient from client where idclient = '"+str+"' ";
    System.out.println("str");
    System.out.println("2");
    rs =(ResultSet) pst.executeQuery();
    System.out.println("3");
    if(rs.next()){
    String str4 = rs.getString("idclient");
    System.out.println("4");
    jTextField1.setText(str4);
    System.out.println("5");
    }
    } catch (SQLException e) {
    Logger.getLogger(Display.class.getName()).log(Leve l.SEVERE, null, e);
    }

    I select the first row the value is 0
    I select the second the value is still 0


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    4,524
    My Mood
    Mellow
    Thanks
    156
    Thanked 615 Times in 602 Posts

    Default Re: Why is the value of the selected row stays the same in textfield?

    Please post your code correctly.

Similar Threads

  1. Replies: 2
    Last Post: December 12th, 2013, 11:01 PM
  2. Help with checking to see which menuItem has been selected
    By jason3460 in forum What's Wrong With My Code?
    Replies: 29
    Last Post: December 6th, 2013, 02:17 PM
  3. How do i make My Jbutton Edit selected Row in Jtable
    By legend101z in forum What's Wrong With My Code?
    Replies: 2
    Last Post: April 7th, 2013, 04:59 PM
  4. Getting the Selected Value in JComboBox
    By aStudentofJava in forum AWT / Java Swing
    Replies: 2
    Last Post: March 9th, 2012, 09:35 AM
  5. SWT browser stays on top of other components [WinOS]
    By Nesh108 in forum Java Theory & Questions
    Replies: 5
    Last Post: December 3rd, 2011, 09:31 AM

Tags for this Thread