Now you can easily create a JTable component. Here, the procedure for creating a JTable component is given with the brief description of JTable and it's components.
JTable: The JTabel component is more flexible Java Swing component that allows the user to store, show and edit the data in tabular format. It is a user-interface component that represents the data of two-dimensional tabular format. The Java swing implements tables by using the JTable class and a subclass of JComponent.
For learning complete JTable component you have to learn following parts:
Rendering: In computer program, the rendering is a process that generates an image from a model. Model is a specification of three dimensional objects.
Table model: All tables contains of its data from an object that implements the TableModel interface of java swing package. The TableModel interface uses the methods of JTable class that integrates a tabular data model.
Observable event model: The event model is a building block of graphical user interfaces (GUI). This is a user friendly and most common that is provided by the graphical frameworks. The observable is a system state property that determines by some sequence of physical operations.
Tool tips: The tool tips are most common graphical user interface that is used for displaying the message in small box given by the user appropriate message, when the mouse pointer or cursor goes on it, a message (description) appears without clicking it.
Description of program:
In this Java programming tutorial we are going to implement the simple JTable on the java swing frame with the help of some java methods. To create a JTable component, you need a java swing frame. The JTable based on the frame's panel contains multiple data in a tabular format such as rows and columns.
Description of code:
JTable( Object data, Object col):
This is the constructor of JTable class that implements a JTable for displaying the values in tabular format like rows and columns. All rows must have the same length as column names. It takes two arguments: data and col.
data - It defines the all data that will have to
create a JTable.
col - It specifies the name of each column of the JTable.
Here is the code of program:
Output of program:
Rs. 20,000 US$ 300
Today: Rs. 10,000 US$150
Course Duration: 30 hrs
Posted on: April 14, 2007 If you enjoyed this post then why not add us on Google+? Add us to your Circles