2013-10-19 23 views
0

我設計一個全屏桌面應用程序,使用Eclipse窗口生成器工具包
和調整,我已經在我使用的GroupLayout設計
發現了這個奇怪的問題,我必須在放置元件但是,正如你所看到的,我所提供的圖像中所放置的組件之間存在差異。的contentPane在設計時在Eclipse IDE

enter image description here

這裏是由IDE生成的源:

package info.visual.gui; 

import java.awt.EventQueue; 

import javax.swing.JFrame; 
import java.awt.Color; 
import javax.swing.GroupLayout; 
import javax.swing.GroupLayout.Alignment; 
import javax.swing.JButton; 

public class MDI { 

    public JFrame frame; 
    /** 
    * @wbp.nonvisual location=487,159 
    */ 
    private final JButton button = new JButton("New button"); 

    /** 
    * Launch the application. 
    */ 
    public static void main(String[] args) { 
     EventQueue.invokeLater(new Runnable() { 
      public void run() { 
       try { 
        MDI window = new MDI(); 
        window.frame.setVisible(true); 
       } catch (Exception e) { 
        e.printStackTrace(); 
       } 
      } 
     }); 
    } 

    /** 
    * Create the application. 
    */ 
    public MDI() { 
     initialize(); 
    } 

    /** 
    * Initialize the contents of the frame. 
    */ 
    private void initialize() { 
     frame = new JFrame(); 
     frame.getContentPane().setBackground(new Color(0, 0, 0)); 

     JButton btnButton = new JButton("button1"); 
     GroupLayout groupLayout = new GroupLayout(frame.getContentPane()); 
     groupLayout.setHorizontalGroup(
      groupLayout.createParallelGroup(Alignment.LEADING) 
       .addGroup(Alignment.TRAILING, groupLayout.createSequentialGroup() 
        .addContainerGap(319, Short.MAX_VALUE) 
        .addComponent(btnButton) 
        .addGap(26)) 
     ); 
     groupLayout.setVerticalGroup(
      groupLayout.createParallelGroup(Alignment.LEADING) 
       .addGroup(groupLayout.createSequentialGroup() 
        .addGap(113) 
        .addComponent(btnButton) 
        .addContainerGap(125, Short.MAX_VALUE)) 
     ); 
     frame.getContentPane().setLayout(groupLayout); 
     frame.setExtendedState(6); 
     frame.setResizable(true); 
     frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
    } 
} 

看看代碼的這些線路

/** 
    * @wbp.nonvisual location=487,159 
    */ 
    private final JButton button = new JButton("New button"); 

那件事情我很好奇,也是最重要的這是問題。 任何人都可以清楚我應該怎麼做才能得到的contentPane擴展到全尺寸的框架是在設計時... 感謝名單..

回答

0

我同樣的問題,我通過調整框架解決它,不是的contentPane 。
只需拖放框架(窗口)的右下角,直到到達框架的中間位置(例如),ContentPane現在應該具有新的大小,並且您應該看到自己的組件正確。