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


Java JFrame.getBounds方法代码示例

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


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

示例1: About

import javax.swing.JFrame; //导入方法依赖的package包/类
/** Creates new form About */
public About(JFrame parent) {
    super(parent,true);
    initComponents();
    pack();
    Rectangle parentBounds = parent.getBounds();
    Dimension size = getSize();
    // Center in the parent
    int x = Math.max(0, parentBounds.x + (parentBounds.width - size.width) / 2);
    int y = Math.max(0, parentBounds.y + (parentBounds.height - size.height) / 2);
    setLocation(new Point(x, y));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:About.java

示例2: borderTest

import javax.swing.JFrame; //导入方法依赖的package包/类
/**
 * 
 * Tests
 * 
 */

private static boolean borderTest()
{	
	JFrame frame = new JFrame();
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
	
	JPanel contentPanel = new JPanel();
	contentPanel.setLayout( new SlickLayout() );
	contentPanel.setBorder( BorderFactory.createEmptyBorder(10, 10, 10, 10) );
	
	JPanel comp1 = new RandomColorPanel( new Dimension( 200, 200 ), "1" );
	contentPanel.add(comp1, new SlickConstraint(0, SlickConstraint.HorizontalPack, SlickConstraint.VerticalPack) );
	
	frame.add(contentPanel);
	frame.pack();
	//frame.setVisible(true);
	frame.dispose();
	
	boolean pass = true;
	
	//java.awt.Rectangle[x=62,y=0,width=236,height=259]
	Rectangle frameBounds = frame.getBounds();
	pass &= (frameBounds.width == 236)&(frameBounds.height == 259);
	
	//java.awt.Rectangle[x=0,y=0,width=220,height=220]
	Rectangle contentPanelBounds = contentPanel.getBounds();
	pass &= (contentPanelBounds.width == 220)&(contentPanelBounds.height == 220);
	pass &= (contentPanelBounds.x == 0)&(contentPanelBounds.y == 0);
		
	//java.awt.Rectangle[x=10,y=10,width=200,height=200]
	Rectangle comp1Bounds = comp1.getBounds();
	pass &= (comp1Bounds.width == 200)&(comp1Bounds.height == 200);
	pass &= (comp1Bounds.x == 10)&(comp1Bounds.y == 10);
	
	return pass;
}
 
开发者ID:jpxor,项目名称:slick,代码行数:42,代码来源:Test_SlickLayout.java

示例3: initialize

import javax.swing.JFrame; //导入方法依赖的package包/类
/**
 * Initialize the contents of the frame.
 */
private void initialize(String title, Rectangle bounds) {
	frame = new JFrame();
	frame.setBounds(bounds);
	frame.setMinimumSize(frame.getBounds().getSize());
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	frame.getContentPane().setLayout(null);
	frame.setTitle(title);
	this.title = title;
	this.originalBounds = frame.getBounds();
}
 
开发者ID:Cyphereion,项目名称:Java-Swing-Helper,代码行数:14,代码来源:SwingWindow.java


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