//PROGRAM 13-13 import java.awt.*; import java.awt.event.*; import javax.swing.*; class DemoTable { public JTable table; public JScrollPane scroller; public DemoTable() { final String[] judulKolom = {"No.", "Nama", "Alamat", "Kota"}; final Object[][] data = { {"1", "Totok Triwibowo", "Jl. Melati 12", "Cimahi"}, {"2", "Desi Mekarsari", "Jl. Bunga 333", "Bandung"}, {"3", "Malik Hendrawan","Jl. Sukamiskin 444", "Bandung"}, {"4", "Wahyu Suhendi", "Jl. Badak 1", "Sumedang"}, {"5", "Darmanto", "Jl. Bawang 23", "Brebes"}, {"6", "Hendarto", "Jl. Pemali 32", "Brebes"}, {"7", "Kiki Sumantro", "Jl. Cipakoma 1", "Tegal"}, {"8", "Herman Wijanarko", "Jl. Macanucul 34", "Tegal"}, {"9", "Slamet", "Jl. Pakulaut 99", "Tegal"}, {"10", "Dewi Susanti", "Jl. Tukul 88", "Semarang"}, {"11", "Noni Sumantri", "Jl. A Yani 222", "Solo"}, {"12", "Tedjo Hermanto", "Jl. Duren 6", "Yogyakarta"}, {"13", "Sri Sumarsih","Jl. Melati 5", "Surabaya"}, {"14", "Eko Waluyo", "Jl. Batu 4", "Malang"}, {"15", "Doni Sandi", "Jl. Jeruk 56", "Malang"} }; table = new JTable(data, judulKolom); scroller = new JScrollPane(table, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); scroller.setLocation(0,0); scroller.setSize(new Dimension(440, 300)); } public void createAndShowGUI() { JFrame.setDefaultLookAndFeelDecorated(true); JFrame frame = new JFrame("Demo JTable"); frame.setLayout(null); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(scroller); frame.setBounds(0, 0, 450, 350); frame.setLocationRelativeTo(null); frame.setVisible(true); } public static void main(String[] args) { javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { DemoTable app = new DemoTable(); app.createAndShowGUI(); } }); } }