本文整理汇总了Java中javax.swing.JScrollPane.setMaximumSize方法的典型用法代码示例。如果您正苦于以下问题:Java JScrollPane.setMaximumSize方法的具体用法?Java JScrollPane.setMaximumSize怎么用?Java JScrollPane.setMaximumSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JScrollPane
的用法示例。
在下文中一共展示了JScrollPane.setMaximumSize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateScrollPane
import javax.swing.JScrollPane; //导入方法依赖的package包/类
public JScrollPane generateScrollPane()
{
JScrollPane newScroll = new JScrollPane();
JList list = new JList(listModel);
list.setFont( new Font("monospaced", Font.PLAIN, 12) );
newScroll.setViewportView(list);
Dimension listSize = new Dimension(400, 150);
newScroll.setSize(listSize);
newScroll.setMaximumSize(listSize);
newScroll.setPreferredSize(listSize);
newScroll.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() {
public void adjustmentValueChanged(AdjustmentEvent e) {
e.getAdjustable().setValue(e.getAdjustable().getMaximum());
}
});
return newScroll;
}
示例2: buildImage
import javax.swing.JScrollPane; //导入方法依赖的package包/类
/**
* Builds the image component
*
* @return JComponent
*/
private JComponent buildImage() {
scrollPane = new JScrollPane(new ImageContainer());
scrollPane.setMaximumSize(VISNode.get().getMainPanel().getSize());
return scrollPane;
}
示例3: 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();
}
}
}