/*
* @(#)JTable.java 1.288 06/11/15
*
* 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 源代码
共2000个文件
java:3196个
class:18个
umr:2个
需积分: 9 44 下载量 145 浏览量
2009-07-14
00:01:19
上传
评论
收藏 9.35MB RAR 举报
温馨提示
JDK1.6 源代码 ,这是最新的并齐全的源代码。为了满足大家的需求,故贡献出来大家贡献一下
资源推荐
资源详情
资源评论
收起资源包目录
JDK1.6 源代码 (2000个子文件)
JTable.java 350KB
Component.java 338KB
Character.java 212KB
BaseRowSet.java 210KB
JComponent.java 194KB
ResultSet.java 192KB
JTree.java 187KB
Pattern.java 183KB
JTextComponent.java 177KB
Arrays.java 163KB
Container.java 162KB
Formatter.java 154KB
DatabaseMetaData.java 150KB
BasicTabbedPaneUI.java 148KB
BasicTreeUI.java 140KB
BigDecimal.java 139KB
GroupLayout.java 139KB
Collections.java 136KB
JList.java 136KB
DecimalFormat.java 135KB
ComponentColorModel.java 131KB
RelationService.java 127KB
HTMLDocument.java 124KB
AffineTransform.java 124KB
KeyboardFocusManager.java 123KB
Class.java 121KB
URI.java 116KB
ImageReader.java 115KB
CallableStatement.java 114KB
Window.java 113KB
String.java 113KB
ConcurrentSkipListMap.java 111KB
ObjectInputStream.java 110KB
BigInteger.java 107KB
StyleSheet.java 107KB
MetalLookAndFeel.java 106KB
ResourceBundle.java 104KB
JOptionPane.java 104KB
AbstractButton.java 103KB
TextLayout.java 102KB
GregorianCalendar.java 101KB
Font.java 100KB
RowSet.java 100KB
AbstractDocument.java 99KB
Toolkit.java 99KB
BasicListUI.java 98KB
CSS.java 98KB
Scanner.java 98KB
Path2D.java 97KB
SynthPainter.java 96KB
Calendar.java 96KB
X509CertSelector.java 95KB
BasicLookAndFeel.java 94KB
ParsedSynthStyle.java 92KB
RequiredModelMBean.java 91KB
AccessibleHTML.java 90KB
BasicTextUI.java 90KB
RMIConnector.java 89KB
ColorModel.java 88KB
GridBagLayout.java 88KB
AbstractQueuedSynchronizer.java 84KB
JEditorPane.java 83KB
TreeMap.java 83KB
MetalIconFactory.java 83KB
CachedRowSet.java 82KB
JInternalFrame.java 82KB
JTabbedPane.java 82KB
ImageWriter.java 81KB
BasicTableUI.java 80KB
JComboBox.java 80KB
DefaultStyledDocument.java 79KB
File.java 79KB
ObjectName.java 78KB
Raster.java 78KB
JapaneseImperialCalendar.java 77KB
SimpleDateFormat.java 77KB
ObjectOutputStream.java 76KB
DefaultEditorKit.java 76KB
AbstractQueuedLongSynchronizer.java 74KB
HTMLEditorKit.java 72KB
SwingUtilities.java 71KB
CharacterData00.java 70KB
ObjectStreamClass.java 70KB
BasicSplitPaneUI.java 70KB
ClassLoader.java 69KB
SecurityManager.java 68KB
Thread.java 68KB
AbstractPreferences.java 68KB
ThreadPoolExecutor.java 68KB
SimpleTimeZone.java 67KB
BasicSliderUI.java 66KB
JSpinner.java 64KB
BasicComboBoxUI.java 63KB
TransferHandler.java 63KB
Dialog.java 63KB
MetaData.java 62KB
MessageFormat.java 62KB
JFileChooser.java 62KB
ICC_Profile.java 62KB
DefaultCaret.java 61KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
users502317468
- 粉丝: 1
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功