import java.awt.*;

import javax.swing.*;

import java.awt.event.WindowAdapter;

import java.awt.event.WindowEvent;

 

public class UseJTable extends JFrame {

 

        private static final long serialVersionUID = 1L;

 

        public UseJTable() {

               super("JTable");

               setSize(300, 200);

               addWindowListener(new WindowAdapter(){

                       public void windowClosing(WindowEvent windowevent)

                       {

                              Window window = windowevent.getWindow();

                              window.dispose();

                              System.exit(0);

                       }

               });

               JTable jtable = new JTable(new String[][] {

                              {"Tom", "24"}, {"Kevin", "25"},

                              {"Dave", "24"},{"Michael", "24"},

                              {"Jimmy", "24"},{"Remy", "24"},

                              {"Alice", "24"},{"Jo", "24"}},

                              new String[] {"Name", "Age"});

               jtable.setRowHeight(25);

               jtable.setGridColor(Color.BLUE);

               JScrollPane jScrollPane = new JScrollPane(jtable);

               getContentPane().add(jScrollPane, BorderLayout.CENTER);

        }

 

        public static void main(String args[]) {

               UseJTable st = new UseJTable();

               st.setVisible(true);

        }

} 

[출처] javadocexamples.com


저작자 표시 비영리 변경 금지
신고

'JAVA > Java Applet' 카테고리의 다른 글

[JavaApplet] JTable 예제  (0) 2014.09.17
YOUR COMMENT IS THE CRITICAL SUCCESS FACTOR FOR THE QUALITY OF BLOG POST