JInternalFrame.setMaximum (true)
Claude Stéphan <[email protected]>
| Newsgroups | gmane.comp.java.netbeans.general.french |
|---|---|
| Message-ID | <[email protected]> |
Bonjour,
Merci à Christophe Cailloix
Toujours sous windows XP, J2SE 5.0 et netbeans 5.0, je reviens vers vous
au sujet de la propriété JInternalFrame.setMaximum (boolean b)
Cette fois, je n'écris aucune ligne de code.
Je crée, *par l'intermédiaire de l'EDI*, un JFrame qui inclut un
JDesktopPane lui même incluant un JInternalFrame. Toute les valeurs sont
par défaut, tout fonctionne.
(Le code figure ci-dessous.)
Si, *par l'intermédiaire de l'EDI netbeans,* j'active la propriété
JInternalFrame.setMaximum (true), je récupère une erreur à run time:
/*_/*exception in thread "AWT-EventQueue-0" java.lang.NullPointerException*/
*/_l'erreur est signalée comme provenant de la méthode ci-dessous à la
ligne que j'ai mis en gras soit:_
_Rectangle desktopBounds = f.getParent().getBounds();_/*
*/_/public void maximizeFrame(JInternalFrame f) {
if (f.isIcon()) {
try {
// In turn calls deiconifyFrame in the desktop manager.
// That method will handle the maximization of the frame.
f.setIcon(false);
} catch (PropertyVetoException e2) {
}
} else {
f.setNormalBounds(f.getBounds());
*Rectangle desktopBounds = f.getParent().getBounds();*
setBoundsForFrame(f, 0, 0,
desktopBounds.width, desktopBounds.height);
}
// Set the maximized frame as selected.
try {
f.setSelected(true);
} catch (PropertyVetoException e2) {
}
}
_*voici le code du Projet qui me crée des soucis et pour lequel
j'aimerais en comprendre la raison*_
//*
* Accueil.java
*
* Created on 5 mars 2006, 08:55
*/
package Accueil;
/**
*
* @author Claude
*/
public class Accueil extends javax.swing.JFrame {
/** Creates new form Accueil */
public Accueil() {
initComponents();
/**il n'y a aucune erreur si j'écris le code à cet emplacement**/
/*try {
jInternalFrameBienvenue.setMaximum(true);
} catch (java.beans.PropertyVetoException e1) {
e1.printStackTrace();
}*/
}
/** 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.
*/
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">
private void initComponents() {
jDesktopPane1 = new javax.swing.JDesktopPane();
jInternalFrame1 = new javax.swing.JInternalFrame();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
/**place de la propriété JInternalFrameBienvenue.setMaximum(true)
par l'EDI qui occasionne l'apparition du message d'erreur**/
/*/*try {
jInternalFrameBienvenue.setMaximum(true);
} catch (java.beans.PropertyVetoException e1) {
e1.printStackTrace();
}*/*/
jInternalFrame1.setVisible(true);
org.jdesktop.layout.GroupLayout jInternalFrame1Layout = new
org.jdesktop.layout.GroupLayout(jInternalFrame1.getContentPane());
jInternalFrame1.getContentPane().setLayout(jInternalFrame1Layout);
jInternalFrame1Layout.setHorizontalGroup(
jInternalFrame1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(0, 18, Short.MAX_VALUE)
);
jInternalFrame1Layout.setVerticalGroup(
jInternalFrame1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(0, 0, Short.MAX_VALUE)
);
jInternalFrame1.setBounds(0, 0, 24, 26);
jDesktopPane1.add(jInternalFrame1,
javax.swing.JLayeredPane.DEFAULT_LAYER);
org.jdesktop.layout.GroupLayout layout = new
org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(0, 400, Short.MAX_VALUE)
.add(jDesktopPane1,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 100,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(0, 300, Short.MAX_VALUE)
.add(jDesktopPane1,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 100,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
);
pack();
}// </editor-fold>
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Accueil().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JDesktopPane jDesktopPane1;
private javax.swing.JInternalFrame jInternalFrame1;
// End of variables declaration
}