zoukankan      html  css  js  c++  java
  • Swing JTable使用

    package cn.ychx;
    
    import java.awt.Dimension;
    import java.awt.Toolkit;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    import java.util.ArrayList;
    import java.util.List;
    
    import javax.swing.JFrame;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.SwingUtilities;
    
    public class CreateWebCode extends JFrame {
    
    	private static final long serialVersionUID = 1L;
    	public static final int WIDTH = 300;
    	public static final int HEIGHT = 500;
    	
    	public static void main(String[] args) {
    		SwingUtilities.invokeLater(new Runnable(){
    			@Override
    			public void run() {
    				CreateWebCode cwc = new CreateWebCode();
    				Toolkit kit = Toolkit.getDefaultToolkit();
    				Dimension dimension = kit.getScreenSize();
    				cwc.setBounds((dimension.width - WIDTH)/2, (dimension.height - HEIGHT)/2, WIDTH, HEIGHT);
    				cwc.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    				cwc.setVisible(true);
    			}
    			
    		});
    		
    	}
    
    	public CreateWebCode() {
    		String[] columnNames = { "Name", "Flag"};
    		Object[][] data = {
    				{"Tom","1"},
    				{"Alice","2"},
    				{"Jance","3"},
    				{"Babo","4"}
    		};
    		JTable table = new JTable(data, columnNames);
    		JScrollPane scrollPane = new JScrollPane(table); 
    		add(scrollPane);
    	}
    }

  • 相关阅读:
    Html
    git和github简易教程
    Java基础
    如何学习一门语言
    leetcode题解(持续更新)
    浅谈安全威胁+引子
    内网渗透基础
    Java运算符
    Java修饰符
    Java变量类型
  • 原文地址:https://www.cnblogs.com/yangchongxing/p/7642420.html
Copyright © 2011-2022 走看看