/*
* @(#)JTable.java 1.168 01/02/09
*
* Copyright 1997-2001 Sun Microsystems, Inc. All Rights Reserved.
*
* This software is the proprietary information of Sun Microsystems, Inc.
* Use is subject to license terms.
*
*/
package javax.swing;
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import java.beans.*;
import java.io.Serializable;
import java.io.ObjectOutputStream;
import java.io.ObjectInputStream;
import java.io.IOException;
import javax.accessibility.*;
import javax.swing.event.*;
import javax.swing.plaf.*;
import javax.swing.table.*;
import javax.swing.border.*;
import java.text.NumberFormat;
import java.text.DateFormat;
/**
* <code>JTable</code> is a user-interface component that presents data in
* a two-dimensional table format.
* See <a href="http://java.sun.com/docs/books/tutorial/uiswing/components/table.html">How to Use Tables</a>
* in <em>The Java Tutorial</em>
* for task-oriented documentation and examples of using <code>JTable</code>.
*
* <p>
* The <code>JTable</code> has many
* facilities that make it possible to customize its rendering and editing
* but provides defaults for these features so that simple tables can be
* set up easily. For example, to set up a table with 10 rows and 10
* columns of numbers:
* <p>
* <pre>
* TableModel dataModel = new AbstractTableModel() {
* public int getColumnCount() { return 10; }
* public int getRowCount() { return 10;}
* public Object getValueAt(int row, int col) { return new Integer(row*col); }
* };
* JTable table = new JTable(dataModel);
* JScrollPane scrollpane = new JScrollPane(table);
* </pre>
* <p>
* Because the <code>JTable</code> is now much easier to set up with custom models
* the <code>DefaultTableModel</code> is less useful than it was in previous releases.
* Instead of copying the data in an application into the <code>DefaultTableModel</code>,
* we recommend wrapping it in the methods of the <code>TableModel</code> interface and
* passing the real data to the <code>JTable</code> as above. This technique is nearly as concise
* as using a <code>DefaultTableModel</code> and starting this way has a number of advantages
* over the longer term. In particular: it is a scalable technique,
* can more easily handle dynamic or editable tables, and often results in much
* more efficient applications because the model is free to choose the
* internal representation that best suits the data.
* <p>
* The "Table" directory in the examples/demo area gives a number of complete
* examples of <code>JTable</code> usage, covering how the <code>JTable</code> can be used to provide
* an editable view of data taken from a database and how to modify the columns
* in the display to use specialized renderers and editors. For example, overriding
* <code>AbstractTableModel</code>'s <code>getColumnClass</code> method to return a value of
* <code>ImageIcon.class</code> for a given column allows icons to be displayed,
* while returning a value of <code>Number.class</code> allows digits to be
* right-justified in the column.
* <p>
* The <code>JTable</code> uses integers exclusively to refer to both the rows and the columns
* of the model that it displays. The <code>JTable</code> simply takes a tabular range of cells
* and uses <code>getValueAt(int, int)</code> to retrieve and display the appropriate
* values from the model.
* <p>
* If <code>getTableHeader().setReorderingAllowed(boolean)</code> is used to
* enable column reordering columns may be rearranged in the <code>JTable</code> so that the
* view's columns appear in a different order to the columns in the model.
* This does not affect the implementation of the model at all: when the
* columns are reordered, the <code>JTable</code> maintains the new order of the columns
* internally and converts its column indices before querying the model.
* <p>
* So, when writing a <code>TableModel</code>, it is not necessary to listen for column
* reordering events as the model will be queried in its own coordinate
* system regardless of what is happening in the view.
* In the examples area there is a demonstration of a sorting algorithm making
* use of exactly this technique to interpose yet another coordinate system
* where the order of the rows is changed, rather than the order of the columns.
* <p>
* The general rule for the <code>JTable</code> API and the APIs of all its associated classes,
* including the column model and both the row and column selection models, is:
* methods using integer indices for rows and columns always use the coordinate
* system of the view. There are three exceptions to this rule:
* <ul>
* <li> All references to rows and columns in the <code>TableModel</code>
* interface are in the coordinate system of the model.
* <li> The index <code>modelIndex</code> in the <code>TableColumn</code> constructors
* refers to the index of the column in the model, not the view.
* <li> All constructors for the <code>TableModelEvent</code>, which describes changes
* that have taken place in a table model, use the coordinate system
* of the model.
* </ul>
* The <code>TableColumn</code> provides a slot for holding an identifier or "tag" for each column,
* and the <code>JTable</code> and <code>TableColumnModel</code> both support <code>getColumn(Object id)</code>
* conveniences for locating columns by their identifier. If no identifier is
* explicitly set, the <code>TableColumn</code> returns its header value (the name of the column)
* as a default. A different identifier, which can be of any type, can be set
* using the <code>TableColumn</code>'s <code>setIdentifier</code> method. All of the <code>JTable</code>'s
* functions operate correctly regardless of the type and uniqueness of these
* identifiers.
* <p>
* The <code>convertColumnIndexToView</code> and
* <code>convertColumnIndexToModel</code> methods have been provided to
* convert between the two coordinate systems but
* they are rarely needed during normal use.
* <p>
* As for all <code>JComponent</code> classes, you can use
* {@link InputMap} and {@link ActionMap} to associate an
* {@link Action} object with a {@link KeyStroke} and execute the
* action under specified conditions.
* <p>
* For the keyboard keys used by this component in the standard Look and
* Feel (L&F) renditions, see the
* <a href="doc-files/Key-Index.html#JTable"><code>JTable</code></a> key assignments.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is appropriate
* for short term storage or RMI between applications running the same
* version of Swing. A future release of Swing will provide support for
* long term persistence.
*
*
* @beaninfo
* attribute: isContainer false
* description: A component which displays data in a two dimensional grid.
*
* @version 1.168 02/09/01
* @author Philip Milne
*/
/* The first versions of the JTable, contained in Swing-0.1 through
* Swing-0.4, were written by Alan Chung.
*/
public class JTable extends JComponent implements TableModelListener, Scrollable,
TableColumnModelListener, ListSelectionListener, CellEditorListener,
Accessible
{
//
// Static Constants
//
/**
* @see #getUIClassID
* @see #readObject
*/
private static final String uiClassID = "TableUI";
/** Do not adjust column widths automatically; use a scrollbar. */
public static final int AUTO_RESIZE_OFF = 0;
/** When a column is adjusted in the UI, adjust the next column the opposite way. */
public static final int AUTO_RESIZE_NEXT_COLUMN = 1;
/** During UI adjustment, change subsequent columns to preserve the total width;
* this is the default behavior. */
public static final int AUTO_RESIZE_SUBSEQUENT_COLUMNS = 2;
/** During all resi
没有合适的资源?快使用搜索试试~ 我知道了~
jdk1.3.1_01
共2000个文件
java:2066个
class:91个
h:63个
需积分: 50 40 下载量 30 浏览量
2017-06-13
10:22:19
上传
评论 1
收藏 26.64MB ZIP 举报
温馨提示
jdk 1.3 留备,大家自取, windows平台
资源推荐
资源详情
资源评论
收起资源包目录
jdk1.3.1_01 (2000个子文件)
java.c 25KB
java_md.c 8KB
jni.h 65KB
jvmdi.h 36KB
jvmdi.h 36KB
jvm.h 32KB
interpreter.h 26KB
jvmpi.h 22KB
jvmpi.h 22KB
oobj.h 16KB
gc.h 16KB
reflect.h 11KB
hpi.h 10KB
sys_api.h 9KB
jit.h 9KB
jawt.h 7KB
jawt.h 7KB
opcodes.h 5KB
monitor.h 5KB
vmprofiler.h 5KB
typecodes.h 4KB
util.h 4KB
gc_md.h 3KB
threads.h 3KB
breakpoints.h 3KB
common_exceptions.h 3KB
typedefs.h 3KB
java_lang_Thread.h 2KB
java_lang_ClassLoader.h 2KB
typedefs_md.h 2KB
javaString.h 2KB
tree.h 2KB
signature.h 2KB
bag.h 2KB
log.h 2KB
exceptions.h 2KB
monitor_cache.h 2KB
jvm_md.h 1KB
sysmacros_md.h 1KB
alloc_cache.h 1KB
java.h 1KB
oldnmi.h 1KB
io_md.h 998B
timeval_md.h 966B
java_md.h 946B
jawt_md.h 916B
jawt_md.h 916B
java_lang_String.h 894B
dll.h 884B
java_lang_ThreadGroup.h 850B
byteorder_md.h 831B
utf.h 711B
jmath_md.h 643B
native.h 640B
path.h 592B
wrap.h 570B
debug.h 538B
path_md.h 535B
StubPreamble.h 523B
jni_md.h 496B
miscdefs_md.h 474B
hpi_md.h 453B
jmath.h 442B
bool.h 391B
byteorder.h 358B
readme.html 12KB
sources.html 4KB
metal.html 3KB
example1.html 2KB
metalworks.html 2KB
example1.html 2KB
example1.html 1KB
example3.html 1KB
imagemapcheat.html 1KB
example1.html 1KB
SwingSet2Plugin.html 1KB
example3.html 928B
example3.html 921B
toc.html 906B
example1.html 873B
example1.html 867B
example4.html 867B
Font2DTest.html 859B
example2.html 841B
swing.html 837B
example1.html 801B
Welcome.html 786B
example1.html 754B
example1.html 730B
example4.html 593B
example1.html 586B
example2.html 543B
credits.html 516B
example2.html 508B
example1.html 504B
example2.html 476B
example3.html 474B
example4.html 473B
example1.html 462B
example1.html 441B
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
akemi_homura
- 粉丝: 13
- 资源: 12
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功