⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 exercise24_11.java

📁 java程序设计 机械工业出版社 书籍代码
💻 JAVA
字号:
import java.awt.*;import javax.swing.*;import java.util.*;import javax.swing.table.*;public class Exercise24_11 extends javax.swing.JApplet {  /** Creates new form Exercise24_11 */  public Exercise24_11() {    // Create images    Class locator = this.getClass();    ImageIcon imageUS = new ImageIcon(      locator.getResource("image/person.jpg"));    ImageIcon imageFrance =  new ImageIcon(      locator.getResource("image/person.jpg"));    ImageIcon imageCanada =  new ImageIcon(      locator.getResource("image/person.jpg"));    ImageIcon imageUK =  new ImageIcon(      locator.getResource("image/person.jpg"));    // Create table column names    String[] columnNames =      {"Name", "Birthday", "Class Status", "In-State", "Photo"};    // Create table data    Object[][] data = {      {"Jeff F. Smith", new GregorianCalendar(1998, 9-1, 29).getTime(),       "Freshman", new Boolean(false), imageUS},      {"John F. Kay", new GregorianCalendar(1997, 9-1, 29).getTime(),       "Freshman", new Boolean(false), imageFrance},      {"Susan F. Johnson", new GregorianCalendar(1999, 9-1, 29).getTime(),       "Freshman", new Boolean(true), imageCanada},      {"Georege F. Kates", new GregorianCalendar(1999, 9-1, 29).getTime(),       "Freshman", new Boolean(false), imageUK}    };    // Create table model    MyTableModel tableModel = new MyTableModel(data, columnNames);    initComponents();    jTable1.setModel(tableModel);    jTable1.setRowHeight(90);    // Create a combo box for publishers    JComboBox jcboClassStatus = new JComboBox();    jcboClassStatus.addItem("Freshman");    jcboClassStatus.addItem("Sophomore");    jcboClassStatus.addItem("Junior");    jcboClassStatus.addItem("Senior");    jcboClassStatus.addItem("Graduate");    // Set combo box as the editor for the publisher column    TableColumn publisherColumn = jTable1.getColumn("Class Status");    publisherColumn.setCellEditor(      new DefaultCellEditor(jcboClassStatus));  }  /** This method is called from within the constructor to   * initialize the form.   * WARNING: Do NOT modify this code. The content of this method is   * always regenerated by the Form Editor.   */  private void initComponents() {//GEN-BEGIN:initComponents    jScrollPane1 = new javax.swing.JScrollPane();    jTable1 = new javax.swing.JTable();    jTable1.setRowHeight(40);    jScrollPane1.setViewportView(jTable1);    getContentPane().add(jScrollPane1, java.awt.BorderLayout.CENTER);  }//GEN-END:initComponents  // Variables declaration - do not modify//GEN-BEGIN:variables  private javax.swing.JScrollPane jScrollPane1;  private javax.swing.JTable jTable1;  // End of variables declaration//GEN-END:variables  public static void main(String[] args) {    Exercise24_11 applet = new Exercise24_11();    JFrame frame = new JFrame();    //EXIT_ON_CLOSE == 3    frame.setDefaultCloseOperation(3);    frame.setTitle("Exercise24_11");    frame.getContentPane().add(applet, BorderLayout.CENTER);    applet.init();    applet.start();    frame.setSize(400,320);    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();    frame.setLocation((d.width - frame.getSize().width) / 2,                      (d.height - frame.getSize().height) / 2);    frame.setVisible(true);  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -