本文整理汇总了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;
}
示例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;
}
示例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);
}
示例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);
}
}
示例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);
}