?? librarytablemodel.java
字號:
/* ===================================================
* JCommon : a free general purpose Java class library
* ===================================================
*
* Project Info: http://www.jfree.org/jcommon/index.html
* Project Lead: David Gilbert (david.gilbert@object-refinery.com);
*
* (C) Copyright 2000-2003, by Object Refinery Limited and Contributors.
*
* This library is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* ----------------------
* LibraryTableModel.java
* ----------------------
* (C) Copyright 2002, 2003, by Object Refinery Limited.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* $Id: LibraryTableModel.java,v 1.4 2003/06/12 16:54:45 mungady Exp $
*
* Changes
* -------
* 28-Feb-2002 : Version 1 (DG);
* 15-Mar-2002 : Modified to use ResourceBundle for elements that require localisation (DG);
* 08-Oct-2002 : Fixed errors reported by Checkstyle (DG);
*
*/
package org.jfree.ui.about;
import java.util.List;
import java.util.ResourceBundle;
import javax.swing.table.AbstractTableModel;
/**
* A table model containing a list of libraries used in a project.
* <P>
* Used in the LibraryPanel class.
*
* @author David Gilbert
*/
public class LibraryTableModel extends AbstractTableModel {
/** Storage for the libraries. */
private List libraries;
/** Localised name column label. */
private String nameColumnLabel;
/** Localised version column label. */
private String versionColumnLabel;
/** Localised licence column label. */
private String licenceColumnLabel;
/** Localised info column label. */
private String infoColumnLabel;
/**
* Constructs a LibraryTableModel.
*
* @param libraries the libraries.
*/
public LibraryTableModel(List libraries) {
this.libraries = libraries;
String baseName = "org.jfree.ui.about.resources.AboutResources";
ResourceBundle resources = ResourceBundle.getBundle(baseName);
this.nameColumnLabel = resources.getString("libraries-table.column.name");
this.versionColumnLabel = resources.getString("libraries-table.column.version");
this.licenceColumnLabel = resources.getString("libraries-table.column.licence");
this.infoColumnLabel = resources.getString("libraries-table.column.info");
}
/**
* Returns the number of rows in the table model.
*
* @return the number of rows.
*/
public int getRowCount() {
return libraries.size();
}
/**
* Returns the number of columns in the table model. In this case, there are always four
* columns (name, version, licence and other info).
*
* @return the number of columns in the table model.
*/
public int getColumnCount() {
return 4;
}
/**
* Returns the name of a column in the table model.
*
* @param column the column index (zero-based).
*
* @return the name of the specified column.
*/
public String getColumnName(int column) {
String result = null;
switch (column) {
case 0: result = this.nameColumnLabel;
break;
case 1: result = this.versionColumnLabel;
break;
case 2: result = this.licenceColumnLabel;
break;
case 3: result = this.infoColumnLabel;
break;
}
return result;
}
/**
* Returns the value for a cell in the table model.
*
* @param row the row index (zero-based).
* @param column the column index (zero-based).
*
* @return the value.
*/
public Object getValueAt(int row, int column) {
Object result = null;
Library library = (Library) libraries.get(row);
if (column == 0) {
result = library.getName();
}
else if (column == 1) {
result = library.getVersion();
}
else if (column == 2) {
result = library.getLicence();
}
else if (column == 3) {
result = library.getInfo();
}
return result;
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -