簡體   English   中英

Swing對話框窗口在運行[WindowBuilder]上不可見

[英]Swing Dialog Window is not visible on Run [WindowBuilder]

我是Java swing開發的新手,在這里,我正在eclipse(Mars)上使用WindowBuilder開發一個簡單的桌面應用程序。 但是在Eclipse中運行我的應用程序時,我什至看不到鍋爐代碼對話框窗口彈出。 但是,如果我創建SWT應用程序窗口,則會在“運行”中顯示。

這是我的Swing對話框鍋爐代碼:

import java.awt.BorderLayout;
import java.awt.FlowLayout;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

public class UploaderDlg extends JDialog {

private final JPanel contentPanel = new JPanel();

/**
 * Launch the application.
 */
public static void main(String[] args) {
    try {
        UploaderDlg dialog = new UploaderDlg();
        dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
        dialog.setVisible(true);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

/**
 * Create the dialog.
 */
public UploaderDlg() {
    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);
        }
    }
 }

}

有人可以幫我知道這是怎么回事嗎?

嘗試右鍵單擊文件名->使用-> Windows Builder打開。

祝好運

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM