retrieve data from a jTable

Discussion in 'Java' started by Jacques Chaurette, Oct 4, 2005.

  1. hi, I am trying to retrieve data from a jTable with this instruction:

    jLabelPipec1.setText(""+ valueOf(data[1,1]));

    the data array is an objet as required for a table.

    and of course it doesn't work. Any suggestions appreciated.


    Jacques
    Jacques Chaurette, Oct 4, 2005
    #1
    1. Advertising

  2. Jacques Chaurette

    Roedy Green Guest

    On Tue, 4 Oct 2005 17:59:43 -0400, "Jacques Chaurette"
    <> wrote or quoted :

    >and of course it doesn't work.


    By that you mean?

    There is no change visible?
    You get an exception?
    You get a compile error?

    I am going to tease you, though it is not just you who do this.
    Jacques invited his friends to come see his fine new house. When they
    came in the door he issued each with a pirate's eye patch to cover one
    eye and a paper tube from the centre of a roll of paper towels. Then
    he instructed them to look out the other eye, only through the tube.
    Then he turned out all the lights and guided them on a tour of the
    house lit by flashlight (electric torch).

    Well, what do you think of my skill at interior design? he asked at
    the end of the tour.

    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Again taking new Java programming contracts.
    Roedy Green, Oct 5, 2005
    #2
    1. Advertising

  3. On 2005-10-04, Jacques Chaurette penned:
    > hi, I am trying to retrieve data from a jTable with this
    > instruction:
    >
    > jLabelPipec1.setText(""+ valueOf(data[1,1]));
    >
    > the data array is an objet as required for a table.
    >
    > and of course it doesn't work. Any suggestions appreciated.
    >


    Um.

    Okay, I'll start with the first question: in what class does the above
    line live? Is there any reason I should know what valueOf does
    without knowing which class it belongs to?

    I don't recognize the syntax data[1,1] as anything you can do in Java,
    although it's late and my brain is fried, so I may be wrong.

    Oh! One more! Please define "doesn't work." Doesn't compile? If so,
    what does the compiler say?

    --
    monique

    Ask smart questions, get good answers:
    http://www.catb.org/~esr/faqs/smart-questions.html
    Monique Y. Mudama, Oct 5, 2005
    #3
  4. Right sorry, doesn't work means doesn't compile. I am using JBuilder and the
    compiler just refuses to run this, claims its missing a parenthesis. My java
    knowledge is a little sketchy as I keep forgetting things that I knew a few
    years ago especially when I stop doing java for a few years.

    Data is an object that contains string data for a table and I am trying to
    retrieve some table data. I thought that valueOf was a sort of universal
    function that could accomplish this.

    I am pretty sure that this syntax is OK data[1,1] for retrieving the item in
    the 1,1 position.

    The table elements are defined as follows:

    String[] columnNames = {"Dia. (in)",
    "Instal. cost"};

    Object[][] data = {
    {"3", "$25"},
    {"4", "$30"},
    {"5", "$35"},
    {"6", "$45"},
    {"8", "$55"}

    };

    Jacques

    "Monique Y. Mudama" <> wrote in message
    news:...
    > On 2005-10-04, Jacques Chaurette penned:
    >> hi, I am trying to retrieve data from a jTable with this
    >> instruction:
    >>
    >> jLabelPipec1.setText(""+ valueOf(data[1,1]));
    >>
    >> the data array is an objet as required for a table.
    >>
    >> and of course it doesn't work. Any suggestions appreciated.
    >>

    >
    > Um.
    >
    > Okay, I'll start with the first question: in what class does the above
    > line live? Is there any reason I should know what valueOf does
    > without knowing which class it belongs to?
    >
    > I don't recognize the syntax data[1,1] as anything you can do in Java,
    > although it's late and my brain is fried, so I may be wrong.
    >
    > Oh! One more! Please define "doesn't work." Doesn't compile? If so,
    > what does the compiler say?
    >
    > --
    > monique
    >
    > Ask smart questions, get good answers:
    > http://www.catb.org/~esr/faqs/smart-questions.html
    Jacques Chaurette, Oct 5, 2005
    #4
  5. Ah, got it, you were right I am calling the data item the wrong way,
    data[1][1] is the right call.

    Jacques

    "Jacques Chaurette" <> wrote in message
    news:bmE0f.2154$...
    > Right sorry, doesn't work means doesn't compile. I am using JBuilder and
    > the compiler just refuses to run this, claims its missing a parenthesis.
    > My java knowledge is a little sketchy as I keep forgetting things that I
    > knew a few years ago especially when I stop doing java for a few years.
    >
    > Data is an object that contains string data for a table and I am trying to
    > retrieve some table data. I thought that valueOf was a sort of universal
    > function that could accomplish this.
    >
    > I am pretty sure that this syntax is OK data[1,1] for retrieving the item
    > in the 1,1 position.
    >
    > The table elements are defined as follows:
    >
    > String[] columnNames = {"Dia. (in)",
    > "Instal. cost"};
    >
    > Object[][] data = {
    > {"3", "$25"},
    > {"4", "$30"},
    > {"5", "$35"},
    > {"6", "$45"},
    > {"8", "$55"}
    >
    > };
    >
    > Jacques
    >
    > "Monique Y. Mudama" <> wrote in message
    > news:...
    >> On 2005-10-04, Jacques Chaurette penned:
    >>> hi, I am trying to retrieve data from a jTable with this
    >>> instruction:
    >>>
    >>> jLabelPipec1.setText(""+ valueOf(data[1,1]));
    >>>
    >>> the data array is an objet as required for a table.
    >>>
    >>> and of course it doesn't work. Any suggestions appreciated.
    >>>

    >>
    >> Um.
    >>
    >> Okay, I'll start with the first question: in what class does the above
    >> line live? Is there any reason I should know what valueOf does
    >> without knowing which class it belongs to?
    >>
    >> I don't recognize the syntax data[1,1] as anything you can do in Java,
    >> although it's late and my brain is fried, so I may be wrong.
    >>
    >> Oh! One more! Please define "doesn't work." Doesn't compile? If so,
    >> what does the compiler say?
    >>
    >> --
    >> monique
    >>
    >> Ask smart questions, get good answers:
    >> http://www.catb.org/~esr/faqs/smart-questions.html

    >
    >
    Jacques Chaurette, Oct 5, 2005
    #5
  6. Jacques Chaurette

    Roedy Green Guest

    On Tue, 4 Oct 2005 19:36:37 -0400, "Jacques Chaurette"
    <> wrote or quoted :

    >compiler just refuses to run this, claims its missing a parenthesis.


    To solve this we need to see:

    1. the exact line the compiler is complaining about.

    2. the exact text of the error message.

    3. the context: i.e. the places where the various things mentioned in
    the line are defined.

    4. ideally a COMPLETE program since the problem is rarely where the
    person with the problem thinks it is.

    The devil is in the details. You can diagnose squat from a rough
    description.
    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Again taking new Java programming contracts.
    Roedy Green, Oct 5, 2005
    #6
  7. Jacques Chaurette

    John Guest

    Jacques Chaurette wrote:
    > hi, I am trying to retrieve data from a jTable with this instruction:
    >
    > jLabelPipec1.setText(""+ valueOf(data[1,1]));
    >
    > the data array is an objet as required for a table.
    >
    > and of course it doesn't work. Any suggestions appreciated.
    >
    >
    > Jacques
    >
    >


    you need something more like this..

    String[][] data inited elsewhere
    String[] headers inited elsewhere
    JLabel myLabel inited elsewhere

    JTable myTable = new JTable(data, header);

    myLabel.setText(myTable.getValueAt(0,0).toString());

    Your initial code is nowhere near compiling or working.

    John
    John, Oct 5, 2005
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tivo Escobar
    Replies:
    1
    Views:
    7,258
    manusa
    Apr 12, 2007
  2. sameer
    Replies:
    0
    Views:
    664
    sameer
    Jun 30, 2003
  3. Tintin92
    Replies:
    1
    Views:
    1,671
    Andrew Thompson
    Feb 14, 2007
  4. Tom
    Replies:
    3
    Views:
    156
  5. Haircuts Are Important
    Replies:
    3
    Views:
    296
    Haircuts Are Important
    Jun 4, 2013
Loading...

Share This Page