Results 1 to 6 of 6

Thread: What is the use of JTable class?

  1. #1
    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.

  2. #2
    Join Date
    May 2008
    Posts
    2,297

    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.

  3. #3
    Join Date
    Oct 2005
    Posts
    2,393

    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);
    
      }

  4. #4
    Join Date
    May 2008
    Posts
    2,389

    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)

  5. #5
    Join Date
    Feb 2008
    Posts
    1,852

    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);
    
      }
    
    }

  6. #6
    Join Date
    Jan 2008
    Posts
    1,521

    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)

Similar Threads

  1. Editing JTable cells
    By Messenger in forum Software Development
    Replies: 5
    Last Post: 29-07-2010, 10:31 AM
  2. Fill JTable with several values
    By Logan 2 in forum Software Development
    Replies: 5
    Last Post: 19-01-2010, 02:39 PM
  3. Print JTable with the help of java
    By Coldman in forum Software Development
    Replies: 3
    Last Post: 25-11-2009, 09:02 AM
  4. How to retrieve data from a jTable in Java and MS access
    By Corona in forum Software Development
    Replies: 3
    Last Post: 09-07-2009, 11:59 AM
  5. How to refresh data of Jtable in java
    By sarmad_iu in forum Software Development
    Replies: 1
    Last Post: 28-05-2009, 02:45 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,454,540.07326 seconds with 17 queries