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 :

Beans avec Netbeans


Sujet :

NetBeans Java

  1. #1
    Membre habitué Avatar de ABN84
    Inscrit en
    Octobre 2007
    Messages
    410
    Détails du profil
    Informations personnelles :
    Âge : 39

    Informations forums :
    Inscription : Octobre 2007
    Messages : 410
    Points : 149
    Points
    149
    Par défaut Beans avec Netbeans
    bonjour,
    quelcun sait-il comment creer des beans avec Netbeans?
    le beans que je veux creer sera basé sur jPanel, que vaut-il mieux choisir comme type de projet swing gui form/bean ou swing gui form/jpanel? la difference reside dans le et .
    "Celui qui n'a jamais fait d'erreurs n'a jamais rien essayé"A. Einstein
    "La différence entre la stupidité et le génie est que le génie a ses limites"A. Einstein
    "c'est en forgeant qu'on devient forgeron"

  2. #2
    Rédacteur
    Avatar de eclesia
    Profil pro
    Inscrit en
    Décembre 2006
    Messages
    2 108
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2006
    Messages : 2 108
    Points : 3 203
    Points
    3 203
    Par défaut
    un JPanel est deja un "extends Object". donc tu peux utiliser le jpanel.
    Systèmes d'Informations Géographiques
    - Projets : Unlicense.science - Apache.SIS

    Pour un monde sans BigBrother IxQuick ni censure RSF et Les moutons

  3. #3
    Membre habitué Avatar de ABN84
    Inscrit en
    Octobre 2007
    Messages
    410
    Détails du profil
    Informations personnelles :
    Âge : 39

    Informations forums :
    Inscription : Octobre 2007
    Messages : 410
    Points : 149
    Points
    149
    Par défaut
    bonjour,
    j'ai fais quelques essais simples: jPanel avec un jButton et jTextField à l'inteireur, je compile, j'ajoute le jar à la palette, et là eefectivement y a un nouveau bean qui apparait mais, il n'herique des propriétes que du jPanel, les textfield et le button ne sont pas cliquables.
    "Celui qui n'a jamais fait d'erreurs n'a jamais rien essayé"A. Einstein
    "La différence entre la stupidité et le génie est que le génie a ses limites"A. Einstein
    "c'est en forgeant qu'on devient forgeron"

  4. #4
    Rédacteur
    Avatar de eclesia
    Profil pro
    Inscrit en
    Décembre 2006
    Messages
    2 108
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2006
    Messages : 2 108
    Points : 3 203
    Points
    3 203
    Par défaut
    c'est normal. si tu veux des methodes pour manipuler les composants qui sont a l'intérieur du jpanel c'est a toi de les faire.
    Systèmes d'Informations Géographiques
    - Projets : Unlicense.science - Apache.SIS

    Pour un monde sans BigBrother IxQuick ni censure RSF et Les moutons

  5. #5
    Membre habitué Avatar de ABN84
    Inscrit en
    Octobre 2007
    Messages
    410
    Détails du profil
    Informations personnelles :
    Âge : 39

    Informations forums :
    Inscription : Octobre 2007
    Messages : 410
    Points : 149
    Points
    149
    Par défaut
    bonsoir,
    merci pour ces eclaicissements.
    voilà donc j'ai fait mon composant, mais il me reste 3 problemes à resoudre:
    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
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    /*
     * Scale.java
     *
     * Created on 2 octobre 2007, 19:33
     */
     
     
     
    /**
     *
     * @author  neilab
     */
    public class Scale extends javax.swing.JPanel {
     
        public double round(double value, int dec) {
            double mult = Math.pow (10.0, (double)dec);
            return Math.round(value * mult) / mult;
        }   
        /** Creates new form Scale */
        public Scale() {
            initComponents();
        }
     
        public String getUnit() {
            return (this.unit);
        }
     
        public void setUnit(String unit) {
            this.unit=unit;
            ScaleMeasure.setText(unit);
        }
     
        public Double getMax() {
            return (this.max);
        }
     
        public Double getMin() {
            return (this.min);
        }
     
        public void setMax(Double max) {
            this.max=max;
            ScaleValue1.setText(Double.toString(max));
            double step=round(((max-min)/11),4);   
            ScaleValue2.setText(Double.toString(min+step));
            ScaleValue3.setText(Double.toString(min+2*step));
            ScaleValue4.setText(Double.toString(min+3*step));
            ScaleValue5.setText(Double.toString(min+4*step));
            ScaleValue6.setText(Double.toString(min+5*step));
            ScaleValue7.setText(Double.toString(min+6*step));
            ScaleValue8.setText(Double.toString(min+7*step));
            ScaleValue9.setText(Double.toString(min+8*step));
            ScaleValue10.setText(Double.toString(min+9*step));
        }    
     
        public void setMin(Double min) {
            this.min=min;
            ScaleValue11.setText(Double.toString(min));
            double step=round(((max-min)/11),4);        
            ScaleValue2.setText(Double.toString(min+step));
            ScaleValue3.setText(Double.toString(min+2*step));
            ScaleValue4.setText(Double.toString(min+3*step));
            ScaleValue5.setText(Double.toString(min+4*step));
            ScaleValue6.setText(Double.toString(min+5*step));
            ScaleValue7.setText(Double.toString(min+6*step));
            ScaleValue8.setText(Double.toString(min+7*step));
            ScaleValue9.setText(Double.toString(min+8*step));
            ScaleValue10.setText(Double.toString(min+9*step));
        }
     
        public Boolean getOpaque(){
            return (this.opq);
        }
     
     
        public void setOpaque(){
            this.opq=opq;
            Scale.setOpaque(opq);
        }
        /** 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() {
     
            ScaleColor = new javax.swing.JLabel();
            ScaleValue1 = new javax.swing.JLabel();
            ScaleValue2 = new javax.swing.JLabel();
            ScaleValue3 = new javax.swing.JLabel();
            ScaleValue4 = new javax.swing.JLabel();
            ScaleValue5 = new javax.swing.JLabel();
            ScaleValue6 = new javax.swing.JLabel();
            ScaleValue7 = new javax.swing.JLabel();
            ScaleValue8 = new javax.swing.JLabel();
            ScaleValue9 = new javax.swing.JLabel();
            ScaleValue10 = new javax.swing.JLabel();
            ScaleValue11 = new javax.swing.JLabel();
            ScaleMeasure = new javax.swing.JLabel();
     
            setBackground(new java.awt.Color(255, 255, 255));
     
            ScaleColor.setIcon(new javax.swing.ImageIcon(getClass().getResource("/scale/scale.PNG"))); // NOI18N
     
            ScaleValue1.setText("sc11");
     
            ScaleValue2.setText("sc10");
     
            ScaleValue3.setText("sc9");
     
            ScaleValue4.setText("sc8");
     
            ScaleValue5.setText("sc7");
     
            ScaleValue6.setText("sc6");
     
            ScaleValue7.setText("sc5");
     
            ScaleValue8.setText("sc4");
     
            ScaleValue9.setText("sc3");
     
            ScaleValue10.setText("sc2");
     
            ScaleValue11.setText("sc1");
     
            ScaleMeasure.setText("ScaleMeasure");
     
            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
            this.setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(ScaleColor)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(ScaleValue11, javax.swing.GroupLayout.DEFAULT_SIZE, 59, Short.MAX_VALUE)
                                .addComponent(ScaleValue10, javax.swing.GroupLayout.DEFAULT_SIZE, 59, Short.MAX_VALUE)
                                .addComponent(ScaleValue9, javax.swing.GroupLayout.DEFAULT_SIZE, 59, Short.MAX_VALUE)
                                .addComponent(ScaleValue8, javax.swing.GroupLayout.DEFAULT_SIZE, 59, Short.MAX_VALUE)
                                .addComponent(ScaleValue7, javax.swing.GroupLayout.DEFAULT_SIZE, 59, Short.MAX_VALUE)
                                .addComponent(ScaleValue6, javax.swing.GroupLayout.DEFAULT_SIZE, 59, Short.MAX_VALUE)
                                .addComponent(ScaleValue5, javax.swing.GroupLayout.DEFAULT_SIZE, 59, Short.MAX_VALUE)
                                .addComponent(ScaleValue3, javax.swing.GroupLayout.DEFAULT_SIZE, 59, Short.MAX_VALUE)
                                .addComponent(ScaleValue1, javax.swing.GroupLayout.DEFAULT_SIZE, 59, Short.MAX_VALUE)
                                .addComponent(ScaleValue2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 59, Short.MAX_VALUE)
                                .addComponent(ScaleValue4, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 59, Short.MAX_VALUE)))
                        .addComponent(ScaleMeasure, javax.swing.GroupLayout.DEFAULT_SIZE, 83, Short.MAX_VALUE))
                    .addContainerGap())
            );
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                    .addComponent(ScaleMeasure)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(ScaleValue1)
                            .addGap(18, 18, 18)
                            .addComponent(ScaleValue2)
                            .addGap(18, 18, 18)
                            .addComponent(ScaleValue3)
                            .addGap(18, 18, 18)
                            .addComponent(ScaleValue4)
                            .addGap(18, 18, 18)
                            .addComponent(ScaleValue5)
                            .addGap(18, 18, 18)
                            .addComponent(ScaleValue6)
                            .addGap(18, 18, 18)
                            .addComponent(ScaleValue7)
                            .addGap(18, 18, 18)
                            .addComponent(ScaleValue8)
                            .addGap(18, 18, 18)
                            .addComponent(ScaleValue9)
                            .addGap(18, 18, 18)
                            .addComponent(ScaleValue10)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(ScaleValue11, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addComponent(ScaleColor, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 335, javax.swing.GroupLayout.PREFERRED_SIZE)))
            );
     
            layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {ScaleValue1, ScaleValue10, ScaleValue2, ScaleValue3, ScaleValue4, ScaleValue5, ScaleValue6, ScaleValue7, ScaleValue8, ScaleValue9});
     
        }// </editor-fold>
     
     
        // Variables declaration - do not modify
        private javax.swing.JLabel ScaleColor;
        private javax.swing.JLabel ScaleMeasure;
        private javax.swing.JLabel ScaleValue1;
        private javax.swing.JLabel ScaleValue10;
        private javax.swing.JLabel ScaleValue11;
        private javax.swing.JLabel ScaleValue2;
        private javax.swing.JLabel ScaleValue3;
        private javax.swing.JLabel ScaleValue4;
        private javax.swing.JLabel ScaleValue5;
        private javax.swing.JLabel ScaleValue6;
        private javax.swing.JLabel ScaleValue7;
        private javax.swing.JLabel ScaleValue8;
        private javax.swing.JLabel ScaleValue9;
        // End of variables declaration
        String unit;
        Double max=0.0, min=0.0;
        Boolean opq;
    }
    le premier se situe à ce niveau:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
        public Boolean getOpaque(){
            return (this.opq);
        }
     
     
        public void setOpaque(){
            this.opq=opq;
            Scale.setOpaque(opq);
        }
    ce composant etant la plupart du temps transparent, j'aimerais bien que la transparence soit parmis ses methodes. ca me donne l'erreur:
    non static method setopaque can't be referenced from static context
    .
    le deuxieme prob est à ce niveau:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
        public double round(double value, int dec) {
            double mult = Math.pow (10.0, (double)dec);
            return Math.round(value * mult) / mult;
        }
    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
        public Double getMax() {
            return (this.max);
        }
     
        public Double getMin() {
            return (this.min);
        }
     
        public void setMax(Double max) {
            this.max=max;
            ScaleValue1.setText(Double.toString(max));
            double step=round(((max-min)/11),4);   
            ScaleValue2.setText(Double.toString(min+step));
            ScaleValue3.setText(Double.toString(min+2*step));
            ScaleValue4.setText(Double.toString(min+3*step));
            ScaleValue5.setText(Double.toString(min+4*step));
            ScaleValue6.setText(Double.toString(min+5*step));
            ScaleValue7.setText(Double.toString(min+6*step));
            ScaleValue8.setText(Double.toString(min+7*step));
            ScaleValue9.setText(Double.toString(min+8*step));
            ScaleValue10.setText(Double.toString(min+9*step));
        }    
     
        public void setMin(Double min) {
            this.min=min;
            ScaleValue11.setText(Double.toString(min));
            double step=round(((max-min)/11),4);        
            ScaleValue2.setText(Double.toString(min+step));
            ScaleValue3.setText(Double.toString(min+2*step));
            ScaleValue4.setText(Double.toString(min+3*step));
            ScaleValue5.setText(Double.toString(min+4*step));
            ScaleValue6.setText(Double.toString(min+5*step));
            ScaleValue7.setText(Double.toString(min+6*step));
            ScaleValue8.setText(Double.toString(min+7*step));
            ScaleValue9.setText(Double.toString(min+8*step));
            ScaleValue10.setText(Double.toString(min+9*step));
        }
    c'est la methode round qui n'est pas vraiment efficace. si je reste dans les valeurs inferieures à 1000 ça va ça arrondit comme il se doit. mais ces lors que les nombres s'ecrivent avec des exposants (ex: 2E6, 47.65E5), il n'arrondit plus le nobre qui est avant l'exposant. connaissez vous une autre methode pour arrondire qui fonctionnerait meme avec les gros nombres?

    pour le troixieme probleme, il s'ajit de graphique:
    le composant en question est un jpanel qui contient exclusivement des jLabel.
    je voudrais en redimentionnant le Panel que les labels suivent. le ScaleColor, devrait s'allonger et retrecire avec le panel. l'icone qu'il contient (scale.png) devrait suivre. le ScaleMeasure reste inerte aux changements. les autres ScaleValue1-11 devraient s'eloigner et se rapprocher en gardant une distance identique des uns / aux autres.
    si joint tout le dossier si besoin.
    merci
    "Celui qui n'a jamais fait d'erreurs n'a jamais rien essayé"A. Einstein
    "La différence entre la stupidité et le génie est que le génie a ses limites"A. Einstein
    "c'est en forgeant qu'on devient forgeron"

  6. #6
    Membre habitué Avatar de ABN84
    Inscrit en
    Octobre 2007
    Messages
    410
    Détails du profil
    Informations personnelles :
    Âge : 39

    Informations forums :
    Inscription : Octobre 2007
    Messages : 410
    Points : 149
    Points
    149
    Par défaut
    bonsoir,
    le premier se situe à ce niveau:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
        public Boolean getOpaque(){
            return (this.opq);
        }
     
     
        public void setOpaque(){
            this.opq=opq;
            Scale.setOpaque(opq);
        }
    resolu comme suit:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
        public Boolean getOpaque(){
            return (this.opq);
        }
     
     
        public void setOpaque(){
            this.opq=opq;
            this.setOpaque(opq);
        }
    reste les deux autres.
    j'espere que quelcun pourra m'eclairer.
    merci.
    "Celui qui n'a jamais fait d'erreurs n'a jamais rien essayé"A. Einstein
    "La différence entre la stupidité et le génie est que le génie a ses limites"A. Einstein
    "c'est en forgeant qu'on devient forgeron"

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

Discussions similaires

  1. [struts] Compiler un bean avec netBeans
    Par Invité dans le forum NetBeans
    Réponses: 2
    Dernier message: 29/12/2005, 17h15
  2. [netbeans] debugg avec netbeans questions ???!!!
    Par nadass dans le forum NetBeans
    Réponses: 8
    Dernier message: 10/03/2005, 12h16
  3. [NetBeans] Comment creer des Beans sous Netbeans 4.0
    Par Turtle dans le forum NetBeans
    Réponses: 2
    Dernier message: 16/01/2005, 20h44
  4. Interfaces avec NetBeans
    Par messier79 dans le forum NetBeans
    Réponses: 3
    Dernier message: 26/04/2004, 15h55
  5. Applet avec NetBeans
    Par Kevgeii dans le forum NetBeans
    Réponses: 7
    Dernier message: 29/03/2004, 11h30

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