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: Problem with columns in JTable and JScrollPane - equal values in two columns for every row in a Jtable

  1. #1
    Junior Member
    Join Date
    Feb 2014
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Problem with columns in JTable and JScrollPane - equal values in two columns for every row in a Jtable

    Hi,

    I have a JScrollPane with two coulmns. In the first column I have an image pane JTable, and in the second a list with names of sections. This second column I try to divide in two columns, one (the second column) to display the names of the sections (each row contains one name), and in the other column (the third) I want to show some values for every section in the row respectively. But, instead of displaying the desired values in the third column, I get the same names of the sections as in the second column. Here is a part of the code I have:


    private Vector<Section> daten = new Vector<Section>(0); //These are the values for the first column in the Jscroll
    private String[] header = {"Section","calcGYR"}; // These are the values for the second and third column (in this case the header for the both columns

    public TrafficObserveModel(Vector<Section> daten) {

    setData(daten);

    }

    public Object getValueAt(int row, int col) {

    return ((Section)daten.elementAt(row));

    }

    public void setData(Vector<Section> daten){

    this.daten = daten;

    fireTableDataChanged();
    }

    public Vector<Section> getData() {
    return daten;
    }

    But I don't know how to modify the methods in order to render the desired integer values in the third column. Can anybody help me please.

    Thank you very much in advance.


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Problem with columns in JTable and JScrollPane - equal values in two columns for every row in a Jtable

    For better help sooner, post an SSCCE that demonstrates exactly what you're doing.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Help fixing JTable columns in place and length
    By Zuckerberg in forum What's Wrong With My Code?
    Replies: 1
    Last Post: January 26th, 2014, 06:02 AM
  2. Replies: 2
    Last Post: December 13th, 2013, 12:01 AM
  3. passing jtable row values to an sql statement while looping through it
    By greeninho in forum What's Wrong With My Code?
    Replies: 3
    Last Post: May 30th, 2013, 04:40 PM
  4. Search for min and max values as columns position in array
    By susieferrari in forum Java Theory & Questions
    Replies: 3
    Last Post: April 28th, 2011, 07:39 AM
  5. [SOLVED] JTables: How do I adjust row order as I drag columns?
    By assel in forum AWT / Java Swing
    Replies: 3
    Last Post: December 7th, 2010, 04:51 PM

Tags for this Thread