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

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

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

JTree.getPreferredSize介绍

暂无

代码示例

代码示例来源:origin: google/sagetv

public java.awt.Dimension getPreferredSize()
{
 java.awt.Dimension prefSize = super.getPreferredSize();
 return prefSize;
}

代码示例来源:origin: google/sagetv

public java.awt.Dimension getPreferredSize()
{
 java.awt.Dimension prefSize = super.getPreferredSize();
 return prefSize;
}

代码示例来源:origin: org.jacorb/jacorb

public Dimension getPreferredSize ()
{
 if (!created)
 {
   created = true;
   return size;
 }
 else
   return super.getPreferredSize ();
}

代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-bu

public Dimension getPreferredSize()
{
 Dimension r;
 try { r=super.getPreferredSize(); }
 catch(Exception ex) { r=new Dimension(120,80); }
 return r;
}

代码示例来源:origin: org.zaproxy/zap

@Override
public boolean getScrollableTracksViewportWidth() {
  int width = Math.max(sitesTree.getPreferredSize().width, contextsTree.getPreferredSize().width);
  return SwingUtilities.getUnwrappedParent(this).getWidth() > width;
}

代码示例来源:origin: org.zaproxy/zap

@Override
  public boolean getScrollableTracksViewportHeight() {
    return SwingUtilities.getUnwrappedParent(this)
        .getHeight() > (sitesTree.getPreferredSize().height + contextsTree.getPreferredSize().height);
  }
}

代码示例来源:origin: de.sciss/jtreetable

@Override
public Dimension getPreferredSize(JComponent c) {
  Dimension size = tree.getPreferredSize();
  size.width = table.getPreferredSize().width;
  return size;
}

代码示例来源:origin: MegaMek/megamek

@Override
  public void treeExpanded(TreeExpansionEvent arg0) {
    if (forceTree.getPreferredSize().getWidth() > paneForceTree.getSize().getWidth()) {
      rightPanel.setMinimumSize(new Dimension(forceTree.getMinimumSize().width, rightPanel.getMinimumSize().height));
      rightPanel.setPreferredSize(new Dimension(forceTree.getPreferredSize().width, rightPanel.getPreferredSize().height));
    }
    rightPanel.revalidate();
  }
});

代码示例来源:origin: org.codehaus.izpack/izpack-panel

public CheckBoxNodeRenderer(TreePacksPanel t)
{
  selectionForeground = UIManager.getColor("Tree.selectionForeground");
  selectionBackground = UIManager.getColor("Tree.selectionBackground");
  textForeground = UIManager.getColor("Tree.textForeground");
  textBackground = UIManager.getColor("Tree.textBackground");
  treePacksPanel = t;
  int treeWidth = t.getTree().getPreferredSize().width;
  int height = checkbox.getPreferredSize().height;
  int cellWidth = treeWidth - treeWidth / 4;
  //Don't touch, it fixes various layout bugs in swing/awt
  rendererPanel.setLayout(new BorderLayout(0, 0));
  rendererPanel.setBackground(textBackground);
  rendererPanel.add(BorderLayout.WEST, checkbox);
  rendererPanel.setAlignmentX((float) 0);
  rendererPanel.setAlignmentY((float) 0);
  rendererPanel.add(BorderLayout.EAST, packSizeLabel);
  rendererPanel.setMinimumSize(new Dimension(cellWidth, height));
  rendererPanel.setPreferredSize(new Dimension(cellWidth, height));
  rendererPanel.setSize(new Dimension(cellWidth, height));
  rendererPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
}

代码示例来源:origin: Vhati/Slipstream-Mod-Manager

treeScroll.setPreferredSize( new Dimension( pathTree.getPreferredSize().width, 300 ) );

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide

private void revalidateScrollBar() {
    if (!isDisplayable()) {
      return;
    }
    if (treeTable.getColumnModel().getColumnCount() > 0 && ((TreeTable)treeTable).getTreeColumnIndex() >= 0) {
      int extentWidth = treeTable.getColumnModel().getColumn(((TreeTable)treeTable).getTreeColumnIndex()).getWidth();
      int maxWidth = tree.getPreferredSize().width;
      int extentHeight = scrollPane.getViewport().getSize().height;
      int maxHeight = tree.getPreferredSize().height;
      int positionX = ((TreeTable)treeTable).getPositionX();
      int value = Math.max(0, Math.min(positionX, maxWidth - extentWidth));
      boolean hsbvisible = hScrollBar.isVisible();
      boolean vsbvisible = scrollPane.getVerticalScrollBar().isVisible();
      int hsbheight = hsbvisible ? hScrollBar.getHeight() : 0;
      int vsbwidth = scrollPane.getVerticalScrollBar().getWidth();
      hScrollBar.setValues(value, extentWidth, 0, maxWidth);
      if (hideHScrollBar || maxWidth <= extentWidth
        || (vsbvisible && (maxHeight <= extentHeight + hsbheight 
                  && maxWidth <= extentWidth + vsbwidth)))
        hScrollBar.setVisible(false);
      else
        hScrollBar.setVisible(true);
    }
  }
}

代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide

private void revalidateScrollBar() {
    if (!isDisplayable()) {
      return;
    }
    if (treeTable.getColumnModel().getColumnCount() > 0 && ((TreeTable)treeTable).getTreeColumnIndex() >= 0) {
      int extentWidth = treeTable.getColumnModel().getColumn(((TreeTable)treeTable).getTreeColumnIndex()).getWidth();
      int maxWidth = tree.getPreferredSize().width;
      int extentHeight = scrollPane.getViewport().getSize().height;
      int maxHeight = tree.getPreferredSize().height;
      int positionX = ((TreeTable)treeTable).getPositionX();
      int value = Math.max(0, Math.min(positionX, maxWidth - extentWidth));
      boolean hsbvisible = hScrollBar.isVisible();
      boolean vsbvisible = scrollPane.getVerticalScrollBar().isVisible();
      int hsbheight = hsbvisible ? hScrollBar.getHeight() : 0;
      int vsbwidth = scrollPane.getVerticalScrollBar().getWidth();
      hScrollBar.setValues(value, extentWidth, 0, maxWidth);
      if (hideHScrollBar || maxWidth <= extentWidth
        || (vsbvisible && (maxHeight <= extentHeight + hsbheight 
                  && maxWidth <= extentWidth + vsbwidth)))
        hScrollBar.setVisible(false);
      else
        hScrollBar.setVisible(true);
    }
  }
}

代码示例来源:origin: org.netbeans.api/org-openide-explorer

int extentWidth = treeTable.getColumnModel().getColumn(((TreeTable) treeTable).getTreeColumnIndex())
              .getWidth();
int maxWidth = tree.getPreferredSize().width;
int extentHeight = scrollPane.getViewport().getSize().height;
int maxHeight = tree.getPreferredSize().height;
int positionX = ((TreeTable) treeTable).getPositionX();

代码示例来源:origin: org.bitbucket.goalhub.simpleide/jedit

selectPane(rootNode,null);
splitter.setDividerLocation(paneTree.getPreferredSize().width
  + scroller.getVerticalScrollBar().getPreferredSize()
  .width);

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-php-editor

/** Creates new form FmtSpaces */
private FmtSpaces() {
  initComponents();
  jScrollPane1.getVerticalScrollBar().setUnitIncrement(20);
  model = createModel();
  cfgTree.setModel(model);
  cfgTree.setRootVisible(false);
  cfgTree.setShowsRootHandles(true);
  cfgTree.setCellRenderer(this);
  cfgTree.setEditable(false);
  cfgTree.addMouseListener(this);
  cfgTree.addKeyListener(this);
  dr.setIcon(null);
  dr.setOpenIcon(null);
  dr.setClosedIcon(null);
  DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot();
  for (int i = root.getChildCount(); i >= 0; i--) {
    cfgTree.expandRow(i);
  }
  Dimension dimension = new Dimension((int) cfgTree.getPreferredSize().getWidth() + Utils.POSSIBLE_SCROLL_BAR_WIDTH, (int) jScrollPane1.getMinimumSize().getHeight());
  jScrollPane1.setMinimumSize(dimension);
}

相关文章

JTree类方法