⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 showtable.java

📁 图书浏览软件
💻 JAVA
字号:
import java.awt.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
import java.sql.*;


public class showtable extends JTable
{
	public DefaultTableModel tabmod;
	Font newfont = new Font("newfont",Font.PLAIN,12);
	public showtable(DefaultTableModel mod)
	{
		super(mod);
		tabmod = mod;
		setFont(newfont);
	}
	
	public void setColumn(Object[] column)
	{
		for(int i = 0;i<column.length;i++)
		{
			tabmod.addColumn(column[i]);
		}
	}
	
	public void addRow(Object[] row)
	{
			tabmod.addRow(row);
	}
	

	public void removeAllRow()
	{
	    int count = tabmod.getRowCount();
		for(int i = 0;i<count;i++)
		tabmod.removeRow(0);
	}
	
	public void paixu()
	{
		for(int i = 0;i<tabmod.getRowCount();i++)
		{
			tabmod.setValueAt(""+(i+1),i,0);
		}
	}
	
	public void showLinkData(ResultSet rs)
	{	
	    removeAllRow();	
		try
		{
			while(rs.next())
		    {
	            String[] row = new String[getColumnCount()];
	            for(int i = 0;i<getColumnCount();i++)
	            {
	            	row[i] = rs.getString(i+1);
	            }
	            addRow(row);
		    }
		    
		    rs.close();  
		}
		catch(Exception e)
		{
			e.printStackTrace();
		} 
	}
	
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -