Results 1 to 10 of 10

Thread: JTable intro

  1. #1
    o2cool is offline Member
    Join Date
    Mar 2012
    Location
    earth
    Posts
    9
    Rep Power
    0

    Default JTable intro

    I am new to java and my teacher is not able to answer questions or even follow up on anything. I am building a report that will take 11 values from a record and then generate a jtable but i am not able to get this jtable to show up or do anything, I am wondering if there is a place i could ask for some help with how to get a jtable to show up and allow me to add one row to it at a time. Its the amortization report assignment for my class. He just left us hanging without any help yet again. Thanks for any input. I have tried the jtable turtorials from sun but they are not complete enough for me to understand and when they are complied, nothing happens other than "Build Successful" Thanks again.

  2. #2
    gauravfzd's Avatar
    gauravfzd is offline Member
    Join Date
    Oct 2010
    Location
    India
    Posts
    72
    Rep Power
    0

    Default Re: JTable intro

    What do you actually want? Theory or implementation?

  3. #3
    o2cool is offline Member
    Join Date
    Mar 2012
    Location
    earth
    Posts
    9
    Rep Power
    0

    Default Re: JTable intro

    Quote Originally Posted by gauravfzd View Post
    What do you actually want? Theory or implementation?
    im new so not sure what to ask or how to properly ask.

    i have a string going to a method that creates the jtextarea to a scrolling container and a table in that. i am trying to split the table into a header on top and a list on the bottom and make a new window for each record in the file. i do have a optionpane running to ask for 1 record or print all of them. does that help?

  4. #4
    gauravfzd's Avatar
    gauravfzd is offline Member
    Join Date
    Oct 2010
    Location
    India
    Posts
    72
    Rep Power
    0

    Default Re: JTable intro

    There is brief detail on how to show a JTable with data:

    Some steps are:
    1. Create a class that extends AbstractTableModel class.

    2. In this class atleast override/define four methods:
    a). public int getRowCount() //The no of rows the Table will display.
    b). public int getColumnCount() //The no of columns the Table will display.
    c). public Object getValueAt(int rowIndex, int columnIndex) //The value at the particular cell of the table
    d). public String getColumnName(int col) //The name of the column

    3. If you want to change the values in the Table dynamically, Then change the values and assure that the above methods must return the values as you want
    then on the reference of the object of your TableModel class call
    fireTableChanged(null);

    4. Use the Constructor JTable(TableModel) instead of JTable(Object[][] value,String[] label)...


    Use this and ask anything you don't understand in the above code

  5. #5
    o2cool is offline Member
    Join Date
    Mar 2012
    Location
    earth
    Posts
    9
    Rep Power
    0

    Default Re: JTable intro

    ok, i will look into that tomorrow after class, thanks

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

    Default Re: JTable intro

    I have tried the jtable turtorials from sun but they are not complete enough for me to understand and when they are complied, nothing happens other than "Build Successful"
    You probably need to start earlier on in the tutorial: Trail: Creating a GUI With JFC/Swing (The Java™ Tutorials)

    Some steps are:
    1. Create a class that extends AbstractTableModel class.
    There's absolutely no need to extend AbstractTableModel. That's only needed for extreme customization.

    Just use a DefaultTableModel.

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

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

    Default Re: JTable intro

    Moved from New to Java.

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

  8. #8
    gauravfzd's Avatar
    gauravfzd is offline Member
    Join Date
    Oct 2010
    Location
    India
    Posts
    72
    Rep Power
    0

    Default Re: JTable intro

    Quote Originally Posted by DarrylBurke View Post
    There's absolutely no need to extend AbstractTableModel. That's only needed for extreme customization.

    Just use a DefaultTableModel.
    I believe the DefaultTableModel contains a general definition of all the methods of the TableModel. Then again, we want to show our data into the table not someone's data.
    So from where this Extreme customization comes.....

    What is the advantage of using DefaultTableModel over AbstractTableModel????

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

    Default Re: JTable intro

    Quote Originally Posted by gauravfzd View Post
    What is the advantage of using DefaultTableModel over AbstractTableModel????
    When you have a question, start your own thread. Don't hijack an ongoing discussion.

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

  10. #10
    fam2315 is offline Member
    Join Date
    Feb 2011
    Posts
    78
    Rep Power
    0

Similar Threads

  1. Intro
    By ayangupta in forum Threads and Synchronization
    Replies: 2
    Last Post: 03-01-2009, 05:16 PM
  2. Intro
    By ayangupta in forum Introductions
    Replies: 0
    Last Post: 02-27-2009, 08:49 PM
  3. Intro
    By java_srinivasan in forum Introductions
    Replies: 7
    Last Post: 07-21-2008, 03:52 AM
  4. Intro!
    By lakhmir.singh in forum Introductions
    Replies: 3
    Last Post: 10-30-2007, 08:13 PM
  5. Intro...
    By skarthig in forum Advanced Java
    Replies: 2
    Last Post: 08-12-2007, 12:11 PM

Tags for this Thread

Posting Permissions

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