本文整理匯總了Java中org.jdesktop.swingx.JXTable.getModel方法的典型用法代碼示例。如果您正苦於以下問題:Java JXTable.getModel方法的具體用法?Java JXTable.getModel怎麽用?Java JXTable.getModel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.jdesktop.swingx.JXTable
的用法示例。
在下文中一共展示了JXTable.getModel方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: interactiveTableSortComparableAndStringValue
import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
* Issue #1156-swingx: sort must use comparable
*
* visually check that the custom string value for the color column is
* used for sorting.
*/
public void interactiveTableSortComparableAndStringValue() {
JXTable table = new JXTable(new AncientSwingTeam());
table.setDefaultRenderer(Color.class, new DefaultTableRenderer(sv));
JTable core = new JTable(table.getModel());
core.setAutoCreateRowSorter(true);
JXFrame frame = wrapWithScrollingInFrame(table, core, "JXTable <--> JTable: Compare sorting of color column");
show(frame);
}
示例2: exportToCSV
import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
* Static function for exporting a JXTable to a CSV text file
*
* @param table - table to export
* @param file - file to export to
*/
public static void exportToCSV(JXTable table, File file) {
int i = 0;
int j = 0;
try
{
TableModel model = table.getModel();
FileWriter csv = new FileWriter(file);
for (i = 0; i < model.getColumnCount(); i++)
{
csv.write(model.getColumnName(i) + ",");
}
csv.write(System.getProperty("line.separator"));
for (i = 0; i < model.getRowCount(); i++)
{
for (j = 0; j < (model.getColumnCount()); j++)
{
if (model.getValueAt(i, j) == null)
{
csv.write("" + ",");
}
else
{
csv.write(model.getValueAt(i, j).toString() + ",");
}
}
csv.write(System.getProperty("line.separator"));
}
csv.close();
}
catch (IOException e)
{
JOptionPane.showMessageDialog(App.mainFrame, "Error saving file '" + file.getName() + "'\n" + e.getLocalizedMessage());
e.printStackTrace();
}
}
示例3: getTableModel
import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
public static <T extends AbstractTableModel> T getTableModel(JXTable pTable) {
return (T) pTable.getModel();
}
示例4: interactiveCheckBoxEditorSelectBackground
import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
* Issue #??-swingx: first click in unselected (in terms of
* listSelection, not checkBox) checkbox does not change
* the editor background to selected.
*
* Suspected culprit is the editor: the click starts the
* edit, but doesn't update the background of the editor
* itself. Once selected, the editor will be selected as well.
*
* Core issue: Problem is that at the time of getting the
* editing component, the row is not yet selected. Based on
* shouldSelectedCell, the table's row selection is updated
* _after_ installing the editing component.
*
* Options:
* - override changeSelection to special case the editing comp
* - tweak the editor to config the renderer with isSelected == true
* (or with shouldSelect)
*
*/
public void interactiveCheckBoxEditorSelectBackground() {
JXTable table = new JXTable(new AncientSwingTeam());
JTable core = new JTable(table.getModel());
JComponent comp = Box.createHorizontalBox();
comp.add(new JScrollPane(table));
comp.add(new JScrollPane(core));
showInFrame(comp, "compare checkbox editor x <-> core");
}