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


Java Component.setMaximumSize方法代码示例

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


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

示例1: getListCellRendererComponent

import java.awt.Component; //导入方法依赖的package包/类
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
    FormatInfo info = (FormatInfo)value;
    Component comp = delegate.getListCellRendererComponent(list, info.getDisplayName(), index, isSelected, cellHasFocus);
    if (comp instanceof JComponent) {
        JComponent jcomp = (JComponent)comp;
        Border border = jcomp.getBorder();
        if ((border != null) && (border.getBorderInsets(panel) != null)) { // Issue 161997
            panel.setBorder(border);
        } else {
            panel.setBorder(BorderFactory.createEmptyBorder());
        }
        panel.setOpaque(jcomp.isOpaque());
        jcomp.setBorder(null);
    }
    panel.removeAll();
    panel.setBackground(comp.getBackground());
    // 1st column            
    comp.setPreferredSize(null);
    Dimension prefSize = comp.getPreferredSize();
    comp.setPreferredSize(new Dimension(width1, prefSize.height));
    comp.setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
    panel.add(comp);
    panel.add(Box.createHorizontalStrut(5));
    // 2nd column
    label.setText(info.getExample());
    label.setForeground(comp.getForeground());
    label.setFont(comp.getFont());
    label.setPreferredSize(null);
    prefSize = label.getPreferredSize();
    label.setPreferredSize(new Dimension(width2, prefSize.height));
    label.setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
    panel.add(label);
    return panel;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:36,代码来源:FormatSelector.java

示例2: defaultHeight

import java.awt.Component; //导入方法依赖的package包/类
private static int defaultHeight() {
    if (DEFAULT_HEIGHT == -1) {
        JPanel ref = new JPanel(null);
        ref.setLayout(new BoxLayout(ref, BoxLayout.LINE_AXIS));
        ref.setOpaque(false);
        
        ref.add(new JLabel("XXX")); // NOI18N
        
        ref.add(new JButton("XXX")); // NOI18N
        ref.add(new PopupButton("XXX")); // NOI18N
        
        ref.add(new JCheckBox("XXX")); // NOI18N
        ref.add(new JRadioButton("XXX")); // NOI18N
        
        ref.add(new JTextField("XXX")); // NOI18N
        
        ref.add(new JExtendedSpinner(new SpinnerNumberModel(1, 1, 655535, 1)));
        
        Component separator = Box.createHorizontalStrut(1);
        Dimension d = separator.getMaximumSize(); d.height = 20;
        separator.setMaximumSize(d);
        ref.add(separator);
        
        DEFAULT_HEIGHT = ref.getPreferredSize().height;
    }
    return DEFAULT_HEIGHT;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:SettingsPanel.java

示例3: setAllSizes

import java.awt.Component; //导入方法依赖的package包/类
/**
 * Set min max and preferred size for a component
 * @param c
 * @param d
 */
private static void setAllSizes(Component c, Dimension d) {
	c.setPreferredSize(d);
	c.setMaximumSize(d);
	c.setMinimumSize(d);
	c.setSize(d);
}
 
开发者ID:fatmanspanda,项目名称:SpriteAnimator,代码行数:12,代码来源:AnimatorGUI.java

示例4: runTest

import java.awt.Component; //导入方法依赖的package包/类
public void runTest(final Component c) {
    try {
        test(c);
        c.setMinimumSize(new Dimension(100, 10));
        c.setMaximumSize(new Dimension(200, 20));
        c.setPreferredSize(new Dimension(300, 30));
        test(c);
    } catch (final Throwable ignored) {
        failures.add(c);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:12,代码来源:DimensionEncapsulation.java

示例5: updateComponent

import java.awt.Component; //导入方法依赖的package包/类
/**
 * Updates the component in the specified cell.
 *
 * @param rowIndex
 * @param columnIndex
 */
private void updateComponent(int rowIndex, int columnIndex) {
	Pair<Integer, Integer> key = new Pair<>(rowIndex, columnIndex);

	// remove old component
	Component oldComponent = mapOfComponents.get(key);
	if (oldComponent != null) {
		innerPanel.remove(oldComponent);
	}

	// add updated component to panel instead
	Component updatedComponent = createComponentForCell(rowIndex, columnIndex);

	// add dimension constraint (if applicable)
	if (isConstraintsUsed()) {
		updatedComponent.setMinimumSize(constraints[columnIndex]);
		updatedComponent.setMaximumSize(constraints[columnIndex]);
		updatedComponent.setPreferredSize(constraints[columnIndex]);
	}

	if (isConstraintsUsed()) {
		gbc.weightx = 0.0;
	} else {
		if (Collection.class.isAssignableFrom(model.getColumnClass(columnIndex))) {
			gbc.weightx = 0.1;
		} else {
			gbc.weightx = 1.0 / model.getColumnCount();
		}
	}
	gbc.weighty = 0.0;
	if (isConstraintsUsed() && fillerMode == FillerMode.NONE) {
		gbc.fill = GridBagConstraints.VERTICAL;
	} else {
		gbc.fill = GridBagConstraints.BOTH;
	}
	gbc.gridx = columnIndex;
	gbc.gridy = rowIndex;
	innerPanel.add(updatedComponent, gbc);
	innerPanel.revalidate();
	innerPanel.repaint();

	mapOfComponents.put(key, updatedComponent);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:49,代码来源:TablePanel.java


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