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


Java Component.setPreferredSize方法代码示例

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


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

示例1: setupAssistant

import java.awt.Component; //导入方法依赖的package包/类
private void setupAssistant() {
    if (formEditorSupport.isOpened()) {
        updateAssistant();
        settingsListener = new PreferenceChangeListener() {
            @Override
            public void preferenceChange(PreferenceChangeEvent evt) {
                if (FormLoaderSettings.PROP_ASSISTANT_SHOWN.equals(evt.getKey())) {
                    updateAssistant();
                }
            }
        };
        FormLoaderSettings.getPreferences().addPreferenceChangeListener(settingsListener);
    } else if (FormLoaderSettings.getInstance().getAssistantShown()) {
        // only placeholder space during loading
        Component c = new JPanel();
        c.setPreferredSize(new Dimension(10, 41));
        c.setBackground(FormLoaderSettings.getInstance().getFormDesignerBackgroundColor());
        add(c, BorderLayout.NORTH);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:FormDesignerTC.java

示例2: 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

示例3: getListCellRendererComponent

import java.awt.Component; //导入方法依赖的package包/类
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
		boolean cellHasFocus) {

	Component renderComponent = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);

	renderComponent.setPreferredSize(new Dimension(WIDTH, HEIGHT));
	if (value instanceof ColorScheme && index != -1) {
		adaptColorSchemePreviewComponent((ColorScheme) value, renderComponent, index);
		return colorSchemeComponent;
	}
	return renderComponent;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:14,代码来源:ColorSchemeComboBoxRenderer.java

示例4: 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

示例5: UserDataCellRenderer

import java.awt.Component; //导入方法依赖的package包/类
UserDataCellRenderer(Component comp) {
    this.comp = comp;
    Dimension d = comp.getPreferredSize();
    if (d.getHeight() > 200) {
        comp.setPreferredSize(new Dimension((int) d.getWidth(), 200));
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:8,代码来源:XMBeanNotifications.java

示例6: MaximizedCellRenderer

import java.awt.Component; //导入方法依赖的package包/类
MaximizedCellRenderer(Component comp) {
    this.comp = comp;
    Dimension d = comp.getPreferredSize();
    if (d.getHeight() > 220) {
        comp.setPreferredSize(new Dimension((int) d.getWidth(), 220));
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:8,代码来源:XMBeanAttributes.java

示例7: 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

示例8: main

import java.awt.Component; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    Robot robot = new Robot();
    for(int i = 0; i < 10; i++) {
        Dialog dialog = new Dialog((Frame) null);
        dialog.setLocation(100, 100);
        Component panel = new Panel();
        panel.setPreferredSize(new Dimension(200, 100));
        dialog.add(panel);
        dialog.pack();
        dialog.setVisible(true);
        robot.waitForIdle();
        robot.delay(200);

        Point frameLoc = dialog.getLocationOnScreen();
        Point contentLoc = panel.getLocationOnScreen();

        System.out.println("Decor location " + frameLoc);
        System.out.println("Content location " + contentLoc);

        dialog.setResizable(false);
        robot.waitForIdle();
        robot.delay(200);

        Point l = dialog.getLocationOnScreen();
        if (!l.equals(frameLoc)) {
            dialog.dispose();
            throw new RuntimeException("Decorated frame location moved " +
                    "after setResizable(false)" + l);
        }

        l = panel.getLocationOnScreen();
        if (!l.equals(contentLoc)) {
            dialog.dispose();
            throw new RuntimeException("Content location moved after " +
                    "setResizable(false)" + l);
        }

        if (panel.getLocationOnScreen().y <
                  dialog.getLocationOnScreen().y + dialog.getInsets().top) {
            dialog.dispose();
            throw new RuntimeException(
                        "Wrong content position after setResizable(false)");
        }

        dialog.setResizable(true);
        robot.waitForIdle();
        robot.delay(200);

        l = dialog.getLocationOnScreen();
        if (!l.equals(frameLoc)) {
            dialog.dispose();
            throw new RuntimeException("Decorated frame location moved " +
                    "after setResizable(true)" + l);
        }

        l = panel.getLocationOnScreen();
        if (!l.equals(contentLoc)) {
            dialog.dispose();
            throw new RuntimeException("Content location moved after " +
                    "setResizable(true)" + l);
        }
        if (panel.getLocationOnScreen().y <
                  dialog.getLocationOnScreen().y + dialog.getInsets().top) {
            dialog.dispose();
            throw new RuntimeException(
                         "Wrong content position after setResizable(true)");
        }

        dialog.dispose();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:72,代码来源:ChangeWindowResizabiltyTest.java

示例9: unifyComponentsSize

import java.awt.Component; //导入方法依赖的package包/类
private void unifyComponentsSize(Component c1, Component c2) {
    Dimension preferredSize = new Dimension(Math.max(c1.getPreferredSize().width, c2.getPreferredSize().width),
                                            Math.max(c1.getPreferredSize().height, c2.getPreferredSize().height));
    c1.setPreferredSize(preferredSize);
    c2.setPreferredSize(preferredSize);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:7,代码来源:HeapFragmentWalkerUI.java

示例10: 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

示例11: setNoSize

import java.awt.Component; //导入方法依赖的package包/类
/**
 * Setzt die Größe einer übergebenen Widget-Komponente auf -1.
 */
private void setNoSize(Component component)
{
    component.setPreferredSize(new Dimension(-1, -1));
    component.setSize(-1, -1);
}
 
开发者ID:polemonium,项目名称:SE2Project,代码行数:9,代码来源:AusleiheUI.java


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