Results 1 to 10 of 10
Thread: JTable intro
- 03-26-2012, 11:49 AM #1
Member
- Join Date
- Mar 2012
- Location
- earth
- Posts
- 9
- Rep Power
- 0
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.
- 03-26-2012, 12:07 PM #2
Re: JTable intro
What do you actually want? Theory or implementation?
- 03-26-2012, 12:13 PM #3
Member
- Join Date
- Mar 2012
- Location
- earth
- Posts
- 9
- Rep Power
- 0
Re: JTable intro
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?
- 03-26-2012, 12:25 PM #4
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
- 03-26-2012, 01:09 PM #5
Member
- Join Date
- Mar 2012
- Location
- earth
- Posts
- 9
- Rep Power
- 0
Re: JTable intro
ok, i will look into that tomorrow after class, thanks
- 03-27-2012, 02:48 AM #6
Re: JTable intro
You probably need to start earlier on in the tutorial: Trail: Creating a GUI With JFC/Swing (The Java™ Tutorials)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"
There's absolutely no need to extend AbstractTableModel. That's only needed for extreme customization.Some steps are:
1. Create a class that extends AbstractTableModel class.
Just use a DefaultTableModel.
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 03-27-2012, 02:56 AM #7
Re: JTable intro
Moved from New to Java.
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 03-27-2012, 05:55 AM #8
Re: JTable intro
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????
- 03-27-2012, 11:48 AM #9
- 03-27-2012, 08:43 PM #10
Member
- Join Date
- Feb 2011
- Posts
- 78
- Rep Power
- 0
Similar Threads
-
Intro
By ayangupta in forum Threads and SynchronizationReplies: 2Last Post: 03-01-2009, 05:16 PM -
Intro
By ayangupta in forum IntroductionsReplies: 0Last Post: 02-27-2009, 08:49 PM -
Intro
By java_srinivasan in forum IntroductionsReplies: 7Last Post: 07-21-2008, 03:52 AM -
Intro!
By lakhmir.singh in forum IntroductionsReplies: 3Last Post: 10-30-2007, 08:13 PM -
Intro...
By skarthig in forum Advanced JavaReplies: 2Last Post: 08-12-2007, 12:11 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks