当前位置: 首页>>代码示例>>Java>>正文


Java JScrollPane.getPreferredSize方法代码示例

本文整理汇总了Java中javax.swing.JScrollPane.getPreferredSize方法的典型用法代码示例。如果您正苦于以下问题:Java JScrollPane.getPreferredSize方法的具体用法?Java JScrollPane.getPreferredSize怎么用?Java JScrollPane.getPreferredSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JScrollPane的用法示例。


在下文中一共展示了JScrollPane.getPreferredSize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: showDialog

import javax.swing.JScrollPane; //导入方法依赖的package包/类
/** Shows the content of this table as a dialog. */
public void showDialog(Component parent) {
    JScrollPane scrollPane = new JScrollPane(this);
    Dimension size = scrollPane.getPreferredSize();
    size.height = getPreferredSize().height;
    scrollPane.getViewport().setPreferredSize(size);
    JOptionPane optionPane = new JOptionPane(scrollPane, JOptionPane.PLAIN_MESSAGE);
    JDialog dialog = optionPane.createDialog(parent, "External libraries used in GROOVE");
    dialog.setVisible(true);
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:11,代码来源:LibrariesTable.java

示例2: adjustScrollPaneSize

import javax.swing.JScrollPane; //导入方法依赖的package包/类
private static void adjustScrollPaneSize(JScrollPane sp, JEditorPane editorPane) {
    int height;
    //logger.fine("createSingleLineEditor(): editorPane's margin = "+editorPane.getMargin());
    //logger.fine("createSingleLineEditor(): editorPane's insets = "+editorPane.getInsets());
    Dimension prefSize = sp.getPreferredSize();
    Insets borderInsets = sp.getBorder().getBorderInsets(sp);//sp.getInsets();
    int vBorder = borderInsets.bottom + borderInsets.top;
    EditorUI eui = org.netbeans.editor.Utilities.getEditorUI(editorPane);
    if (logger.isLoggable(Level.FINE)) {
        logger.fine("createSingleLineEditor(): editor UI = "+eui);
        if (eui != null) {
            logger.fine("createSingleLineEditor(): editor UI's line height = "+eui.getLineHeight());
            logger.fine("createSingleLineEditor(): editor UI's line ascent = "+eui.getLineAscent());
        }
    }
    if (eui != null) {
        height = eui.getLineHeight();
        if (height < eui.getLineAscent()) {
            height = (eui.getLineAscent()*4)/3; // Hack for the case when line height = 1
        }
    } else {
        java.awt.Font font = editorPane.getFont();
        java.awt.FontMetrics fontMetrics = editorPane.getFontMetrics(font);
        height = fontMetrics.getHeight();
        //logger.fine("createSingleLineEditor(): editor's font = "+font+" with metrics = "+fontMetrics+", leading = "+fontMetrics.getLeading());
        //logger.fine("createSingleLineEditor(): font's height = "+height);
    }
    height += vBorder + getLFHeightAdjustment();
    //height += 2; // 2 for border
    if (logger.isLoggable(Level.FINE)) {
        logger.fine("createSingleLineEditor(): border vertical insets = "+borderInsets.bottom+" + "+borderInsets.top);
        logger.fine("createSingleLineEditor(): computed height = "+height+", prefSize = "+prefSize);
    }
    if (prefSize.height < height) {
        prefSize.height = height;
        sp.setPreferredSize(prefSize);
        sp.setMinimumSize(prefSize);
        sp.setMaximumSize(prefSize);
        java.awt.Container c = sp.getParent();
        logger.fine("createSingleLineEditor(): setting a new height of ScrollPane = "+height);
        if (c instanceof JComponent) {
            ((JComponent) c).revalidate();
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:46,代码来源:Utilities.java


注:本文中的javax.swing.JScrollPane.getPreferredSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。