Happy Codings - Programming Code Examples
Html Css Web Design Sample Codes CPlusPlus Programming Sample Codes JavaScript Programming Sample Codes C Programming Sample Codes CSharp Programming Sample Codes Java Programming Sample Codes Php Programming Sample Codes Visual Basic Programming Sample Codes


Java Programming Code Examples

Java > Swing Code Examples

JTable example

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
JTable example package com.ack.gui.swing.simple; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import javax.swing.*; public class JTableExample extends JFrame { String data[][] = {{"John", "Sutherland", "Student"}, {"George", "Davies", "Student"}, {"Melissa", "Anderson", "Associate"}, {"Stergios", "Maglaras", "Developer"}, }; String fields[] = {"Name", "Surname", "Status"}; public static void main( String[] argv ) { JTableExample myExample = new JTableExample( "JTable Example" ); } public JTableExample( String title ) { super( title ); setSize( 150, 150 ); addWindowListener( new WindowAdapter() { public void windowClosing( WindowEvent we ) { dispose(); System.exit( 0 ); } } ); init(); pack(); setVisible( true ); } private void init() { JTable jt = new JTable( data, fields ); JScrollPane pane = new JScrollPane( jt ); getContentPane().add( pane ); } }