Table Demo

Friday, November 9, 2007

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

class SimpleTableExample extends JFrame
{

private JPanel topPanel;
private JTable table;
private JScrollPane scrollPane;


public SimpleTableExample()
{

setTitle( "Simple Table Application" );
setSize( 300, 200 );
setBackground( Color.gray );


topPanel = new JPanel();
topPanel.setLayout( new BorderLayout() );
getContentPane().add( topPanel );

// Create columns names
String columnNames[] = { "Column 1", "Column 2", "Column 3" };

// Create some data
String dataValues[][] =
{
{ "12", "234", "67" },
{ "-123", "43", "853" },
{ "93", "89.2", "109" },
{ "279", "9033", "3092" }
};

// Create a new table instance
table = new JTable( dataValues, columnNames );

// Add the table to a scrolling pane
scrollPane = new JScrollPane( table );
topPanel.add( scrollPane, BorderLayout.CENTER );
}

// Main entry point for this example
public static void main( String args[] )
{
// Create an instance of the test application
SimpleTableExample mainFrame = new SimpleTableExample();
mainFrame.setVisible( true );
}
}

Posted by gentlefolk at 9:15 AM  

6 comments:

hi frnd i need a source code for a banking project in java kindly help me out....you can email me at ur_frnd_18@yahoo.co.in

Ricky said...
June 17, 2008 at 1:15 PM  

hi i need a source code for a voice chatting in java.can u plz help me.you can mail me at hemashiki@gmail.com

Hema said...
November 12, 2008 at 8:50 PM  

hi sir,
i am a student of MCA.
i need a full project in jsp on hotel management that should be run on tomcat server.
plz help me and send project on er_oracle@yahoo.co.in

AmanBatra said...
February 3, 2009 at 8:04 PM  

hi frend..i need source code for smsbaning project in java..can u plz help me..u can send project on
snehalbhngl66@gmail.com

Unknown said...
July 19, 2009 at 11:41 PM  

Please put the following code in constructor to get the proper exit of this swing application.

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

Thanking you.

AMOL

AMOL NAKHWA. said...
November 13, 2009 at 9:30 AM  

hi sir
i am a student of mca 4 sem and want a desktop apllication based minor project in java on job consultancy, please send me or help me about another minor project on client server based in java

June 20, 2010 at 2:14 AM  

Post a Comment

About Me

Seventh Sense
View my complete profile

Photos