0
有沒有辦法用Eclipse WindowBuilder創建JDialog並且自動生成的代碼是懶惰風格的?當我在首選項> WindowBuilder> Swing>代碼生成中選擇Lazy時,在JFrames中,我得到了所有組件的懶惰樣式代碼。但是,當我創建一個JDialog,代碼不是懶惰 - 它,而像這樣(注意,確定部件和取消按鈕):使用WindowBuilder在Eclipse中JDialog懶惰風格的代碼生成
public class FactsDialog extends JDialog {
private final JPanel contentPanel = new JPanel();
/**
* Launch the application.
*/
public static void main(String[] args) {
try {
FactsDialog dialog = new FactsDialog();
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
dialog.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Create the dialog.
*/
public FactsDialog() {
setBounds(100, 100, 450, 300);
getContentPane().setLayout(new BorderLayout());
contentPanel.setLayout(new FlowLayout());
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
getContentPane().add(contentPanel, BorderLayout.CENTER);
{
JPanel buttonPane = new JPanel();
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
getContentPane().add(buttonPane, BorderLayout.SOUTH);
{
JButton okButton = new JButton("OK");
okButton.setActionCommand("OK");
buttonPane.add(okButton);
getRootPane().setDefaultButton(okButton);
}
{
JButton cancelButton = new JButton("Cancel");
cancelButton.setActionCommand("Cancel");
buttonPane.add(cancelButton);
}
}
}
}