當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。