我寫了下面的代碼來生成請稍候JDialog
而產生決策樹的,但它打開了,似乎是空白的JDialog盒子打開,但顯示爲空白
public JDialog pleasewait()
{
JDialog dialog = new JDialog();
JLabel label = new JLabel("Please wait...");
label.setIcon(new javax.swing.ImageIcon(getClass().getResource("/decision_tree_runner/load.gif"))); // NOI18N
dialog.setBackground(Color.BLACK);
dialog.setLocationRelativeTo(null);
dialog.setTitle("Please Wait...");
dialog.add(label);
dialog.pack();
return dialog;
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
JDialog dialog = pleasewait();
dialog.repaint();
dialog.setVisible(true);
FypProject fyp_project = new FypProject();
try {fyp_project.main_fypproject();} catch (SQLException ex) {}
dialog.setVisible(false);
}
添加這已收縮對話框並沒有顯示出任何東西仍然 – 2014-12-04 19:06:21
如果您從標籤中刪除圖像會發生什麼? – user489041 2014-12-04 19:09:24
JDialog與所有Swing頂級容器一樣,默認情況下使用BorderLayout ... – MadProgrammer 2014-12-04 19:09:35