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

Forms Oracle Discussion :

[PJC modif] : Unsupported major.minor version 49.0


Sujet :

Forms Oracle

  1. #1
    Membre habitué Avatar de arnobase
    Profil pro
    Inscrit en
    Novembre 2006
    Messages
    151
    Détails du profil
    Informations personnelles :
    Âge : 43
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations forums :
    Inscription : Novembre 2006
    Messages : 151
    Points : 133
    Points
    133
    Par défaut [PJC modif] : Unsupported major.minor version 49.0
    bonjour,

    j'essaie de faire une modification au PJC GetImageFileName trouvé sur PJC-overblog afin de rectifier un problème au clic sur le bouton annuler (chez nous, il prends en compte la dernière photo uploadée)

    la compilation passe bien (j'utilise le jInit d'oracle pour compiler, et je l'ai déja utilisé avec succès pour compiler un autre PJC fonctionnant avec le Jinit) mais à l'exécution le message suivant s'affiche dans la console :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    Exception occurred during event dispatching:
     
    java.lang.UnsupportedClassVersionError: oracle/forms/fd/GetImageFileName (Unsupported major.minor version 49.0)
    at java.lang.ClassLoader.defineClass0(Native Method)
    ...
    je ne vois pas du tout d'ou cela peut-il provenir auriez vous une idée ?

    Merci de votre aide !

    Arnaud
    .
    La vie est un long torrent tranquile...

  2. #2
    Expert éminent sénior
    Avatar de SheikYerbouti
    Profil pro
    Inscrit en
    Mai 2003
    Messages
    6 760
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2003
    Messages : 6 760
    Points : 11 862
    Points
    11 862
    Par défaut
    La version 3 de ce bean, qui n'a pas besoin du JDBC pour communiquer avec la base nécessite, au moins un JRE 1.4, raison pour laquelle il ne fonctionne pas avec le JInitiator qui est resté au 1.3

    Vérifiez également que vous compilez avec un niveau de JRE 1.3
    Rédacteur Oracle (Oracle ACE)
    Guide Oracle ,Guide PL/SQL, Guide Forms 9i/10g, Index de recherche
    Je ne réponds pas aux questions techniques par MP
    Blogs: Forms-PL/SQL-J2EE - Forms Java Beans

  3. #3
    Membre actif
    Profil pro
    Inscrit en
    Avril 2004
    Messages
    422
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Avril 2004
    Messages : 422
    Points : 201
    Points
    201
    Par défaut
    En effet, jinit tourne sur une jvm 1.3 à la souce oracle.
    Donc, vous devez éviter des appels à des classes qui ne se trouve pas en 1.3.

  4. #4
    Membre habitué Avatar de arnobase
    Profil pro
    Inscrit en
    Novembre 2006
    Messages
    151
    Détails du profil
    Informations personnelles :
    Âge : 43
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations forums :
    Inscription : Novembre 2006
    Messages : 151
    Points : 133
    Points
    133
    Par défaut
    voici le code que je compile avec succes en 1.3 (j'ai utilisé le jInit Oracle comme librairie pour la compilation)

    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
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    package oracle.forms.fd;
     
    import javax.swing.*;
    import java.beans.*;
    import java.awt.*;
    import java.io.File;
    import java.util.Hashtable;
    import java.util.Enumeration;
    import javax.swing.filechooser.*;
     
     
    /**
     * A javabean to display an Open-dialog bow with image preview
     *
     * @version 1.0
     * @date    20-oct-2005
     * @author  Francois Degrelle
     */
     
    public class GetImageFileName extends Component
    {
     
      public String string = "" ;
     
      public GetImageFileName()
      {
        super();
      }
     
      /**
       * method to display the OpenFile dialog.
       *
       * @param  the title for the dialog
       * @param  the starting directory
       * @return the selected file name (or null)
       */
      public String GetFile(String dialogTitle, String startDirectory)
      {
        String sFileName = "" ;
        Filters.setTitle( dialogTitle ) ;
        Filters.setDir( startDirectory ) ;
        sFileName = Filters.Start() ;
        return sFileName ;
      }
     
      public void setString(String s)
      {
        string = s ;
        System.out.println("s="+string);
      }
     
      public String getString()
      {
        return string ;
      }
     
     
      public void SetLAF(String s)
      {
        if(s.equalsIgnoreCase("SYSTEM"))
        {
        try
        {
          //System.out.println(UIManager.getLookAndFeelDefaults());
          UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
          SwingUtilities.updateComponentTreeUI(this);
        }
        catch (Exception ex)
        {
          ex.printStackTrace();
        }      
        }
        else
        {
        try
        {
          //System.out.println(UIManager.getLookAndFeelDefaults());
          UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
          SwingUtilities.updateComponentTreeUI(this);
        }
        catch (Exception ex)
        {
          ex.printStackTrace();
        }      
        }
      }
     
    }
     
    /**
     * class that handle the JFileChooser
     */
    class Filters extends JLabel implements PropertyChangeListener {
         private static final int ICON_WIDTH  = 150;
         private static final int ICON_HEIGHT = 150;
         private static String fileName = "" ;
         private static String sTitle   = "" ;     
         private static String startDir = "." ;
         private static String sFilters = "" ;
     
         // Set the dialog box title
         public static void setTitle( String title ) 
         {
           sTitle = title ;
           //System.out.println("**** sTitle="+sTitle);
         }
     
         // Set the start directory
         public static void setDir( String directory ) 
         {
           startDir = directory ;
           //System.out.println("**** startdir="+startDir);
         }
     
         // Add the image previewer to the dialog box
         public Filters(JFileChooser chooser) {
           setVerticalAlignment(JLabel.CENTER);
           setHorizontalAlignment(JLabel.CENTER);
           chooser.addPropertyChangeListener(this);
           setPreferredSize(new Dimension (ICON_WIDTH, ICON_HEIGHT));
         }   
         public void propertyChange(
           PropertyChangeEvent changeEvent) {
            String changeName = changeEvent.getPropertyName();
            if (changeName.equals
                (JFileChooser.SELECTED_FILE_CHANGED_PROPERTY)) {
                    File file = (File)changeEvent.getNewValue();
                    if (file != null) {
                            ImageIcon icon = new ImageIcon(file.getPath());
                    if (icon.getIconWidth() > ICON_WIDTH) {
                            icon = new ImageIcon(
                            icon.getImage().getScaledInstance(ICON_WIDTH, -1, Image.SCALE_DEFAULT));
                    if (icon.getIconHeight() > ICON_HEIGHT) {
                            icon = new ImageIcon(
                            icon.getImage().getScaledInstance(-1, ICON_HEIGHT, Image.SCALE_DEFAULT));
                    }
              }
              setIcon(icon);
             }
           }
         }
     
         public static String Start() {
     
               fileName = "" ;
               JFileChooser fileChooser = new JFileChooser(startDir);
               LabelAccessory accessory = new LabelAccessory(fileChooser);
               fileChooser.setDialogTitle(sTitle);
               fileChooser.setLocation(50,50);
               fileChooser.setPreferredSize(new Dimension(600,400));
               // Set the filter
               ExampleFileFilter filter = new ExampleFileFilter("jpg");
               filter.addExtension("jpeg");
               filter.addExtension("gif");
               filter.addExtension("png");
               filter.setDescription("Jpg,Jpeg,Gif & Png Files");
               fileChooser.addChoosableFileFilter(filter);       
     
               fileChooser.setAccessory(accessory);
               fileChooser.addPropertyChangeListener
                   (JFileChooser.SELECTED_FILE_CHANGED_PROPERTY, accessory);
               int status = fileChooser.showOpenDialog(null);
               fileName = "" ;
               if (status == JFileChooser.APPROVE_OPTION) {
                 File selectedFile = fileChooser.getSelectedFile();
                 fileName = selectedFile.getParent() + selectedFile.separator + selectedFile.getName() ;
     
               }
     
           return fileName ;
         }
     
       public static class LabelAccessory extends JLabel implements PropertyChangeListener {
         private static final int ICON_WIDTH  = 150;
         private static final int ICON_HEIGHT = 150;
     
         public LabelAccessory(JFileChooser chooser) {
           setVerticalAlignment(JLabel.CENTER);
           setHorizontalAlignment(JLabel.CENTER);
           chooser.addPropertyChangeListener(this);
           setPreferredSize(new Dimension(ICON_WIDTH, ICON_HEIGHT));
         }   
         public void propertyChange(
           PropertyChangeEvent changeEvent) {
            String changeName = changeEvent.getPropertyName();
            if (changeName.equals(JFileChooser.SELECTED_FILE_CHANGED_PROPERTY)) {
                    File file = (File)changeEvent.getNewValue();
                    if (file != null) {
                            ImageIcon icon = new ImageIcon(file.getPath());
                    if (icon.getIconWidth() > ICON_WIDTH) {
                            icon = new ImageIcon(icon.getImage().getScaledInstance(ICON_WIDTH, -1, Image.SCALE_DEFAULT));
                    if (icon.getIconHeight() > ICON_HEIGHT) {
                            icon = new ImageIcon(icon.getImage().getScaledInstance(-1, ICON_HEIGHT, Image.SCALE_DEFAULT));
                    }
              }
              setIcon(icon);
             }
           }
         }
       }
     
    /**
     * A convenience implementation of FileFilter that filters out
     * all files except for those type extensions that it knows about.
     *
     * Extensions are of the type ".foo", which is typically found on
     * Windows and Unix boxes, but not on Macinthosh. Case is ignored.
     *
     * Example - create a new filter that filerts out all files
     * but gif and jpg image files:
     *
     *     JFileChooser chooser = new JFileChooser();
     *     ExampleFileFilter filter = new ExampleFileFilter(
     *                   new String{"gif", "jpg"}, "JPEG & GIF Images")
     *     chooser.addChoosableFileFilter(filter);
     *     chooser.showOpenDialog(this);
     *
     * @version 1.9 04/23/99
     * @author Jeff Dinkins
     */
    public static class ExampleFileFilter extends FileFilter {
     
        private String TYPE_UNKNOWN = "Type Unknown";
        private String HIDDEN_FILE = "Hidden File";
     
        private Hashtable filters = null;
        private String description = null;
        private String fullDescription = null;
        private boolean useExtensionsInDescription = true;
     
        /**
         * Creates a file filter. If no filters are added, then all
         * files are accepted.
         *
         * @see #addExtension
         */
        public ExampleFileFilter() {
            this.filters = new Hashtable();
        }
     
        /**
         * Creates a file filter that accepts files with the given extension.
         * Example: new ExampleFileFilter("jpg");
         *
         * @see #addExtension
         */
        public ExampleFileFilter(String extension) {
            this(extension,null);
        }
     
        /**
         * Creates a file filter that accepts the given file type.
         * Example: new ExampleFileFilter("jpg", "JPEG Image Images");
         *
         * Note that the "." before the extension is not needed. If
         * provided, it will be ignored.
         *
         * @see #addExtension
         */
        public ExampleFileFilter(String extension, String description) {
            this();
            if(extension!=null) addExtension(extension);
            if(description!=null) setDescription(description);
        }
     
        /**
         * Creates a file filter from the given string array.
         * Example: new ExampleFileFilter(String {"gif", "jpg"});
         *
         * Note that the "." before the extension is not needed adn
         * will be ignored.
         *
         * @see #addExtension
         */
        public ExampleFileFilter(String[] filters) {
            this(filters, null);
        }
     
        /**
         * Creates a file filter from the given string array and description.
         * Example: new ExampleFileFilter(String {"gif", "jpg"}, "Gif and JPG Images");
         *
         * Note that the "." before the extension is not needed and will be ignored.
         *
         * @see #addExtension
         */
        public ExampleFileFilter(String[] filters, String description) {
            this();
            for (int i = 0; i < filters.length; i++) {
                // add filters one by one
                addExtension(filters[i]);
            }
            if(description!=null) setDescription(description);
        }
     
        /**
         * Return true if this file should be shown in the directory pane,
         * false if it shouldn't.
         *
         * Files that begin with "." are ignored.
         *
         * @see #getExtension
         * @see FileFilter#accepts
         */
        public boolean accept(File f) {
            if(f != null) {
                if(f.isDirectory()) {
                    return true;
                }
                String extension = getExtension(f);
                if(extension != null && filters.get(getExtension(f)) != null) {
                    return true;
                };
            }
            return false;
        }
     
        /**
         * Return the extension portion of the file's name .
         *
         * @see #getExtension
         * @see FileFilter#accept
         */
        public String getExtension(File f) {
            if(f != null) {
                String filename = f.getName();
                int i = filename.lastIndexOf('.');
                if(i>0 && i<filename.length()-1) {
                    return filename.substring(i+1).toLowerCase();
                };
            }
            return null;
        }
     
        /**
         * Adds a filetype "dot" extension to filter against.
         *
         * For example: the following code will create a filter that filters
         * out all files except those that end in ".jpg" and ".tif":
         *
         *   ExampleFileFilter filter = new ExampleFileFilter();
         *   filter.addExtension("jpg");
         *   filter.addExtension("tif");
         *
         * Note that the "." before the extension is not needed and will be ignored.
         */
        public void addExtension(String extension) {
            if(filters == null) {
                filters = new Hashtable(5);
            }
            filters.put(extension.toLowerCase(), this);
            fullDescription = null;
        }
     
     
        /**
         * Returns the human readable description of this filter. For
         * example: "JPEG and GIF Image Files (*.jpg, *.gif)"
         *
         * @see setDescription
         * @see setExtensionListInDescription
         * @see isExtensionListInDescription
         * @see FileFilter#getDescription
         */
        public String getDescription() {
            if(fullDescription == null) {
                if(description == null || isExtensionListInDescription()) {
                    fullDescription = description==null ? "(" : description + " (";
                    // build the description from the extension list
                    Enumeration extensions = filters.keys();
                    if(extensions != null) {
                        fullDescription += "." + (String) extensions.nextElement();
                        while (extensions.hasMoreElements()) {
                            fullDescription += ", " + (String) extensions.nextElement();
                        }
                    }
                    fullDescription += ")";
                } else {
                    fullDescription = description;
                }
            }
            return fullDescription;
        }
     
        /**
         * Sets the human readable description of this filter. For
         * example: filter.setDescription("Gif and JPG Images");
         *
         * @see setDescription
         * @see setExtensionListInDescription
         * @see isExtensionListInDescription
         */
        public void setDescription(String description) {
            this.description = description;
            fullDescription = null;
        }
     
        /**
         * Determines whether the extension list (.jpg, .gif, etc) should
         * show up in the human readable description.
         *
         * Only relevent if a description was provided in the constructor
         * or using setDescription();
         *
         * @see getDescription
         * @see setDescription
         * @see isExtensionListInDescription
         */
        public void setExtensionListInDescription(boolean b) {
            useExtensionsInDescription = b;
            fullDescription = null;
        }
     
        /**
         * Returns whether the extension list (.jpg, .gif, etc) should
         * show up in the human readable description.
         *
         * Only relevent if a description was provided in the constructor
         * or using setDescription();
         *
         * @see getDescription
         * @see setDescription
         * @see setExtensionListInDescription
         */
        public boolean isExtensionListInDescription() {
            return useExtensionsInDescription;
        }
    }
     
     
       }
    je l'ai trouvé à cette adresse : http://sheikyerbouti.developpez.com/...efilename.java

    pourquoi ne peut-il pas être exécuté avec le jInit puisqu'il compile en 1.3 ?

    il s'agirait de la version 1 de octobre 2005

    et voici le contenu de la classe Filter encapsulée dans GetImageFileName une fois décompilée avec Cavaj, on voit une petite différence entre les deux fichiers, notament dans la fonction Start, la variable fileName qui n'est pas réinitialisée

    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
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    package oracle.forms.fd;
     
    import java.awt.Dimension;
    import java.awt.Image;
    import java.beans.PropertyChangeEvent;
    import java.beans.PropertyChangeListener;
    import java.io.File;
    import java.io.PrintStream;
    import java.util.Enumeration;
    import java.util.Hashtable;
    import javax.swing.*;
    import javax.swing.filechooser.FileFilter;
     
    class Filters extends JLabel
        implements PropertyChangeListener
    {
        public static class ExampleFileFilter extends FileFilter
        {
     
            private String TYPE_UNKNOWN;
            private String HIDDEN_FILE;
            private Hashtable filters;
            private String description;
            private String fullDescription;
            private boolean useExtensionsInDescription;
     
            public boolean accept(File f)
            {
                if(f != null)
                {
                    if(f.isDirectory())
                    {
                        return true;
                    }
                    String extension = getExtension(f);
                    if(extension != null && filters.get(getExtension(f)) != null)
                    {
                        return true;
                    }
                }
                return false;
            }
     
            public String getExtension(File f)
            {
                if(f != null)
                {
                    String filename = f.getName();
                    int i = filename.lastIndexOf('.');
                    if(i > 0 && i < filename.length() - 1)
                    {
                        return filename.substring(i + 1).toLowerCase();
                    }
                }
                return null;
            }
     
            public void addExtension(String extension)
            {
                if(filters == null)
                {
                    filters = new Hashtable(5);
                }
                filters.put(extension.toLowerCase(), this);
                fullDescription = null;
            }
     
            public String getDescription()
            {
                if(fullDescription == null)
                {
                    if(description == null || isExtensionListInDescription())
                    {
                        fullDescription = description != null ? description + " (" : "(";
                        Enumeration extensions = filters.keys();
                        if(extensions != null)
                        {
                            for(fullDescription += "." + (String)extensions.nextElement(); extensions.hasMoreElements(); fullDescription += ", " + (String)extensions.nextElement()) { }
                        }
                        fullDescription += ")";
                    } else
                    {
                        fullDescription = description;
                    }
                }
                return fullDescription;
            }
     
            public void setDescription(String description)
            {
                this.description = description;
                fullDescription = null;
            }
     
            public void setExtensionListInDescription(boolean b)
            {
                useExtensionsInDescription = b;
                fullDescription = null;
            }
     
            public boolean isExtensionListInDescription()
            {
                return useExtensionsInDescription;
            }
     
            public ExampleFileFilter()
            {
                TYPE_UNKNOWN = "Type Unknown";
                HIDDEN_FILE = "Hidden File";
                filters = null;
                description = null;
                fullDescription = null;
                useExtensionsInDescription = true;
                filters = new Hashtable();
            }
     
            public ExampleFileFilter(String extension)
            {
                this(extension, null);
            }
     
            public ExampleFileFilter(String extension, String description)
            {
                this();
                if(extension != null)
                {
                    addExtension(extension);
                }
                if(description != null)
                {
                    setDescription(description);
                }
            }
     
            public ExampleFileFilter(String filters[])
            {
                this(filters, null);
            }
     
            public ExampleFileFilter(String filters[], String description)
            {
                this();
                for(int i = 0; i < filters.length; i++)
                {
                    addExtension(filters[i]);
                }
     
                if(description != null)
                {
                    setDescription(description);
                }
            }
        }
     
        public static class LabelAccessory extends JLabel
            implements PropertyChangeListener
        {
     
            private static final int ICON_WIDTH = 100;
            private static final int ICON_HEIGHT = 100;
     
            public void propertyChange(PropertyChangeEvent changeEvent)
            {
                String changeName = changeEvent.getPropertyName();
                if(changeName.equals("SelectedFileChangedProperty"))
                {
                    File file = (File)changeEvent.getNewValue();
                    if(file != null)
                    {
                        ImageIcon icon = new ImageIcon(file.getPath());
                        if(icon.getIconWidth() > 100)
                        {
                            icon = new ImageIcon(icon.getImage().getScaledInstance(100, -1, 1));
                            if(icon.getIconHeight() > 100)
                            {
                                icon = new ImageIcon(icon.getImage().getScaledInstance(-1, 100, 1));
                            }
                        }
                        setIcon(icon);
                    }
                }
            }
     
            public LabelAccessory(JFileChooser chooser)
            {
                setVerticalAlignment(0);
                setHorizontalAlignment(0);
                chooser.addPropertyChangeListener(this);
                setPreferredSize(new Dimension(100, 100));
            }
        }
     
     
        private static final int ICON_WIDTH = 100;
        private static final int ICON_HEIGHT = 100;
        private static String fileName = "";
        private static String sTitle = "";
        private static String startDir = ".";
     
        public static void setTitle(String title)
        {
            sTitle = title;
        }
     
        public static void setDir(String directory)
        {
            startDir = directory;
        }
     
        public Filters(JFileChooser chooser)
        {
            setVerticalAlignment(0);
            setHorizontalAlignment(0);
            chooser.addPropertyChangeListener(this);
            setPreferredSize(new Dimension(100, 100));
        }
     
        public void propertyChange(PropertyChangeEvent changeEvent)
        {
            String changeName = changeEvent.getPropertyName();
            if(changeName.equals("SelectedFileChangedProperty"))
            {
                File file = (File)changeEvent.getNewValue();
                if(file != null)
                {
                    ImageIcon icon = new ImageIcon(file.getPath());
                    if(icon.getIconWidth() > 100)
                    {
                        icon = new ImageIcon(icon.getImage().getScaledInstance(100, -1, 1));
                        if(icon.getIconHeight() > 100)
                        {
                            icon = new ImageIcon(icon.getImage().getScaledInstance(-1, 100, 1));
                        }
                    }
                    setIcon(icon);
                }
            }
        }
     
        public static String Start()
        {
            JFileChooser fileChooser = new JFileChooser(startDir);
            LabelAccessory accessory = new LabelAccessory(fileChooser);
            fileChooser.setDialogTitle(sTitle);
            ExampleFileFilter filter = new ExampleFileFilter("jpg");
            filter.addExtension("gif");
            filter.setDescription("Jpeg & Gif Files");
            fileChooser.addChoosableFileFilter(filter);
            fileChooser.setAccessory(accessory);
            fileChooser.addPropertyChangeListener("SelectedFileChangedProperty", accessory);
            int status = fileChooser.showOpenDialog(null);
            if(status == 0)
            {
                File selectedFile = fileChooser.getSelectedFile();
                fileName = selectedFile.getParent() + File.separator + selectedFile.getName();
                System.out.println("filename= " + fileName);
            }
            return fileName;
        }
     
    }
    le jar d'ou provient cette source passe bien avec le Jinit, mais il ne s'agit vraissemblablement pas du même code ?

    merci beaucoup pour votre aide

    Arno
    .
    La vie est un long torrent tranquile...

Discussions similaires

  1. Unsupported major minor version
    Par reneguenon dans le forum Général Java
    Réponses: 11
    Dernier message: 05/06/2009, 15h00
  2. Réponses: 9
    Dernier message: 27/08/2008, 12h07
  3. Réponses: 1
    Dernier message: 12/06/2008, 10h40
  4. Unsupported major.minor version 49.0
    Par YPFine dans le forum Tomcat et TomEE
    Réponses: 7
    Dernier message: 12/01/2007, 17h10
  5. Unsupporter major.minor version 49.0
    Par hugo123 dans le forum Tomcat et TomEE
    Réponses: 1
    Dernier message: 25/09/2006, 17h46

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