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 :

Evenement de click sur une cellule de JTable


Sujet :

Composants Java

  1. #1
    Membre régulier Avatar de mitnick2006
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Décembre 2006
    Messages
    163
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 37
    Localisation : Maroc

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Décembre 2006
    Messages : 163
    Points : 106
    Points
    106
    Par défaut Evenement de click sur une cellule de JTable
    salut tous
    je veux appliquer un evenement de click sur une cellule de jtable pour la modifier.

    j ai appliqué une fonction qui fais l édition automatique de la base dans une classe qui hérite de TableCellRenderer.
    et ca marche mais le compilateur me donne beaucoup de warnings qui interrompent le programme par la suite voici le code
    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
     
    		class DemoCellRenderer extends JLabel implements TableCellRenderer { 
            boolean isBordered = true; 
            Color selectedForeground = null; 
            Color selectedBackground = null; 
            Color unselectedForegroundAlt = null; 
            Color unselectedBackgroundAlt = new Color( 255, 255, 255 ); 
            Color unselectedForeground = null; 
            Color unselectedBackground = null; 
     
            public DemoCellRenderer() { 
                super(); 
                setOpaque(true);
                }
     
                 //pour remplir le tableau
            public Component getTableCellRendererComponent( 
            JTable table, Object val, 
            boolean isSelected, boolean hasFocus, 
            int row, int column) { 
                setAlignmentX( CENTER_ALIGNMENT ); 
     
     
                Font f = getFont(); 
                if ( isSelected ) { 
                    setFont( new Font( f.getName(), Font.PLAIN|Font.ITALIC, f.getSize() ) ); 
     
                    super.setForeground( ( selectedForeground != null) ? selectedForeground : table.getSelectionForeground() ); 
                    super.setBackground( ( selectedBackground != null) ? selectedBackground : table.getSelectionBackground() ); 
     
                } 
                else { 
                    setFont( new Font( f.getName(), Font.PLAIN, f.getSize() ) ); 
     
                    if ( ((column)>>1)<<1 == column - (row-((row>>1)<<1)) ) { 
                        super.setForeground( ( unselectedForegroundAlt != null) ? unselectedForegroundAlt : table.getForeground() ); 
                        super.setBackground( ( unselectedBackgroundAlt != null) ? unselectedBackgroundAlt : table.getBackground() ); 
                    } 
                    else { 
                        super.setForeground( ( unselectedForeground != null) ? unselectedForeground : table.getForeground() ); 
                        super.setBackground( ( unselectedBackground != null) ? unselectedBackground : table.getBackground() ); 
                    } 
                } 
                setText( (String)val ); 
               //mise a jour de la base de données automatiquement.
     
             update_Row(column); 
               return this; 
            } 
     
    	}
    et merci en avance

  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,

    Pourrait-tu être plus précis ?

    le compilateur me donne beaucoup de warnings qui interrompent le programme par la suite
    Ce sont les Exceptions qui interrompent le programme par la suite.

    Qu'elle est le message de l'exception qui est affiché dans la console ?

  3. #3
    Membre régulier Avatar de mitnick2006
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Décembre 2006
    Messages
    163
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 37
    Localisation : Maroc

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Décembre 2006
    Messages : 163
    Points : 106
    Points
    106
    Par défaut
    Citation Envoyé par visiwi Voir le message
    Salut,

    Qu'elle est le message de l'exception qui est affiché dans la console ?
    voila le message qui s'affiche dans la console
    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
     
    com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Champ 'Citerne' inconnu dans field list
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at  sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
        at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
        at com.mysql.jdbc.Util.getInstance(Util.java:381)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1031)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:957)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3376)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3308)
        at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1837)
        at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1961)
        at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2537)
        at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1564)
        at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1485)
        at base.execute_update(base.java:104)
        at Grille.update_Row(Grille.java:385)
        at Grille$DemoCellRenderer.getTableCellRendererComponent(Grille.java:222)
        at javax.swing.JTable.prepareRenderer(JTable.java:5683)
        at javax.swing.plaf.basic.BasicTableUI.paintCell(BasicTableUI.java:2067)
        at javax.swing.plaf.basic.BasicTableUI.paintCells(BasicTableUI.java:1969)
        at javax.swing.plaf.basic.BasicTableUI.paint(BasicTableUI.java:1765)
        at javax.swing.plaf.ComponentUI.update(ComponentUI.java:143)
        at javax.swing.JComponent.paintComponent(JComponent.java:758)
        at javax.swing.JComponent.paint(JComponent.java:1022)
        at javax.swing.JComponent.paintChildren(JComponent.java:859)
        at javax.swing.JComponent.paint(JComponent.java:1031)
        at javax.swing.JViewport.paint(JViewport.java:747)
        at javax.swing.JComponent.paintChildren(JComponent.java:859)
        at javax.swing.JComponent.paint(JComponent.java:1031)
        at javax.swing.JComponent.paintChildren(JComponent.java:859)
        at javax.swing.JComponent.paint(JComponent.java:1031)
        at javax.swing.JComponent.paintChildren(JComponent.java:859)
        at javax.swing.JComponent.paint(JComponent.java:1031)
        at javax.swing.JComponent.paintChildren(JComponent.java:859)
        at javax.swing.JComponent.paint(JComponent.java:1031)
        at javax.swing.JLayeredPane.paint(JLayeredPane.java:564)
        at javax.swing.JComponent.paintChildren(JComponent.java:859)
        at javax.swing.JComponent.paint(JComponent.java:1031)
        at javax.swing.JComponent.paintChildren(JComponent.java:859)
        at javax.swing.JComponent.paint(JComponent.java:1031)
        at javax.swing.JComponent.paintToOffscreen(JComponent.java:5104)
        at javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:285)
        at javax.swing.RepaintManager.paint(RepaintManager.java:1132)
        at javax.swing.JComponent._paintImmediately(JComponent.java:5052)
        at javax.swing.JComponent.paintImmediately(JComponent.java:4862)
        at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:727)
        at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:683)
        at javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:663)
        at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:128)
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)

  4. #4
    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
    Le problème ne vient pas de Swing mais indirectement de JDBC.

    Tu as une erreur SQL :
    Champ 'Citerne' inconnu dans field list
    Dans ta requête, tu fait référence à un champ Citerne qui n'existe pas !

Discussions similaires

  1. Réponses: 0
    Dernier message: 04/09/2009, 02h08
  2. Réponses: 1
    Dernier message: 21/07/2009, 22h18
  3. Evenement double click sur une ligne d'un DataGrid
    Par imad_eddine dans le forum ASP.NET
    Réponses: 7
    Dernier message: 19/11/2007, 17h24
  4. click sur une cellule
    Par jazziestan dans le forum Macros et VBA Excel
    Réponses: 2
    Dernier message: 28/12/2006, 17h13
  5. [VBA-E] Double-Click sur une cellule
    Par boosty dans le forum Macros et VBA Excel
    Réponses: 2
    Dernier message: 05/04/2006, 15h12

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