/*
* @(#)JTable.java 1.287 06/08/08
*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package javax.swing;
import java.util.*;
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import java.awt.print.*;
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;
import java.text.MessageFormat;
import javax.print.attribute.*;
import javax.print.PrintService;
import sun.swing.SwingUtilities2;
import sun.swing.SwingUtilities2.Section;
import static sun.swing.SwingUtilities2.Section.*;
import sun.swing.PrintingStatus;
/**
* The <code>JTable</code> is used to display and edit regular two-dimensional tables
* of cells.
* 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>
* Note that if you wish to use a <code>JTable</code> in a standalone
* view (outside of a <code>JScrollPane</code>) and want the header
* displayed, you can get it using {@link #getTableHeader} and
* display it separately.
* <p>
* To enable sorting and filtering of rows, use a
* {@code RowSorter}.
* You can set up a row sorter in either of two ways:
* <ul>
* <li>Directly set the {@code RowSorter}. For example:
* {@code table.setRowSorter(new TableRowSorter(model))}.
* <li>Set the {@code autoCreateRowSorter}
* property to {@code true}, so that the {@code JTable}
* creates a {@code RowSorter} for
* you. For example: {@code setAutoCreateRowSorter(true)}.
* </ul>
* <p>
* When designing applications that use the <code>JTable</code> it is worth paying
* close attention to the data structures that will represent the table's data.
* The <code>DefaultTableModel</code> is a model implementation that
* uses a <code>Vector</code> of <code>Vector</code>s of <code>Object</code>s to
* store the cell values. As well as copying the data from an
* application into the <code>DefaultTableModel</code>,
* it is also possible to wrap the data in the methods of the
* <code>TableModel</code> interface so that the data can be passed to the
* <code>JTable</code> directly, as in the example above. This often results
* in more efficient applications because the model is free to choose the
* internal representation that best suits the data.
* A good rule of thumb for deciding whether to use the <code>AbstractTableModel</code>
* or the <code>DefaultTableModel</code> is to use the <code>AbstractTableModel</code>
* as the base class for creating subclasses and the <code>DefaultTableModel</code>
* when subclassing is not required.
* <p>
* The "TableExample" directory in the demo area of the source distribution
* 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.
* <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 the
* values from the model during painting. It is important to remember that
* the column and row indexes returned by various <code>JTable</code> methods
* are in terms of the <code>JTable</code> (the view) and are not
* necessarily the same indexes used by the model.
* <p>
* By default, 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>
* Similarly when using the sorting and filtering functionality
* provided by <code>RowSorter</code> the underlying
* <code>TableModel</code> does not need to know how to do sorting,
* rather <code>RowSorter</code> will handle it. Coordinate
* conversions will be necessary when using the row based methods of
* <code>JTable</code> with the underlying <code>TableModel</code>.
* All of <code>JTable</code>s row based methods are in terms of the
* <code>RowSorter</code>, which is not necessarily the same as that
* of the underlying <code>TableModel</code>. For example, the
* selection is always in terms of <code>JTable</code> so that when
* using <code>RowSorter</code> you will need to convert using
* <code>convertRowIndexToView</code> or
* <code>convertRowIndexToModel</code>. The following shows how to
* convert coordinates from <code>JTable</code> to that of the
* underlying model:
* <pre>
* int[] selection = table.getSelectedRows();
* for (int i = 0; i < selection.length; i++) {
* selection[i] = table.convertRowIndexToModel(selection[i]);
* }
* // selection is now in terms of the underlying TableModel
* </pre>
* <p>
* By default if sorting is enabled <code>JTable</code> will persist the
* selection and variable row heights in terms of the model on
* sorting. For example if row 0, in terms of the underlying model,
* is currently selected, after the sort row 0, in terms of the
* underlying model will be selected. Visually the selection may
* change, but in terms of the underlying model it will remain the
* same. The one exception to that is if the model index is no longer
* visible or was removed. For example, if row 0 in terms of model
* was filtered out the selection will be empty after the sort.
* <p>
* J2SE 5 adds methods to <code>JTable</code> to provide convenient access to some
* common printing needs. Simple new {@link #print()} methods allow for quick
* and easy addition of printing support to your application. In addition, a new
* {@link #getPrintable} method is available for more advanced printing needs.
* <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>
* <strong>Warning:</strong> Swing is not thread safe. For more
* information see <a
* href="package-summary.html#threading">Swing's Threading
* Policy</a>.
* <p>
* <strong>Warning:</s
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
jdk1.6 源码 包含nio等 (2000个子文件)
java.c 61KB
java_md.c 29KB
parse_manifest.c 17KB
wildcard.c 12KB
version_comp.c 9KB
splashscreen_stubs.c 2KB
jli_util.c 1KB
manifest_info.h 5KB
java.h 2KB
java_md.h 1KB
version_comp.h 491B
splashscreen.h 443B
wildcard.h 393B
jli_util.h 375B
JTable.java 351KB
Component.java 338KB
ORBUtilSystemException.java 314KB
Character.java 212KB
BaseRowSet.java 210KB
XPathParser.java 203KB
JComponent.java 193KB
ResultSet.java 192KB
JTree.java 187KB
Pattern.java 180KB
JTextComponent.java 177KB
XMLSchemaValidator.java 171KB
Arrays.java 163KB
Container.java 162KB
Formatter.java 154KB
DatabaseMetaData.java 150KB
BasicTabbedPaneUI.java 148KB
XMLCipher.java 146KB
BasicTreeUI.java 142KB
BigDecimal.java 139KB
GroupLayout.java 139KB
JList.java 136KB
Collections.java 136KB
DecimalFormat.java 135KB
OMGSystemException.java 133KB
ComponentColorModel.java 131KB
XMLDocumentFragmentScannerImpl.java 130KB
XSDHandler.java 129KB
RegularExpression.java 127KB
RelationService.java 127KB
HTMLDocument.java 124KB
AffineTransform.java 124KB
Class.java 121KB
KeyboardFocusManager.java 120KB
XSSimpleTypeDecl.java 119KB
XMLEntityManager.java 118KB
URI.java 116KB
ImageReader.java 115KB
XIncludeHandler.java 115KB
CallableStatement.java 114KB
Window.java 113KB
String.java 113KB
XSLTErrorResources_ja.java 113KB
ConcurrentSkipListMap.java 111KB
ObjectInputStream.java 110KB
XMLGregorianCalendarImpl.java 110KB
DTDGrammar.java 108KB
ToStream.java 107KB
BigInteger.java 107KB
XSLTErrorResources_ko.java 107KB
WindowsLookAndFeel.java 107KB
StyleSheet.java 107KB
MetalLookAndFeel.java 106KB
ResourceBundle.java 104KB
JOptionPane.java 104KB
AbstractButton.java 103KB
TextLayout.java 102KB
GregorianCalendar.java 101KB
RowSet.java 100KB
AbstractDOMParser.java 100KB
AbstractDocument.java 99KB
Font.java 99KB
Toolkit.java 99KB
XSLTErrorResources_zh_TW.java 99KB
XSLTErrorResources_zh_CN.java 99KB
CSS.java 98KB
Scanner.java 98KB
BasicListUI.java 97KB
Path2D.java 97KB
SynthPainter.java 96KB
XSLTErrorResources_de.java 96KB
XSLTErrorResources_fr.java 96KB
Calendar.java 96KB
XSLTErrorResources_es.java 96KB
JPEGMetadata.java 96KB
CoreDocumentImpl.java 96KB
IIOPInputStream.java 95KB
X509CertSelector.java 95KB
XSLTErrorResources_it.java 95KB
BasicLookAndFeel.java 94KB
DTMDocumentImpl.java 93KB
ParsedSynthStyle.java 92KB
SAX2DTM2.java 92KB
XSAttributeChecker.java 91KB
RequiredModelMBean.java 91KB
AbstractSAXParser.java 90KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
- LeoWangxia2021-04-14源码很全,但是没有nio的jar包啊
- xxzzpp1234562012-03-28还行,不过代码不全
- sdongheng2016-08-26比较坑啊,不全啊
- renee123212012-12-27太肯人了,jdk安装后的目录里面有一个资源文件叫src.zip,这个文件就是该文件。。。。哥们儿,你还收分。。。
- hongxingxiaonan2014-09-18虽然不全,很有一些很重要的源码,也不错了
mietian
- 粉丝: 22
- 资源: 152
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功