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

Composants Java Discussion :

Jcombobox swingx autocompletable


Sujet :

Composants Java

  1. #1
    Membre habitué
    Profil pro
    Architecte de système d’information
    Inscrit en
    Janvier 2007
    Messages
    439
    Détails du profil
    Informations personnelles :
    Localisation : Etats-Unis

    Informations professionnelles :
    Activité : Architecte de système d’information

    Informations forums :
    Inscription : Janvier 2007
    Messages : 439
    Points : 178
    Points
    178
    Par défaut Jcombobox swingx autocompletable
    bonjour , est-il possible d'avoir un jcombobox autocompletable en swingx? j'en ai entendu parlé mais je n'ai pas trouvé sur google. merci

  2. #2
    Membre expérimenté
    Avatar de visiwi
    Profil pro
    Inscrit en
    Février 2008
    Messages
    1 050
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2008
    Messages : 1 050
    Points : 1 340
    Points
    1 340
    Par défaut
    Salut,

    Tu as un exemple tout en bas de la page.

  3. #3
    Membre habitué
    Profil pro
    Architecte de système d’information
    Inscrit en
    Janvier 2007
    Messages
    439
    Détails du profil
    Informations personnelles :
    Localisation : Etats-Unis

    Informations professionnelles :
    Activité : Architecte de système d’information

    Informations forums :
    Inscription : Janvier 2007
    Messages : 439
    Points : 178
    Points
    178
    Par défaut Autocompletion SwingX Textfield
    Bonjour , j'ai trouvé un script sur la complétion automatique:

    http://xpose.avenir.asso.fr/viewxpos...ge=/swingX.php

    Mais ça ne marche pas

    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
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
     
    /*
     * TextFieldAutoComplete.java
     *
     * Created on Oct 25, 2009, 5:34:09 PM
     */
     
    package swingx;
     
    import java.awt.List;
    import java.util.Vector;
    import javax.swing.JList;
    import javax.swing.JTextField;
    import org.jdesktop.swingx.autocomplete.Configurator;
     
     
    /**
     *
     * @author Administrator
     */
    public class TextFieldAutoComplete extends javax.swing.JDialog {
        private final Configurator config = new org.jdesktop.swingx.autocomplete.Configurator();
     
        /** Creates new form TextFieldAutoComplete */
        public TextFieldAutoComplete(java.awt.Frame parent, boolean modal) {
            super(parent, modal);
            initComponents();
     
    	JTextField textField = new JTextField();
            textField.setText("Remi");
    	/* On ajoute le manager qui fera la completion dans le textField avec les champs de la JList */
     
     
            Vector v = new Vector();
            v.add("Jimmy");
            v.add("Julie");
            v.add("Julien");
            v.add("Juliette");
     
            JList list = new JList(v);
     
    	/* On ajoute le manager qui fera la completion dans le textField avec les champs de la JList */
    	Configurator.enableAutoCompletion(list, textField);
     
            this.add(textField);
     
     
        }
     
        /** 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.
         */
        @SuppressWarnings("unchecked")
        // <editor-fold defaultstate="collapsed" desc="Generated Code">
        private void initComponents() {
     
            jPanel1 = new javax.swing.JPanel();
            jTextField1 = new javax.swing.JTextField();
     
            setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
     
            jTextField1.setText("jTextField1");
     
            javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
            jPanel1.setLayout(jPanel1Layout);
            jPanel1Layout.setHorizontalGroup(
                jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel1Layout.createSequentialGroup()
                    .addGap(109, 109, 109)
                    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(132, Short.MAX_VALUE))
            );
            jPanel1Layout.setVerticalGroup(
                jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel1Layout.createSequentialGroup()
                    .addGap(60, 60, 60)
                    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(136, Short.MAX_VALUE))
            );
     
            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(29, 29, 29)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGap(71, 71, 71))
            );
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                    .addContainerGap(45, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(39, 39, 39))
            );
     
            pack();
        }// </editor-fold>
     
        /**
        * @param args the command line arguments
        */
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    TextFieldAutoComplete dialog = new TextFieldAutoComplete(new javax.swing.JFrame(), true);
                    dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                        public void windowClosing(java.awt.event.WindowEvent e) {
                            System.exit(0);
                        }
                    });
                    dialog.setVisible(true);
                }
            });
        }
     
        // Variables declaration - do not modify
        private javax.swing.JPanel jPanel1;
        private javax.swing.JTextField jTextField1;
        // End of variables declaration
     
    }

  4. #4
    Expert éminent sénior
    Avatar de sinok
    Profil pro
    Inscrit en
    Août 2004
    Messages
    8 765
    Détails du profil
    Informations personnelles :
    Âge : 44
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Août 2004
    Messages : 8 765
    Points : 12 977
    Points
    12 977
    Par défaut
    Merci de chercher de détailler un tant soit peu l'erreur/le problème plutôt que de balancer un paquet de code de layout inutile à la compréhension du problème.

    Accessoirement un tuto contenant les diverses méthodes permettant d'avoir de l'autocomplétion sur une JComboBox: http://today.java.net/pub/a/today/20...omboboxes.html

    Accessoirement certaines des solutions marchent également pour des JTextFields

    En l'occurence le papier que tu utilises comme référence date fortement et les API de SwingX ont changé depuis. http://swinglabs.org/hudson/job/SwingX Continuous Build/javadoc/org/jdesktop/swingx/autocomplete/AutoCompleteDecorator.html
    Hey, this is mine. That's mine. All this is mine. I'm claiming all this as mine. Except that bit. I don't want that bit. But all the rest of this is mine. Hey, this has been a really good day. I've eaten five times, I've slept six times, and I've made a lot of things mine. Tomorrow, I'm gonna see if I can't have sex with something.

Discussions similaires

  1. Réponses: 5
    Dernier message: 31/03/2014, 16h21
  2. Autocompletion évoluée JTextField ou JCombobox
    Par Tazz54oli dans le forum Général Java
    Réponses: 1
    Dernier message: 24/06/2013, 13h05
  3. Réponses: 2
    Dernier message: 03/05/2013, 13h34
  4. SwingX et l'autocomplete
    Par kldamr dans le forum Général Java
    Réponses: 1
    Dernier message: 06/07/2010, 12h29
  5. SwingX AutoCompletion event
    Par debutJava dans le forum AWT/Swing
    Réponses: 1
    Dernier message: 09/10/2006, 14h42

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