本文整理匯總了Java中javax.swing.JComponent.setSize方法的典型用法代碼示例。如果您正苦於以下問題:Java JComponent.setSize方法的具體用法?Java JComponent.setSize怎麽用?Java JComponent.setSize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.JComponent
的用法示例。
在下文中一共展示了JComponent.setSize方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: ComponentIcon
import javax.swing.JComponent; //導入方法依賴的package包/類
/** Create an icon.
* @param comp a component, which must be unattached to a container
* and should not be used for other purposes
*/
public ComponentIcon(JComponent comp) {
if (comp.getParent() != null) {
throw new IllegalArgumentException();
}
this.comp = comp;
Dimension size = comp.getPreferredSize();
// Careful! If you have e.g. a JLabel with empty text, width = 0 => exceptions.
// Must make sure it is at least a reasonable size.
comp.setSize(Math.max(size.width, 16), Math.max(size.height, 16));
}
示例2: paint
import javax.swing.JComponent; //導入方法依賴的package包/類
public void paint(Graphics g) {
g.setColor(getBackground());
g.fillRect(location.x, location.y, size.width, size.height);
JComponent component = mainRenderer.getComponent();
int componentWidth = component.getPreferredSize().width;
int componentX = size.width - componentWidth;
mainRenderer.move(location.x + componentX, location.y);
component.setSize(componentWidth, size.height);
component.paint(g);
int freeWidth = size.width - maxRendererWidth - renderersGap();
if (freeWidth >= MIN_BAR_WIDTH) {
barRenderer.setSize(Math.min(freeWidth, MAX_BAR_WIDTH), size.height);
barRenderer.move(location.x, location.y);
barRenderer.paint(g);
}
}
示例3: getComponentImage
import javax.swing.JComponent; //導入方法依賴的package包/類
private Image getComponentImage(JComponent component) {
// Initial component sizing & layout
component.setSize((getClientSize().width == 0) ? component.getPreferredSize() : getClientSize()); // try to fit the component to ComponentMorpher
component.doLayout(); // layout component
// Correct component sizing & layout
component.setSize(new Dimension(getClientSize().width, component.getPreferredSize().height)); // Width of component is fixed, update height
component.doLayout(); // layout component
// One more iteration because of nested JTextAreas
component.setSize(new Dimension(getClientSize().width, component.getPreferredSize().height)); // Width of component is fixed, update height
component.doLayout(); // layout component
// Paint component into BufferedImage
BufferedImage componentImage = new BufferedImage(component.getSize().width, component.getSize().height,
BufferedImage.TYPE_INT_RGB);
component.printAll(componentImage.getGraphics());
return componentImage;
}
示例4: init
import javax.swing.JComponent; //導入方法依賴的package包/類
/**
* 初始化主窗口信息
*/
public void init()
{
this.setJMenuBar((JMenuBar)XJava.getObject("xmMainMenuBar"));
this.getContentPane().setLayout(new BorderLayout());
this.getContentPane().add((Component)XJava.getObject("xpMain") ,BorderLayout.CENTER);
this.setEnabled(false);
JComponent v_JC = ((JComponent)XJava.getObject("xlTables"));
v_JC.setSize(50 ,v_JC.getHeight());
this.showHintInfo("請稍後,正在訪問數據庫..." ,Color.BLUE);
this.initListModel();
this.initTableModel();
this.initTablesInfo();
this.setEnabled(true);
this.showHintInfo("歡迎使用!");
}
示例5: layoutContainer
import javax.swing.JComponent; //導入方法依賴的package包/類
@Override
public void layoutContainer( Container parent ) {
int width = getWidth ();
int height = 0;
for( int i=0; i<descriptors.length; i++ ) {
CategoryDescriptor paletteCategoryDescriptor = descriptors[i];
paletteCategoryDescriptor.setPositionY( height );
JComponent comp = paletteCategoryDescriptor.getComponent();
comp.setSize( width, comp.getPreferredSize().height );
height += paletteCategoryDescriptor.getComponent().getHeight();
}
}
示例6: layoutComponent
import javax.swing.JComponent; //導入方法依賴的package包/類
private JComponent layoutComponent(JComponent component) {
// Initial component sizing & layout
if (getClientSize().width > 0) {
component.setSize(getClientSize()); // try to fit the component to ComponentMorpher
component.validate(); // layout component
// Correct component sizing & layout
component.setSize(new Dimension(getClientSize().width, component.getPreferredSize().height)); // Width of component is fixed, update height
component.validate(); // layout component
}
return component;
}
示例7: render
import javax.swing.JComponent; //導入方法依賴的package包/類
@Override
public void render(Graphics graphics, int width, int height) {
JComponent renderComponent = getRenderComponent();
renderComponent.setSize(width, height);
renderComponent.setDoubleBuffered(false);
renderComponent.paint(graphics);
renderComponent.setDoubleBuffered(true);
}
示例8: createComponent
import javax.swing.JComponent; //導入方法依賴的package包/類
private static JComponent createComponent(String str) {
JComponent comp = new JLabel(str);
comp.setSize(WIDTH, HEIGHT);
comp.putClientProperty(TextAttribute.NUMERIC_SHAPING, NUMERIC_SHAPER);
comp.setFont(getFont());
return comp;
}
示例9: createNoComponent
import javax.swing.JComponent; //導入方法依賴的package包/類
private Component createNoComponent() {
JComponent noComponent = new JComponent() {};
noComponent.setSize(0, 0);
noComponent.setVisible(false);
return noComponent;
}