本文主要是介绍Java swing JTable 示例,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
代码,
import java.awt.Container;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;public class Mylmlk
{public static void main(String[] agrs){JFrame frame=new JFrame("学生成绩表");frame.setSize(500,200);frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);Container contentPane=frame.getContentPane();String[] columnNames = {"id","姓名","性别","年龄","成绩"};Object[][] data1 = {{1, "吴一", "男", 20, 65},{2, "李三", "女", 21, 75},{3, "王四", "男", 20, 85},{4, "刘七七", "女", 22, 65},{5, "张一三", "男", 21, 95} };JTable table=new JTable(data1,columnNames);contentPane.add(new JScrollPane(table));frame.setVisible(true);}
}
这篇关于Java swing JTable 示例的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!