Home | Ajax | BioInformatics | Dojo | EAI | EJB | Hibernate | J2ME | Java | Java Glossary | Java Servlets | JavaScript | Jboss | JDBC | JDO | Jmeter | JSF | JSP | JUnit | Maven | MySQL | Spring Framework | SQL | Struts | Technology | WAP | Web Services | XML


 
  
 
Programming Tutorials: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML
 

 
Facing Programming Problem?
Ask Questions?, Browse Latest Questions, Question-Answer Guidelines
Java
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments

Creating a JTable Component

                         

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:

  • JTable
  • Rendering
  • Table model
  • Observable event model
  • Tool tips

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:

import javax.swing.*;
import java.awt.*;

public class JTableComponent{
  public static void main(String[] args
{

    new JTableComponent();
  }

  public JTableComponent(){
    JFrame frame = new JFrame("Creating 
JTable Component Example!"
);
    JPanel panel = new JPanel();
    String data[][] {{"vinod","BCA","A"},{"Raju","MCA","b"},
     {
"Ranjan","MBA","c"},{"Rinku","BCA","d"}};

      String col[] {"Name","Course","Grade"};
    JTable table = new JTable(data,col);
    panel.add(table,BorderLayout.CENTER);
    
frame.add(panel);
    frame.setSize(300,200);
    frame.setVisible(true);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  }
}

Download this example.

Output of program:

                         

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

3 comments so far (
post your own) View All Comments Latest 10 Comments:

Thanks for such a nice site with meaningful information.

Posted by skg on Thursday, 09.11.08 @ 14:37pm | #78671

I saw your JTable Example where u added JTable to a JPanel,but the header of the JTable is missing in output.I am facing same problem.Is there any solution.

Posted by Manish on Thursday, 08.7.08 @ 13:16pm | #71544

Hi,

I felt very happy by reading the JTable related web pages from your site.

Thank you.
Nagarajan. A.

Posted by Nagarajan on Thursday, 03.27.08 @ 03:49am | #54444

Latest Searches:
Downloading and Instal
adding label and textb
fireTableCellUpdated
Photoshop Abstracts Ab
diff b/w function and
default path
ASP Form Processing Se
telephone
Swing component for en
tree component web jav
binary recursion
Creating a DSN for MyS
source code of game i
Action list
connection between jdb
read from file
valueChangeListener
max length 500 chars
hostname
decimal to ANSI
canonical
XML validation in Stru
jasper reports using j
source code of puzzle
game in java
primitive data types u
jsp codes
file to string
@Results annotation in
multiple ajax combo
<s:text> example
Photoshop Photo Effect
jsp in ibm websphere
Initialization
request.setAttribute
jsp value to javascrip
Xml jsp ajax
default directory
struts2 radio button
displyand store the im
text editor
parse a int to string
jsp to microsoft sql
j2me Collection
ASP Database Related U
Java Write To File in
IBM MQ series
convert object into in
scroll bar
give the input text fi
byte
Combo Box operation in
Containers
input in array
Request Object In JSP
substring
abstract class v5
selectManyCheckbox
Jframe Tutorials
Flash Special Effects
how to capture multipl
command line java
breadcrumbs in jsp
doctor
How to deploy a java p
Eclipse 3.4 EJB
socket
write to text file ret
header
relative path
Visual Basic Date and
Connect JSP with sql
network threading
save image to file
where we place plug-in
Quick Sort
class diagrams in UML
lire fichier texte
align checkboxlist in
<s:autocompleter> ajax
Java String toLowerCase Example
Java String toCharArray Example
Java String substring Example
Java String indexOf Example
Java String startsWith Example
Java String hashCode Example
Java String matches Example
Java String length Example
Java String lastIndexOf Example
Java String isEmpty Example
Java String equalsIgnoreCase Example
Java String equals Example
Java String endsWith Example
Java String copyValueOf Example
Java String contentEquals Example
  EAI Articles
  Java Certification
Tell A Friend
Your Friend Name
Search Tutorials

 

 
 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.