當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。