javax.swing.JTree.setVisibleRowCount()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(10.0k)|赞(0)|评价(0)|浏览(175)

本文整理了Java中javax.swing.JTree.setVisibleRowCount()方法的一些代码示例,展示了JTree.setVisibleRowCount()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTree.setVisibleRowCount()方法的具体详情如下:
包路径:javax.swing.JTree
类名称:JTree
方法名:setVisibleRowCount

JTree.setVisibleRowCount介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

tree.setVisibleRowCount(6);
container.add(new JScrollPane(tree), BorderLayout.WEST);

代码示例来源:origin: stackoverflow.com

tree.setVisibleRowCount(10);
for (int ii = tree.getRowCount(); ii>-1; ii--) {
  tree.expandRow(ii);

代码示例来源:origin: stackoverflow.com

import javax.swing.*;

class ShowTree {

  public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
      public void run() {
        JTree tree = new JTree();
        tree.setVisibleRowCount(10);
        JOptionPane.showMessageDialog(
          null,
          new JScrollPane(tree));
      }
    });
  }
}

代码示例来源:origin: stackoverflow.com

import java.awt.Rectangle;
import javax.swing.*;
import javax.swing.tree.DefaultMutableTreeNode;

public class TestViewPort {
  public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable(){
      public void run() {
        DefaultMutableTreeNode root = new DefaultMutableTreeNode("Root");
        for (int i = 0; i < 100; i++) {
          root.add(new DefaultMutableTreeNode(Integer.toString(i)));
        }
        JTree tree = new JTree(root);
        tree.setVisibleRowCount(10);
        JScrollPane pane = new JScrollPane();
        pane.setViewportView(tree);
        int y = tree.getPreferredSize().height;
        pane.getViewport().scrollRectToVisible(new Rectangle(0, y, 0, 0));
        JOptionPane.showMessageDialog(null, pane);
      }  
    });
  }
}

代码示例来源:origin: stackoverflow.com

tree.setVisibleRowCount(4);
gui.add(new JScrollPane(tree));
gui.setBackground(Color.BLUE);

代码示例来源:origin: stackoverflow.com

JTree tree = new JTree();
tree.getSelectionModel().setSelectionMode(selectionMode);
tree.setVisibleRowCount(8);
SelectableTreeCellRenderer renderer =
  new SelectableTreeCellRenderer();

代码示例来源:origin: org.gosu-lang.gosu/gosu-lab

private JScrollPane makeResultPane()
{
 _varTree = new JTree( makeEmptyModel() );
 _varTree.setBorder( null );
 _varTree.setBackground( Scheme.active().getWindow() );
 _varTree.setRootVisible( true );
 _varTree.setShowsRootHandles( true );
 _varTree.setRowHeight( 22 );
 _varTree.getSelectionModel().setSelectionMode( TreeSelectionModel.SINGLE_TREE_SELECTION );
 _varTree.setVisibleRowCount( 20 );
 _varTree.setCellRenderer( new VarTreeCellRenderer( _varTree ) );
 return new JScrollPane( _varTree );
}

代码示例来源:origin: GoldenGnu/jeveassets

private DefaultMutableTreeNode add(final CheckBoxNode checkBoxNode, final DefaultMutableTreeNode parentNode) {
  jTree.setVisibleRowCount(jTree.getVisibleRowCount() + 1);
  DefaultMutableTreeNode node = new DefaultMutableTreeNode(checkBoxNode);
  if (parentNode == null) {
    treeModel.insertNodeInto(node, rootNode, rootNode.getChildCount());
  } else {
    treeModel.insertNodeInto(node, parentNode, parentNode.getChildCount());
  }
  return node;
}

代码示例来源:origin: stackoverflow.com

p.add(find, BorderLayout.PAGE_START);
tree.setVisibleRowCount(8);
for (int row=tree.getRowCount(); row>=0; row--) {
  tree.expandRow(row);

代码示例来源:origin: edu.illinois.lis/indri

docQueryTree = new JTree(top);
docQueryTree.addTreeSelectionListener(new QueryTreeListener());
docQueryTree.setVisibleRowCount(8);
JScrollPane treeView = new JScrollPane(docQueryTree);
treeView.setDoubleBuffered(true);

代码示例来源:origin: GoldenGnu/jeveassets

private boolean show(Map<String, CheckBoxNode> nodes, boolean selected) {
  save = false;
  rootNode.removeAllChildren();
  treeModel.reload();
  jTree.setVisibleRowCount(0);
  jNewSelected.setVisible(selected);
  Map<String, CheckBoxNode> cloneList = cloneList(nodes);
  Map<String, DefaultMutableTreeNode> cache = new HashMap<String, DefaultMutableTreeNode>();
  for (CheckBoxNode node : cloneList.values()) {
    addTree(cache, node);
  }
  expandAll(new TreePath((rootNode)), true);
  super.setVisible(true);
  boolean changed = changed(cloneList, nodes); //Only need to update if something have been changed...
  if (save && changed) {
    nodes.clear();
    nodes.putAll(cloneList);
  }
  return save && changed;
}

代码示例来源:origin: org.gosu-lang.gosu/gosu-lab

private JComponent makeTreePanel()
{
 DefaultTreeModel model = new DefaultTreeModel( makeSettingsTree() );
 _tree = new JTree( model );
 _tree.setBackground( Scheme.active().getWindow() );
 _tree.setRootVisible( false );
 _tree.setShowsRootHandles( true );
 _tree.setRowHeight( 22 );
 _tree.getSelectionModel().setSelectionMode( TreeSelectionModel.SINGLE_TREE_SELECTION );
 _tree.setVisibleRowCount( 20 );
 _tree.setCellRenderer( new SettingsTreeCellRenderer( _tree ) );
 _tree.addTreeSelectionListener( new SelectionHandler() );
 JScrollPane scroller = new JScrollPane( _tree );
 scroller.setBorder( BorderFactory.createEmptyBorder() );
 expandAll();
 selectMruSettings();
 TabPane tabPane = new TabPane( TabPosition.TOP, TabPane.MIN_MAX_REST );
 tabPane.addTab( "Settings", null, scroller );
 return tabPane;
}

代码示例来源:origin: GoldenGnu/jeveassets

jTree.setVisibleRowCount(35);
} else {
  jTree.setVisibleRowCount(cloneList.size());

代码示例来源:origin: GoldenGnu/jeveassets

private void add(final JSettingsPanel jSettingsPanel, final DefaultMutableTreeNode parentNode) {
  settingsPanels.put(jSettingsPanel.getTitle(), jSettingsPanel);
  icons.put(jSettingsPanel.getTitle(), jSettingsPanel.getIcon());
  jContent.add(jSettingsPanel.getPanel(), jSettingsPanel.getTitle());
  jTree.setVisibleRowCount(jTree.getVisibleRowCount() + 1);
  DefaultMutableTreeNode node = new DefaultMutableTreeNode(jSettingsPanel.getTitle());
  if (parentNode == null) {
    treeModel.insertNodeInto(node, rootNode, rootNode.getChildCount());
  } else {
    treeModel.insertNodeInto(node, parentNode, parentNode.getChildCount());
  }
  jSettingsPanel.setTreeNode(node);
}

代码示例来源:origin: org.gosu-lang.gosu/gosu-lab

private JComponent makeTreePanel()
{
 DefaultTreeModel model = new DefaultTreeModel( makeRunConfigTree() );
 _tree = new JTree( model );
 _tree.setBackground( Scheme.active().getWindow() );
 _tree.setRootVisible( false );
 _tree.setShowsRootHandles( true );
 _tree.setRowHeight( 22 );
 _tree.getSelectionModel().setSelectionMode( TreeSelectionModel.SINGLE_TREE_SELECTION );
 _tree.setVisibleRowCount( 20 );
 _tree.setCellRenderer( new RunConfigTreeCellRenderer( _tree ) );
 _tree.addTreeSelectionListener( new SelectionHandler() );
 JScrollPane scroller = new JScrollPane( _tree );
 scroller.setBorder( BorderFactory.createEmptyBorder() );
 expandAll();
 selectMruRunConfig();
 TabPane tabPane = new TabPane( TabPosition.TOP, TabPane.MIN_MAX_REST );
 tabPane.addTab( "Configurations", null, scroller );
 ToolContainer toolbar = tabPane.getToolContainer();
 addTools( toolbar.getToolBar() );
 return tabPane;
}

代码示例来源:origin: org.gosu-lang.gosu/gosu-editor

public void load( Project project )
{
 _splitPane.clearTop();
 _project = project;
 DefaultTreeModel model = new DefaultTreeModel( new FileTree( getProject() ) );
 _tree = new JTree( model );
 _tree.setBackground( EditorUtilities.WINDOW );
 _tree.setShowsRootHandles( true );
 _tree.setRowHeight( 22 );
 _tree.getSelectionModel().setSelectionMode( TreeSelectionModel.SINGLE_TREE_SELECTION );
 _tree.setVisibleRowCount( 20 );
 _tree.setCellRenderer( new FileTreeCellRenderer( _tree ) );
 _tree.addMouseListener( new TreeMouseHandler() );
 _tree.addKeyListener( new TreeKeyHankder() );
 _scroller = new JScrollPane( _tree );
 _scroller.setBorder( new MatteBorder( 0, 0, 1, 1, EditorUtilities.CONTROL_SHADOW ) );
 expandToFirstSourcePath( 0, _tree.getRowCount() );
 _splitPane.setTop( _scroller );
 revalidate();
}

代码示例来源:origin: org.gosu-lang.gosu/gosu-lab

private TabPane makeFramePane()
{
 _varTree = new JTree( new DefaultTreeModel( new VarTree( null ) ) );
 _varTree.setBorder( null );
 _varTree.setBackground( Scheme.active().getWindow() );
 _varTree.setRootVisible( false );
 _varTree.setShowsRootHandles( true );
 _varTree.setRowHeight( 22 );
 _varTree.getSelectionModel().setSelectionMode( TreeSelectionModel.SINGLE_TREE_SELECTION );
 _varTree.setVisibleRowCount( 20 );
 _varTree.setCellRenderer( new VarTreeCellRenderer( _varTree ) );
 JScrollPane scroller = new JScrollPane( _varTree );
 scroller.setBorder( null );
 TabPane varTabPane = new TabPane( TabPosition.TOP, TabPane.MIN_MAX_REST );
 varTabPane.addTab( "Frame", EditorUtilities.loadIcon( "images/single_frame.png" ), scroller );
 ToolContainer toolbar = varTabPane.getToolContainer();
 addTools( toolbar.getToolBar() );
 return varTabPane;
}

代码示例来源:origin: org.gosu-lang.gosu/gosu-lab

private void configUi()
{
 _tree = new JTree();
 _tree.setModel( new DefaultTreeModel( new MessageTree( _tree ) ) );
 _tree.setBackground( Scheme.active().getWindow() );
 _tree.setRootVisible( false );
 _tree.setShowsRootHandles( true );
 _tree.setRowHeight( 22 );
 _tree.getSelectionModel().setSelectionMode( TreeSelectionModel.SINGLE_TREE_SELECTION );
 _tree.setVisibleRowCount( 20 );
 _tree.setCellRenderer( new LabTreeCellRenderer( _tree ) );
 _tree.addMouseListener( new MouseHandler() );
 _tree.addKeyListener( new TreeKeyHandler() );
 _scroller = new JScrollPane( _tree );
 _scroller.setBorder( new MatteBorder( 0, 1, 1, 1, Scheme.active().getScrollbarBorderColor() ) );
 add( _scroller, BorderLayout.CENTER );
}

代码示例来源:origin: org.gosu-lang.gosu/gosu-lab

public void load( Experiment experiment )
{
 _splitPane.clearTop();
 _experiment = experiment;
 DefaultTreeModel model = new DefaultTreeModel( new FileTree( getExperiment() ) );
 _tree = new JTree( model );
 _tree.setBackground( Scheme.active().getWindow() );
 _tree.setShowsRootHandles( true );
 _tree.setRowHeight( 22 );
 _tree.getSelectionModel().setSelectionMode( TreeSelectionModel.SINGLE_TREE_SELECTION );
 _tree.setVisibleRowCount( 20 );
 _tree.setCellRenderer( new FileTreeCellRenderer( _tree ) );
 _tree.addMouseListener( new TreeMouseHandler() );
 _tree.addKeyListener( new TreeKeyHandler() );
 _scroller = new JScrollPane( _tree );
 _scroller.setBorder( new MatteBorder( 0, 0, 1, 1, Scheme.active().getScrollbarBorderColor() ) );
 //expandToFirstSourcePath( 0, _tree.getRowCount() );
 expandFirstPath();
 _splitPane.setTop( _scroller );
 revalidate();
}

代码示例来源:origin: org.gosu-lang.gosu/gosu-lab

private void configUi()
{
 _tree = new JTree();
 _tree.setModel( new DefaultTreeModel( new SearchTree( _tree ) ) );
 _tree.setBackground( Scheme.active().getWindow() );
 _tree.setRootVisible( false );
 _tree.setShowsRootHandles( true );
 _tree.setRowHeight( 22 );
 _tree.getSelectionModel().setSelectionMode( TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION );
 _tree.setVisibleRowCount( 20 );
 _tree.setCellRenderer( new LabTreeCellRenderer( _tree ) );
 _tree.addMouseListener( new MouseHandler() );
 _tree.addKeyListener( new TreeKeyHandler() );
 _tree.addTreeSelectionListener( new TreeSelectionHandler() );
 JScrollPane scroller = new JScrollPane( _tree );
 scroller.setBorder( new MatteBorder( 0, 1, 1, 1, Scheme.active().getScrollbarBorderColor() ) );
 add( scroller, BorderLayout.CENTER );
 add( makeToolbar(), BorderLayout.WEST );
 addReplaceButtonsPanel();
}

相关文章

JTree类方法