IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

NetBeans Java Discussion :

WizardDescriptor de l'api netbeans


Sujet :

NetBeans Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre chevronné
    Avatar de mhamedbj
    Profil pro
    Inscrit en
    Février 2007
    Messages
    403
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2007
    Messages : 403
    Par défaut WizardDescriptor de l'api netbeans
    bonjour,
    je travaille mon sur la plateforme netbeans et je suis en train de réaliser un wizard, le problème c'est que j'ai besoin d'accéder au contenu des objets dans le(s) panel(s) di wizard pour extraire leur contenu et qu'il soit affiché comme un récap dans le panel qui suit.....,

    j'y arrive pas !!!!.


    il ya bien un "WizardDescriptor" et les methodes "putProperty(String name, Object object)" et "getProperty(String name)" que jai trouver dans la javadoc, mais je n'arrive pas a acceder a l'instance du "WizardDescriptor" qui 'normalement' devrais etre coommun entre tous les panel du wizard

  2. #2
    Expert confirmé


    Profil pro
    Inscrit en
    Mai 2003
    Messages
    3 240
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2003
    Messages : 3 240
    Par défaut
    Logiquement, c'est le readSettings() de ton panel qui va te permettre d'accéder à ces infos.

    Non ?

    Vincent

  3. #3
    Membre chevronné
    Avatar de mhamedbj
    Profil pro
    Inscrit en
    Février 2007
    Messages
    403
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2007
    Messages : 403
    Par défaut
    en fait il ya deux methodes qui proviennent de "implements WizardDescriptor.Panel" et qui sont :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     public void readSettings(Object settings) {
        }
        public void storeSettings(Object settings) {
     
        }
    et qui ne sont pas dans l'objet visuel qui est extends JPanet mais dans une class a part qui est "implements WizardDescriptor.Panel"
    le truc c'est que je voudrais utiliser ces deux methodes mais je n'arrive pas a acceder a l'instance de l'objet qui est extends JPanel pour justement obtenir l'access ames JTextField .... je ne sais pas si vous avez bien compris ????

  4. #4
    Membre émérite
    Avatar de n!co
    Profil pro
    Inscrit en
    Février 2004
    Messages
    831
    Détails du profil
    Informations personnelles :
    Âge : 43
    Localisation : France

    Informations forums :
    Inscription : Février 2004
    Messages : 831
    Par défaut
    Tes instances de JPanel ne sont pas instancié dans tes implémentations de WizardDescriptor.Panel ?

  5. #5
    Membre chevronné
    Avatar de mhamedbj
    Profil pro
    Inscrit en
    Février 2007
    Messages
    403
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2007
    Messages : 403
    Par défaut
    non je n'es pas fais d'instanciation en tout cas je voulais suivre le philosophie de l'API j'ai donc tout simplement fait un new Wizard... et j'ai mis un nombre d'etapes fixes (2) pour l'essai je mis sur le premier panel un JTextField, et dans le second un Jlabel, je veux juste transmettre ce que j'ai ecris dans le TextField dans le jlabel de la deuxiemme etape, amon avis ya pas plus simple pour saisir le truc, je vous file le code qui m'a ete fourni automatiquement par netbeans, il a cree 5 class, je vous les donnes dans l'ordre, une classe qui posséde la methode pour lancer le wizzard, deux classes visuelle pour les wizerd (extends JPanel) et deux class qui permettent.... je ne sais trop quoi!!

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    public final class monwizzWizardAction extends CallableSystemAction {
     
        private WizardDescriptor.Panel[] panels;
     
        public void performAction() {
            WizardDescriptor wizardDescriptor = new WizardDescriptor(getPanels());
            // {0} will be replaced by WizardDesriptor.Panel.getComponent().getName()
            wizardDescriptor.setTitleFormat(new MessageFormat("{0}"));
            wizardDescriptor.setTitle("Your wizard dialog title here");
            Dialog dialog = DialogDisplayer.getDefault().createDialog(wizardDescriptor);
            dialog.setVisible(true);
            dialog.toFront();
            boolean cancelled = wizardDescriptor.getValue() != WizardDescriptor.FINISH_OPTION;
            if (!cancelled) {
                // do something
            }
        }
     
        /**
         * Initialize panels representing individual wizard's steps and sets
         * various properties for them influencing wizard appearance.
         */
        private WizardDescriptor.Panel[] getPanels() {
            if (panels == null) {
                panels = new WizardDescriptor.Panel[] {
                    new monwizzWizardPanel1(),
                    new monwizzWizardPanel2(),
                    new monwizzWizardPanel3()
                };
                String[] steps = new String[panels.length];
                for (int i = 0; i < panels.length; i++) {
                    Component c = panels[i].getComponent();
                    // Default step name to component name of panel. Mainly useful
                    // for getting the name of the target chooser to appear in the
                    // list of steps.
                    steps[i] = c.getName();
                    if (c instanceof JComponent) { // assume Swing components
                        JComponent jc = (JComponent) c;
                        // Sets step number of a component
                        jc.putClientProperty("WizardPanel_contentSelectedIndex", new Integer(i));
                        // Sets steps names for a panel
                        jc.putClientProperty("WizardPanel_contentData", steps);
                        // Turn on subtitle creation on each step
                        jc.putClientProperty("WizardPanel_autoWizardStyle", Boolean.TRUE);
                        // Show steps on the left side with the image on the background
                        jc.putClientProperty("WizardPanel_contentDisplayed", Boolean.TRUE);
                        // Turn on numbering of all steps
                        jc.putClientProperty("WizardPanel_contentNumbered", Boolean.TRUE);
                    }
                }
            }
            return panels;
        }
     
        public String getName() {
            return "Start Sample Wizard";
        }
     
        public String iconResource() {
            return null;
        }
     
        public HelpCtx getHelpCtx() {
            return HelpCtx.DEFAULT_HELP;
        }
     
        protected boolean asynchronous() {
            return false;
        }
    }
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    public final class monwizzVisualPanel1 extends JPanel {
     
        /** Creates new form monwizzVisualPanel1 */
        public monwizzVisualPanel1() {
            initComponents();
        }
     
        public String getName() {
            return "Step #1";
        }
     
        /** 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() {
            jTextField1 = new javax.swing.JTextField();
     
            jTextField1.setText("jTextField1");
     
            org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
            this.setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(layout.createSequentialGroup()
                    .add(39, 39, 39)
                    .add(jTextField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 158, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(203, Short.MAX_VALUE))
            );
            layout.setVerticalGroup(
                layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(layout.createSequentialGroup()
                    .add(41, 41, 41)
                    .add(jTextField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(240, Short.MAX_VALUE))
            );
        }// </editor-fold>
     
     
        // Variables declaration - do not modify
        private javax.swing.JTextField jTextField1;
        // End of variables declaration
     
    }
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    public final class monwizzVisualPanel2 extends JPanel {
     
        /** Creates new form monwizzVisualPanel2 */
        public monwizzVisualPanel2() {
            initComponents();
        }
     
        public String getName() {
            return "Step #2";
        }
     
        /** 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() {
            jLabel1 = new javax.swing.JLabel();
     
            org.openide.awt.Mnemonics.setLocalizedText(jLabel1, "jLabel1");
     
            org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
            this.setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(layout.createSequentialGroup()
                    .add(45, 45, 45)
                    .add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 105, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(250, Short.MAX_VALUE))
            );
            layout.setVerticalGroup(
                layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(layout.createSequentialGroup()
                    .add(43, 43, 43)
                    .add(jLabel1)
                    .addContainerGap(242, Short.MAX_VALUE))
            );
        }// </editor-fold>                        
     
     
        // Variables declaration - do not modify                     
        private javax.swing.JLabel jLabel1;
        // End of variables declaration                   
     
    }
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    public class monwizzWizardPanel1 implements WizardDescriptor.Panel {
     
        /**
         * The visual component that displays this panel. If you need to access the
         * component from this class, just use getComponent().
         */
        private Component component;
       public monwizzWizardPanel1 (){
     
       }
        // Get the visual component for the panel. In this template, the component
        // is kept separate. This can be more efficient: if the wizard is created
        // but never displayed, or not all panels are displayed, it is better to
        // create only those which really need to be visible.
        public Component getComponent() {
            if (component == null) {
                component = new monwizzVisualPanel1();
            }
            return component;
        }
     
        public HelpCtx getHelp() {
            // Show no Help button for this panel:
            return HelpCtx.DEFAULT_HELP;
            // If you have context help:
            // return new HelpCtx(SampleWizardPanel1.class);
        }
     
        public boolean isValid() {
            // If it is always OK to press Next or Finish, then:
            return true;
            // If it depends on some condition (form filled out...), then:
            // return someCondition();
            // and when this condition changes (last form field filled in...) then:
            // fireChangeEvent();
            // and uncomment the complicated stuff below.
        }
     
        public final void addChangeListener(ChangeListener l) {}
        public final void removeChangeListener(ChangeListener l) {}
        /*
        private final Set<ChangeListener> listeners = new HashSet<ChangeListener>(1);
        public final void addChangeListener(ChangeListener l) {
            synchronized (listeners) {
                listeners.add(l);
            }
        }
        public final void removeChangeListener(ChangeListener l) {
            synchronized (listeners) {
                listeners.remove(l);
            }
        }
        protected final void fireChangeEvent() {
            Iterator<ChangeListener> it;
            synchronized (listeners) {
                it = new HashSet<ChangeListener>(listeners).iterator();
            }
            ChangeEvent ev = new ChangeEvent(this);
            while (it.hasNext()) {
                it.next().stateChanged(ev);
            }
        }
         */
     
        // You can use a settings object to keep track of state. Normally the
        // settings object will be the WizardDescriptor, so you can use
        // WizardDescriptor.getProperty & putProperty to store information entered
        // by the user.
        public void readSettings(Object settings) {
          System.out.println("readed");
        }
        public void storeSettings(Object settings) {
             System.out.println("stored1");
        }
    }
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    public class monwizzWizardPanel2 implements WizardDescriptor.Panel {
     
        /**
         * The visual component that displays this panel. If you need to access the
         * component from this class, just use getComponent().
         */
        private Component component;
     
        // Get the visual component for the panel. In this template, the component
        // is kept separate. This can be more efficient: if the wizard is created
        // but never displayed, or not all panels are displayed, it is better to
        // create only those which really need to be visible.
        public Component getComponent() {
            if (component == null) {
                component = new monwizzVisualPanel2();
            }
            return component;
        }
     
        public HelpCtx getHelp() {
            // Show no Help button for this panel:
            return HelpCtx.DEFAULT_HELP;
            // If you have context help:
            // return new HelpCtx(SampleWizardPanel1.class);
        }
     
        public boolean isValid() {
            // If it is always OK to press Next or Finish, then:
            return true;
            // If it depends on some condition (form filled out...), then:
            // return someCondition();
            // and when this condition changes (last form field filled in...) then:
            // fireChangeEvent();
            // and uncomment the complicated stuff below.
        }
     
        public final void addChangeListener(ChangeListener l) {}
        public final void removeChangeListener(ChangeListener l) {}
        /*
        private final Set<ChangeListener> listeners = new HashSet<ChangeListener>(1);
        public final void addChangeListener(ChangeListener l) {
            synchronized (listeners) {
                listeners.add(l);
            }
        }
        public final void removeChangeListener(ChangeListener l) {
            synchronized (listeners) {
                listeners.remove(l);
            }
        }
        protected final void fireChangeEvent() {
            Iterator<ChangeListener> it;
            synchronized (listeners) {
                it = new HashSet<ChangeListener>(listeners).iterator();
            }
            ChangeEvent ev = new ChangeEvent(this);
            while (it.hasNext()) {
                it.next().stateChanged(ev);
            }
        }
         */
     
        // You can use a settings object to keep track of state. Normally the
        // settings object will be the WizardDescriptor, so you can use
        // WizardDescriptor.getProperty & putProperty to store information entered
        // by the user.
        public void readSettings(Object settings) {}
        public void storeSettings(Object settings) {
            System.out.println("stored2");
        }
    et pour répondre à nico...
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
        public Component getComponent() {
            if (component == null) {
                component = new monwizzVisualPanel2();
            }
            return component;
        }
    l'instanciation retourne un objet de type Component, donc je ne sais pas vraiment ce que je peux en tirer, le truc c'est que si on fait attention aux commentaires on voit
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
        // You can use a settings object to keep track of state. Normally the
        // settings object will be the WizardDescriptor, so you can use
        // WizardDescriptor.getProperty & putProperty to store information entered
        // by the user.
    or je n'ais trouvé auccun moyen d'acceder a l'instance du "WizardDescriptor"...

    merci pour votre patience

  6. #6
    Membre chevronné
    Avatar de mhamedbj
    Profil pro
    Inscrit en
    Février 2007
    Messages
    403
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2007
    Messages : 403
    Par défaut
    apparemment mon post vous a fait fuire !!!

    alors je vais facilité les choses :
    en fait il ya deux commentaires qui m'ont mis la puce a l'oreille :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    // Get the visual component for the panel. In this template, the component
        // is kept separate. This can be more efficient: if the wizard is created
        // but never displayed, or not all panels are displayed, it is better to
        // create only those which really need to be visible.
        public Component getComponent() {
            if (component == null) {
                component = new monwizzVisualPanel1();
            }
            return component;
        }
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    // You can use a settings object to keep track of state. Normally the
        // settings object will be the WizardDescriptor, so you can use
        // WizardDescriptor.getProperty & putProperty to store information entered
        // by the user.
        public void readSettings(Object settings) {}
        public void storeSettings(Object settings) {}
    donc logiquement si on suit le philosophie de netbeans:
    l'objet component n'est rien d'autre que mon panel puis que
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    component = new monwizzVisualPanel1();
    et les methodes readSettings et storeSettings se font a chaque fois que j'appuie sur le bouton next ou previous mais je voudrais utiliser le WizzardDescriptor comme c'est indiqué dans le commentaire, en effet ce dernier possede deux methodes qui sont :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    public void putProperty(String name,
                            Object value)
    Allows Panels that use WizardDescriptor as settings object to store additional settings into it. 
     
    Parameters:
    name - name of the property
    value - value of property
    et
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    public Object getProperty(String name)
    Getter for stored property. 
     
    Parameters:
    name - name of the property 
    Returns:
    the value
    est ce que c'est faisable !????


    merci pour votre patience !!

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. recherche d'un plugin ou API netbeans
    Par supcomingenieur dans le forum NetBeans
    Réponses: 0
    Dernier message: 27/02/2013, 11h12
  2. Réponses: 1
    Dernier message: 16/12/2008, 19h11
  3. NetBeans API - Création de Wizards
    Par Cartman.inc dans le forum NetBeans
    Réponses: 4
    Dernier message: 21/03/2007, 15h02
  4. [débutant][netBeans 3.6][API]Castor
    Par pingoui dans le forum NetBeans
    Réponses: 2
    Dernier message: 29/07/2004, 10h46

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo