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

AWT/Swing Java Discussion :

Colors un Type Inconnu.


Sujet :

AWT/Swing Java

  1. #1
    Membre confirmé Avatar de CORTEZ
    Profil pro
    Dev : Java/J2EE
    Inscrit en
    Juillet 2007
    Messages
    59
    Détails du profil
    Informations personnelles :
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Dev : Java/J2EE
    Secteur : Service public

    Informations forums :
    Inscription : Juillet 2007
    Messages : 59
    Par défaut Colors un Type Inconnu.
    salut,

    J’ai trouvé dans un tutorial qui introduit les nouvelles fonctions de SwingX un type inconnu "Colors".
    Je l’ai trouvé exactement dans le tuto des Painters .
    Même la reconnaissance auomatique des types d’eclipse n’a pas marché.

    voici le lien http://developerlife.com/tutorials/?p=140

    Qui connaît ce type ?

  2. #2
    Membre expérimenté
    Profil pro
    Dev NodeJS
    Inscrit en
    Août 2006
    Messages
    177
    Détails du profil
    Informations personnelles :
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Dev NodeJS

    Informations forums :
    Inscription : Août 2006
    Messages : 177
    Par défaut
    Un peu plus loin dans ta page:

    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
     
       1: import java.awt.*;
     
       2:  
     
       3: /**
     
       4:  * Colors is an enumeration class that makes it easier to work with colors. Methods are provided for
     
       5:  * conversion to hex strings, and for getting alpha channel colors.
     
       6:  *
     
       7:  * @author Nazmul Idris
     
       8:  * @version 1.0
     
       9:  * @since Apr 21, 2007, 12:55:24 PM
     
      10:  */
     
      11: public enum Colors {
     
      12:  
     
      13: //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
     
      14: // various colors in the pallete
     
      15: //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
     
      16:   Pink(255, 175, 175),
     
      17:   Green(159, 205, 20),
     
      18:   Orange(213, 113, 13),
     
      19:   Yellow(Color.yellow),
     
      20:   Red(189, 67, 67),
     
      21:   LightBlue(208, 223, 245),
     
      22:   Blue(Color.blue),
     
      23:   Black(0, 0, 0),
     
      24:   White(255, 255, 255),
     
      25:   Gray(Color.gray.getRed(), Color.gray.getGreen(), Color.gray.getBlue());
     
      26:  
     
      27: //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
     
      28: // constructors
     
      29: //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
     
      30:   
     
      31: Colors(Color c) {
     
      32:   _myColor = c;
     
      33: }
     
      34:  
     
      35: Colors(int r, int g, int b) {
     
      36:   _myColor = new Color(r, g, b);
     
      37: }
     
      38:  
     
      39: Colors(int r, int g, int b, int alpha) {
     
      40:   _myColor = new Color(r, g, b, alpha);
     
      41: }
     
      42:  
     
      43: Colors(float r, float g, float b, float alpha) {
     
      44:   _myColor = new Color(r, g, b, alpha);
     
      45: }
     
      46:  
     
      47: //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
     
      48: // data
     
      49: //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
     
      50:  
     
      51: private Color _myColor;
     
      52:  
     
      53: //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
     
      54: // methods
     
      55: //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
     
      56:  
     
      57: public Color alpha(float t) {
     
      58:   return new Color(_myColor.getRed(), _myColor.getGreen(), _myColor.getBlue(), (int) (t * 255f));
     
      59: }
     
      60:  
     
      61: public static Color alpha(Color c, float t) {
     
      62:   return new Color(c.getRed(), c.getGreen(), c.getBlue(), (int) (t * 255f));
     
      63: }
     
      64:  
     
      65: public Color color() { return _myColor; }
     
      66:  
     
      67: public Color color(float f) {
     
      68:   return alpha(f);
     
      69: }
     
      70:  
     
      71: public String toString() {
     
      72:   StringBuilder sb = new StringBuilder();
     
      73:   sb.append("r=")
     
      74:       .append(_myColor.getRed())
     
      75:       .append(", g=")
     
      76:       .append(_myColor.getGreen())
     
      77:       .append(", b=")
     
      78:       .append(_myColor.getBlue())
     
      79:       .append("\n");
     
      80:   return sb.toString();
     
      81: }
     
      82:  
     
      83: public String toHexString() {
     
      84:   Color c = _myColor;
     
      85:   StringBuilder sb = new StringBuilder();
     
      86:   sb.append("#");
     
      87:   sb.append(Integer.toHexString(_myColor.getRed()));
     
      88:   sb.append(Integer.toHexString(_myColor.getGreen()));
     
      89:   sb.append(Integer.toHexString(_myColor.getBlue()));
     
      90:   return sb.toString();
     
      91: }
     
      92:  
     
      93: }//end enum Colors
    Rien a voir avec SwingX...

  3. #3
    Membre confirmé Avatar de CORTEZ
    Profil pro
    Dev : Java/J2EE
    Inscrit en
    Juillet 2007
    Messages
    59
    Détails du profil
    Informations personnelles :
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Dev : Java/J2EE
    Secteur : Service public

    Informations forums :
    Inscription : Juillet 2007
    Messages : 59
    Par défaut
    oui c'est ça ce que je cherche un contrusctuer avec un argument "alpha",
    mais juste une question ce type est-t- il integré dans le JDK 1.5.

    par ce que
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
       6: /*
     
       9:  * @since Apr 21, 2007, 12:55:24 PM
     
      10:  */

  4. #4
    Membre chevronné Avatar de ngpub
    Profil pro
    Inscrit en
    Mai 2008
    Messages
    449
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2008
    Messages : 449
    Par défaut
    ?! As-tu regardé la classe Color ?

  5. #5
    Membre confirmé Avatar de CORTEZ
    Profil pro
    Dev : Java/J2EE
    Inscrit en
    Juillet 2007
    Messages
    59
    Détails du profil
    Informations personnelles :
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Dev : Java/J2EE
    Secteur : Service public

    Informations forums :
    Inscription : Juillet 2007
    Messages : 59
    Par défaut
    Citation Envoyé par ngpub Voir le message
    ?! As-tu regardé la classe Color ?
    oui, mais la transparence alpha ne s'applique pas sur les painters avec le type color.

  6. #6
    Membre Expert
    Avatar de natha
    Profil pro
    Inscrit en
    Janvier 2006
    Messages
    2 346
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Janvier 2006
    Messages : 2 346
    Par défaut
    Citation Envoyé par CORTEZ Voir le message
    oui, mais la transparence alpha ne s'applique pas sur les painters avec le type color.
    Pourquoi pas ?
    http://java.sun.com/javase/6/docs/ap...loat,%20float)

  7. #7
    Membre expérimenté
    Profil pro
    Dev NodeJS
    Inscrit en
    Août 2006
    Messages
    177
    Détails du profil
    Informations personnelles :
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Dev NodeJS

    Informations forums :
    Inscription : Août 2006
    Messages : 177
    Par défaut
    Citation Envoyé par CORTEZ Voir le message
    oui c'est ça ce que je cherche un contrusctuer avec un argument "alpha",
    mais juste une question ce type est-t- il integré dans le JDK 1.5.

    par ce que
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
       6: /*
     
       9:  * @since Apr 21, 2007, 12:55:24 PM
     
      10:  */
    Le type Colors est déclaré dans ton tuto! Le JDK n'a rien a voir, le type Color lui existe dans le JDK et supporte l'alpha (comme dit au dessus)

  8. #8
    Membre confirmé Avatar de CORTEZ
    Profil pro
    Dev : Java/J2EE
    Inscrit en
    Juillet 2007
    Messages
    59
    Détails du profil
    Informations personnelles :
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Dev : Java/J2EE
    Secteur : Service public

    Informations forums :
    Inscription : Juillet 2007
    Messages : 59
    Par défaut
    OK Merci çaaaa MAAAAARCHE avec Colors

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

Discussions similaires

  1. méthode de type inconnue
    Par robert_trudel dans le forum Qt
    Réponses: 2
    Dernier message: 27/09/2006, 12h34
  2. Paramètre de type inconnu
    Par Amoust dans le forum Bases de données
    Réponses: 3
    Dernier message: 07/08/2006, 09h20
  3. Stockage données de type inconnu
    Par jmartell dans le forum Administration
    Réponses: 3
    Dernier message: 06/06/2006, 15h49
  4. Fonction divisant argument de type inconnu
    Par Nasky dans le forum C
    Réponses: 9
    Dernier message: 29/07/2003, 01h32

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