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);
    	}
    }

  • 相关阅读:
    左孩子右兄弟的字典树
    UVA 1401 Remember the Word
    HDOJ 4770 Lights Against Dudely
    UvaLA 3938 "Ray, Pass me the dishes!"
    UVA
    Codeforces 215A A.Sereja and Coat Rack
    Codeforces 215B B.Sereja and Suffixes
    HDU 4788 Hard Disk Drive
    HDU 2095 find your present (2)
    图的连通性问题—学习笔记
  • 原文地址:https://www.cnblogs.com/yangchongxing/p/7642420.html
Copyright © 2011-2022 走看看