📄 tableexample.java
字号:
package examples.windows;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
/** An example class used to demonstrate the use of
* the JTable component
*/
public class TableExample extends JFrame {
/** Class constructor method
* @param titleText Window's title bar text
*/
public TableExample( String titleText ) {
super( titleText );
addWindowListener( new WindowCloser() );
JTable stats = new JTable( new Object[][] {
{ "Gonzalez", ".295", "34", "12", "6", "10" },
{ "Carter", ".302", "27", "12", "2", "15" },
{ "Fernandez", ".285", "30", "12", "11", "1" },
{ "Greene", ".321", "41", "12", "0", "10" },
{ "Delgado", ".298", "34", "12", "1", "20" },
} ,
new Object[] {
"Player", "avg", "1B", "2B", "3B", "HR"
}
);
JScrollPane scrollStats = new JScrollPane( stats );
getContentPane().add( scrollStats,
BorderLayout.CENTER );
setSize( 500, 200 );
setVisible( true );
}
/** The test method for the class
* @param args not used
*/
public static void main( String[] args ) {
new TableExample( "Table Example" );
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -