我有一些问题的JDialog。 我在NetBeans中创建的Swing GUI的。 GUI包含按钮,文本字段等主框架当我点击“下一步”按钮,然后的JDialog(在NetBeans创建ASLO,其它组件部分)是表示。 以下是此JDialog的自定义属性:
- 模态= TRUE;
- 可调整大小= FALSE;
- 默认的关闭运=处置
问题是,在Windows XP(可能是7太),当的JDialog则发生我不能minimalize通过minimalize父窗体应用程序。 在Ubuntu上它工作正常,但在Windows不。
我已经考虑http://docs.oracle.com/javase/tutorial/uiswing/misc/modality.html和这个例子正在Ubuntu和寡妇为好。 所以,我试图手动创建样品的JDialog作为它的演示。 并再次Ubuntu是沃金,在Windows上是没有的。
可能有人有什么想法? 我没有任何已。
样品展示,在Ubuntu上工作,不工作在Windows XP:
package javaapplication5;
public class TWs extends javax.swing.JFrame {
/**
* Creates new form TWs
*/
public TWs() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jDialog1 = new javax.swing.JDialog();
jLabel2 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
jDialog1.setModalityType(java.awt.Dialog.ModalityType.APPLICATION_MODAL);
jDialog1.setResizable(false);
jLabel2.setText("Sample Dialog");
javax.swing.GroupLayout jDialog1Layout = new javax.swing.GroupLayout(jDialog1.getContentPane());
jDialog1.getContentPane().setLayout(jDialog1Layout);
jDialog1Layout.setHorizontalGroup(
jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jDialog1Layout.createSequentialGroup()
.addContainerGap(212, Short.MAX_VALUE)
.addComponent(jLabel2)
.addGap(205, 205, 205))
);
jDialog1Layout.setVerticalGroup(
jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jDialog1Layout.createSequentialGroup()
.addGap(122, 122, 122)
.addComponent(jLabel2)
.addContainerGap(160, Short.MAX_VALUE))
);
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jButton1.setText("Show dialog");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(136, 136, 136)
.addComponent(jButton1)
.addContainerGap(164, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(57, 57, 57)
.addComponent(jButton1)
.addContainerGap(213, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
jDialog1.setSize(200,200);
jDialog1.setVisible(true);
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(TWs.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(TWs.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(TWs.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(TWs.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new TWs().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JDialog jDialog1;
private javax.swing.JLabel jLabel2;
// End of variables declaration
}