本文整理了Java中javax.swing.JTree.getSelectionRows()
方法的一些代码示例,展示了JTree.getSelectionRows()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTree.getSelectionRows()
方法的具体详情如下:
包路径:javax.swing.JTree
类名称:JTree
方法名:getSelectionRows
暂无
代码示例来源:origin: stackoverflow.com
JTree tree = (JTree)support.getComponent();
int dropRow = tree.getRowForPath(dl.getPath());
int[] selRows = tree.getSelectionRows();
for(int i = 0; i < selRows.length; i++) {
if(selRows[i] == dropRow) {
int[] selRows = tree.getSelectionRows();
TreePath path = tree.getPathForRow(selRows[0]);
DefaultMutableTreeNode first =
代码示例来源:origin: org.swinglabs.swingx/swingx-core
/**
* {@inheritDoc}
* <p>
*
* Overridden to always return a not-null array (following SwingX
* convention).
*/
@Override
public int[] getSelectionRows() {
int[] rows = super.getSelectionRows();
return rows != null ? rows : EMPTY_INT_ARRAY;
}
代码示例来源:origin: org.bidib.jbidib.swinglabs.swingx/swingx-core
/**
* {@inheritDoc}
* <p>
*
* Overridden to always return a not-null array (following SwingX
* convention).
*/
@Override
public int[] getSelectionRows() {
int[] rows = super.getSelectionRows();
return rows != null ? rows : EMPTY_INT_ARRAY;
}
代码示例来源:origin: org.codehaus.jtstand/jtstand-desktop
/**
* {@inheritDoc}
* <p>
*
* Overridden to always return a not-null array (following SwingX
* convention).
*/
@Override
public int[] getSelectionRows() {
int[] rows = super.getSelectionRows();
return rows != null ? rows : EMPTY_INT_ARRAY;
}
代码示例来源:origin: com.haulmont.thirdparty/swingx-core
/**
* {@inheritDoc}
* <p>
*
* Overridden to always return a not-null array (following SwingX
* convention).
*/
@Override
public int[] getSelectionRows() {
int[] rows = super.getSelectionRows();
return rows != null ? rows : EMPTY_INT_ARRAY;
}
代码示例来源:origin: org.swinglabs.swingx/swingx-all
/**
* {@inheritDoc}
* <p>
*
* Overridden to always return a not-null array (following SwingX
* convention).
*/
@Override
public int[] getSelectionRows() {
int[] rows = super.getSelectionRows();
return rows != null ? rows : EMPTY_INT_ARRAY;
}
代码示例来源:origin: UNIVALI-LITE/Portugol-Studio
@Override
public void actionPerformed(ActionEvent e) {
int row = arvoreExemplos.getSelectionRows()[0];
arvoreExemplos.setSelectionRow(Math.max(0,row-1));
}
};
代码示例来源:origin: UNIVALI-LITE/Portugol-Studio
@Override
public void actionPerformed(ActionEvent e) {
int row = arvoreExemplos.getSelectionRows()[0];
arvoreExemplos.setSelectionRow(Math.min(row+1, arvoreExemplos.getRowCount()-1));
}
};
代码示例来源:origin: joel-costigliola/assertj-swing
@RunsInCurrentThread
private static void checkSelection(@Nonnull JTree tree, @Nonnull int[] selection, @Nonnull Description errMsg) {
int[] selectionRows = tree.getSelectionRows();
if (selectionRows == null || selectionRows.length == 0) {
failNoSelection(errMsg);
return;
}
sort(selection);
if (Arrays.equals(selectionRows, selection)) {
return;
}
failNotEqualSelection(errMsg, selection, selectionRows);
}
代码示例来源:origin: org.gosu-lang.gosu/gosu-lab
@Override
public void actionPerformed( ActionEvent e )
{
int[] selectionRows = _tree.getSelectionRows();
if( selectionRows != null )
{
int selectionRow = selectionRows[0];
selectionRow = Math.max( 0, selectionRow - 10 );
_tree.setSelectionRow( selectionRow );
_tree.scrollRowToVisible( selectionRow );
}
}
} );
代码示例来源:origin: org.gosu-lang.gosu/gosu-editor
@Override
public void actionPerformed( ActionEvent e )
{
int[] selectionRows = _tree.getSelectionRows();
if( selectionRows != null )
{
int selectionRow = selectionRows[0];
selectionRow = Math.max( 0, selectionRow - 10 );
_tree.setSelectionRow( selectionRow );
_tree.scrollRowToVisible( selectionRow );
}
}
} );
代码示例来源:origin: robward-scisys/sldeditor
@Override
public void textUpdated() {
int[] selectedRows = symbolTree.getSelectionRows();
populateSLD();
symbolTree.setSelectionRows(selectedRows);
}
代码示例来源:origin: UNIVALI-LITE/Portugol-Studio
@Override
public void keyReleased(KeyEvent e)
{
if(e.getKeyCode() == KeyEvent.VK_ENTER){
int selectedRow = arvore.getSelectionRows()[0];
if(arvore.isCollapsed(selectedRow)){
arvore.expandRow(selectedRow);
}else{
arvore.collapseRow(selectedRow);
}
}
}
代码示例来源:origin: org.gosu-lang.gosu/gosu-lab
@Override
public void actionPerformed( ActionEvent e )
{
int[] selectionRows = _tree.getSelectionRows();
if( selectionRows != null )
{
int selectionRow = selectionRows[0];
selectionRow = Math.min( _tree.getRowCount() - 1, selectionRow + 10 );
_tree.setSelectionRow( selectionRow );
_tree.scrollRowToVisible( selectionRow );
}
}
} );
代码示例来源:origin: org.gosu-lang.gosu/gosu-editor
@Override
public void actionPerformed( ActionEvent e )
{
int[] selectionRows = _tree.getSelectionRows();
if( selectionRows != null )
{
int selectionRow = selectionRows[0];
selectionRow = Math.min( _tree.getRowCount() - 1, selectionRow + 10 );
_tree.setSelectionRow( selectionRow );
_tree.scrollRowToVisible( selectionRow );
}
}
} );
代码示例来源:origin: com.jidesoft/jide-oss
@Override
protected int getSelectedIndex() {
if (!isRecursive()) {
int ai[] = ((JTree) _component).getSelectionRows();
return (ai != null && ai.length != 0) ? ai[0] : -1;
}
else {
TreePath[] treePaths = ((JTree) _component).getSelectionPaths();
if (treePaths != null && treePaths.length > 0) {
return getTreePathes().indexOf(treePaths[0]);
}
else
return -1;
}
}
代码示例来源:origin: org.netbeans.api/org-openide-explorer
@Override
public void showPopup(MouseEvent mevt) {
if (isPopupAllowed()) {
if (mevt.getY() > treeTable.getHeight()) {
// clear selection, if click under the table
treeTable.clearSelection();
} else {
int selRow = treeTable.rowAtPoint( mevt.getPoint() );
boolean isAlreadySelected = false;
int[] currentSelection = tree.getSelectionRows();
for( int i=0; null != currentSelection && i<currentSelection.length; i++ ) {
if( selRow == currentSelection[i] ) {
isAlreadySelected = true;
break;
}
}
if( !isAlreadySelected )
tree.setSelectionRow( selRow );
}
createPopup(mevt);
}
}
};
代码示例来源:origin: cpesch/RouteConverter
private void handleCategoryTreeUpdate() {
int[] selectedRows = treeCategories.getSelectionRows();
boolean existsASelectedCategory = selectedRows != null && selectedRows.length > 0;
ActionManager actionManager = Application.getInstance().getContext().getActionManager();
actionManager.enable("delete-category", existsASelectedCategory);
actionManager.enableLocal("delete", CATEGORIES, existsASelectedCategory);
}
代码示例来源:origin: robward-scisys/sldeditor
/**
* Repopulate tree for a undo/redo operation.
*
* @param sldContents the sld contents
*/
private void repopulateTree(String sldContents) {
int[] selectedRows = symbolTree.getSelectionRows();
SLDDataInterface sldData = new SLDData(null, sldContents);
StyledLayerDescriptor sld = SLDUtils.createSLDFromString(sldData);
SelectedSymbol.getInstance().setSld(sld);
populateSLD();
if ((selectedRows != null) && (selectedRows.length > 0)) {
symbolTree.setSelectionRow(selectedRows[0]);
}
}
代码示例来源:origin: MegaMek/mekhq
@Override
public void actionPerformed(ActionEvent action) {
String command = action.getActionCommand();
if (command.equalsIgnoreCase("CONFIG_BOT")) {
PrincessBehaviorDialog pbd = new PrincessBehaviorDialog(frame,
scenario.getBotForce(index).getBehaviorSettings(),
scenario.getBotForce(index).getName());
pbd.setVisible(true);
if (!pbd.dialogAborted) {
scenario.getBotForce(index).setBehaviorSettings(pbd.getBehaviorSettings());
scenario.getBotForce(index).setName(pbd.getBotName());
}
} else if (command.equalsIgnoreCase("EDIT_UNIT")) {
if (tree.getSelectionCount() > 0) {
// row 0 is root node
int i = tree.getSelectionRows()[0] - 1;
UnitEditorDialog med = new UnitEditorDialog(frame,
scenario.getBotForce(index).getEntityList().get(i));
med.setVisible(true);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!