Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



What is the use of JTable class?

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 13-02-2010
Member
 
Join Date: Dec 2009
Posts: 38
What is the use of JTable class?
  

Hi all,

I am learning advanced java programming. This programming sounds very difficult to understand than C++ programming. I need you help to know about the 'class JTable'. This class is something related to creating table java, and this is the only which I know about JTable class. If you have knowledge about the JTable class of java, then please let me know the same. I would greatly appreciate your any help.

Reply With Quote
  #2  
Old 13-02-2010
Member
 
Join Date: May 2008
Posts: 2,290
Re: What is the use of JTable class?

The JTable is used to display and edit regular two-dimensional tables of cells. The JTable has many facilities that make it possible to customize its rendering and editing but provides defaults for these features so that simple tables can be set up easily. Note that if you wish to use a JTable in a standalone view (outside of a JScrollPane) and want the header displayed, you can get it using getTableHeader() and display it separately.
Reply With Quote
  #3  
Old 13-02-2010
Member
 
Join Date: Oct 2005
Posts: 2,389
Re: What is the use of JTable class?

Hi friend,

I have one example of java which will demonstrate you the use of JTable class:
Code:
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;

public class JTableDemo {
  public static void main(String args[]) {
    JFrame frp = new JFrame();
    frp.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    Object rowData[][] = { { "Row1-Column1", "Row1-Column2", "Row1-Column3" },
        { "Row2-Column1", "Row2-Column2", "Row2-Column3" } };
    Object columnNames[] = { "Column One", "Column Two", "Column Three" };
    JTable table = new JTable(rowData, columnNames);

    JScrollPane scrollPane = new JScrollPane(table);
    frp.add(scrollPane, BorderLayout.CENTER);
    frp.setSize(200, 150);
    frp.setVisible(true);

  }
Reply With Quote
  #4  
Old 13-02-2010
Member
 
Join Date: May 2008
Posts: 2,381
Re: What is the use of JTable class?

The JTable class of java is basically used for to create tables. Following are some constructors of the JTable class:
  • JTable(Vector rData, Vector Namesofcolumn)
  • JTable(TableModel tdm, TableColumnModel tcm, ListSelectionModel sm)
  • JTable(TableModel tdm, TableColumnModel tcm)
  • JTable(TableModel tdm)
  • JTable(int Rowsnum, int Columnsnum)
Reply With Quote
  #5  
Old 13-02-2010
Member
 
Join Date: Feb 2008
Posts: 1,845
Re: What is the use of JTable class?

I have coded one java example using JTable class. When you run below code, it will create table with 12 rows and 6 columns:
Code:
import javax.swing.JTable;
import javax.swing.JScrollPane;

public class TJDemo
{
  
public static void main(String[] argt) 
{
    JTable tnl = new JTable(12, 6);// it will create a table with 12 rows and 6 columns

    JScrollPane scrollPane = new JScrollPane(tnl);

  }

}
Reply With Quote
  #6  
Old 13-02-2010
Member
 
Join Date: Jan 2008
Posts: 1,514
Re: What is the use of JTable class?

Hi,

Below are some methods of JTable class of java, please go through them:
  1. createScrollPaneForTable(JTable tle)
  2. ditCellAt(int rw, int clm, EventObject eo)
  3. editingStopped(ChangeEvent ev)
  4. columnSelectionChanged(ListSelectionEvent ev)
  5. columnAtPoint(Point pt)
  6. addRowSelectionInterval(int 0index, int 1index)
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "What is the use of JTable class?"
Thread Thread Starter Forum Replies Last Post
Editing JTable cells Messenger Software Development 5 29-07-2010 10:31 AM
Fill JTable with several values Logan 2 Software Development 5 19-01-2010 01:39 PM
Print JTable with the help of java Coldman Software Development 3 25-11-2009 08:02 AM
How to retrieve data from a jTable in Java and MS access Corona Software Development 3 09-07-2009 11:59 AM
How to refresh data of Jtable in java sarmad_iu Software Development 1 28-05-2009 02:45 PM


All times are GMT +5.5. The time now is 11:54 AM.