《Java2图形设计卷II:Swing》配套光盘源码

源代码在线查看: test.java

软件大小: 4504 K
上传用户: guigong
关键词: Java2 Swing 图形 光盘
下载地址: 免注册下载 普通下载 VIP

相关代码

				import javax.swing.*;
				import javax.swing.event.*;
				import javax.swing.table.*;
				import java.awt.*;
				import java.awt.event.*;
				
				public class Test extends JApplet {
					JTable table = new JTable(
						new AbstractTableModel() {
							int rows = 10, cols = 10;
				
							public int getRowCount() { return rows; }
							public int getColumnCount() { return cols; }
				
							public Object getValueAt(int row, int col) {
								return "(" + Integer.toString(row) + "," +
											 Integer.toString(col) + ")";
							}
						}
					);	
				
					public void init() {
						Container contentPane = getContentPane();
				
						contentPane.add(new JScrollPane(table),
										BorderLayout.CENTER);
				
						table.getColumnModel().addColumnModelListener(
												new TableColumnModelListener() {
							public void columnAdded(TableColumnModelEvent e) { }
							public void columnMarginChanged(ChangeEvent e) { }
							public void columnRemoved(TableColumnModelEvent e) { }
							public void columnSelectionChanged(
														ListSelectionEvent e) { }
				
							public void columnMoved(TableColumnModelEvent e) { 
								String s = "Column Moved From " + 
											e.getFromIndex() + " To " +
											e.getToIndex();
				
								showStatus(s);
							}
						});
					}
				}
							

相关资源