java jlistview_介绍JComponentPack产品中的JListView控件

昌山
2023-12-01

If you want to implements the Windows explorer like feature in Java swing application, the

The JListView.setViewMode” can change the view mode of

The Introduce Cell Renderer” introduce why using the

The

JListView.getSelectedValue(); // get the lead selection value

JListView.getSelectedValues(); // get all selected values

The JListView.isEditing(); // determines whether the JListView.cancelEditing(); // cancel current editing

JListView.stopEditing(); // stop the current editing and apply the editing value

JListView.startEditingAtIndex(); // start the editing at the specified index

JListview.getEditingInex(); // get the current editing object’s index

The com.zfqjava.swing.model and

JListView listView = new JListView();

listView.setListData(new FileTableModel(new File(System.getProperty("user.home"))));

listView.setCellRenderer(new FileCellRenderer());

listView.setCellEditor(new FileCellEditor());

The ColumnSorter interface, it can support the row sorting automatically, we want to improve this area after upgrade the JRE version to 1.6.

The

“JListView.rowSelectionAllowed” allow the full row can be selected

“JListView.showVerticalLines” shows the vertical lines in details view mode.

“JListView.showHorizontalLines” shows the horizontal lines in details view mode.

“JListView.backgroundImage” sets the background image for

For details, you can view the

The JComponentPack 1.1.0 and early version, implements this feature has trick and tips:

// get JTable and JList

BasicListViewUI ui = (BasicListViewUI)listView.getUI();

JTable table = ui.getTable();

JList list = ui.getList();

table.setDragEnabled(true);

list.setDragEnabled(true);

TransferHandler th = new TransferHandler() {

public int getSourceActions(JComponent c) {

return COPY;

}

protected Transferable createTransferable(JComponent c) {

// just a test

Object o = listView.getSelectedValue();

if(o != null) {

return new StringSelection(o.toString());

}

return null;

}

};

table.setTransferHandler(th);

list.setTransferHandler(th);

In the upcoming version JComponentPack 1.2.0, we have improved this area, so in the new version, implements the drag and drop feature is very simple:

listView.setDragEnabled(true);

TransferHandler th = new TransferHandler() {

public int getSourceActions(JComponent c) {

return COPY;

}

protected Transferable createTransferable(JComponent c) {

// just a test

Object o = listView.getSelectedValue();

if(o != null) {

return new StringSelection(o.toString());

}

return null;

}

};

listView. setTransferHandler(th);

The JListView.setViewMode” can change the view mode of

The Introduce Cell Renderer” introduce why using the

The

JListView.getSelectedValue(); // get the lead selection value

JListView.getSelectedValues(); // get all selected values

The JListView.isEditing(); // determines whether the JListView.cancelEditing(); // cancel current editing

JListView.stopEditing(); // stop the current editing and apply the editing value

JListView.startEditingAtIndex(); // start the editing at the specified index

JListview.getEditingInex(); // get the current editing object’s index

The com.zfqjava.swing.model and

JListView listView = new JListView();

listView.setListData(new FileTableModel(new File(System.getProperty("user.home"))));

listView.setCellRenderer(new FileCellRenderer());

listView.setCellEditor(new FileCellEditor());

The ColumnSorter interface, it can support the row sorting automatically, we want to improve this area after upgrade the JRE version to 1.6.

The

“JListView.rowSelectionAllowed” allow the full row can be selected

“JListView.showVerticalLines” shows the vertical lines in details view mode.

“JListView.showHorizontalLines” shows the horizontal lines in details view mode.

“JListView.backgroundImage” sets the background image for

For details, you can view the

The JComponentPack 1.1.0 and early version, implements this feature has trick and tips:

// get JTable and JList

BasicListViewUI ui = (BasicListViewUI)listView.getUI();

JTable table = ui.getTable();

JList list = ui.getList();

table.setDragEnabled(true);

list.setDragEnabled(true);

TransferHandler th = new TransferHandler() {

public int getSourceActions(JComponent c) {

return COPY;

}

protected Transferable createTransferable(JComponent c) {

// just a test

Object o = listView.getSelectedValue();

if(o != null) {

return new StringSelection(o.toString());

}

return null;

}

};

table.setTransferHandler(th);

list.setTransferHandler(th);

In the upcoming version JComponentPack 1.2.0, we have improved this area, so in the new version, implements the drag and drop feature is very simple:

listView.setDragEnabled(true);

TransferHandler th = new TransferHandler() {

public int getSourceActions(JComponent c) {

return COPY;

}

protected Transferable createTransferable(JComponent c) {

// just a test

Object o = listView.getSelectedValue();

if(o != null) {

return new StringSelection(o.toString());

}

return null;

}

};

listView. setTransferHandler(th);

posted on 2009-02-25 10:56 fralepg 阅读(450) 评论(0)  编辑  收藏

 类似资料: