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 :

Exception lors de l'impression


Sujet :

AWT/Swing Java

  1. #1
    Membre actif
    Profil pro
    Inscrit en
    Septembre 2005
    Messages
    504
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2005
    Messages : 504
    Points : 288
    Points
    288
    Par défaut Exception lors de l'impression
    Re-Bonjour,
    je debute pour l'impression d'une fenetre, j'ai donc fait des recherche sur le net, et j'ai trouver uns source, je l'ai implémenté, j'ai bien ma fenêtre pour choisir l'impression, mais une fois que je clik sur OK, j'ai une exception.
    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
     
    printMenuItem.addActionListener(new java.awt.event.ActionListener() { 
          	public void actionPerformed(java.awt.event.ActionEvent e) {    
              // @AM TODO
              Properties props = new Properties();
     
              props.put("awt.print.paperSize", "a4");
              props.put("awt.print.destination", "printer");
     
     
              PrintJob pJob = getToolkit().getPrintJob(MyFrame.this,
          			  "Printing_Test", props);
              if (pJob != null)
                {
                  Graphics pg = pJob.getGraphics();
                  printAll(pg);
                  pg.dispose();
                  pJob.end();
                }
          	}
          });
    et voila l'execption :
    Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: sun.print.ProxyPrintGraphics
    at com.incors.plaf.kunststoff.KunststoffUtilities.drawGradient(Unknown Source)
    at com.incors.plaf.kunststoff.KunststoffTabbedPaneUI.paintTab(Unknown Source)
    at javax.swing.plaf.basic.BasicTabbedPaneUI.paintTabArea(Unknown Source)
    at javax.swing.plaf.basic.BasicTabbedPaneUI.paint(Unknown Source)
    at javax.swing.plaf.ComponentUI.update(Unknown Source)
    at javax.swing.JComponent.paintComponent(Unknown Source)
    at javax.swing.JComponent.printComponent(Unknown Source)
    at javax.swing.JComponent.paint(Unknown Source)
    at javax.swing.JComponent.print(Unknown Source)
    at javax.swing.JComponent.paintChildren(Unknown Source)
    at javax.swing.JSplitPane.paintChildren(Unknown Source)
    at javax.swing.JComponent.printChildren(Unknown Source)
    at javax.swing.JComponent.paint(Unknown Source)
    at javax.swing.JComponent.print(Unknown Source)
    at javax.swing.JComponent.paintChildren(Unknown Source)
    at javax.swing.JComponent.printChildren(Unknown Source)
    at javax.swing.JComponent.paint(Unknown Source)
    at javax.swing.JComponent.print(Unknown Source)
    at javax.swing.JComponent.paintChildren(Unknown Source)
    at javax.swing.JComponent.printChildren(Unknown Source)
    at javax.swing.JComponent.paint(Unknown Source)
    at javax.swing.JLayeredPane.paint(Unknown Source)
    at javax.swing.JComponent.print(Unknown Source)
    at javax.swing.JComponent.paintChildren(Unknown Source)
    at javax.swing.JComponent.printChildren(Unknown Source)
    at javax.swing.JComponent.paint(Unknown Source)
    at javax.swing.JComponent.print(Unknown Source)
    at java.awt.GraphicsCallback$PrintCallback.run(Unknown Source)
    at sun.awt.SunGraphicsCallback.runOneComponent(Unknown Source)
    at sun.awt.SunGraphicsCallback.runComponents(Unknown Source)
    at java.awt.Container.print(Unknown Source)
    at sun.awt.windows.WComponentPeer.print(Unknown Source)
    at sun.awt.windows.WCanvasPeer.print(Unknown Source)
    at sun.awt.windows.WPanelPeer.print(Unknown Source)
    at java.awt.GraphicsCallback$PeerPrintCallback.run(Unknown Source)
    at sun.awt.SunGraphicsCallback.runOneComponent(Unknown Source)
    at java.awt.Component.printAll(Unknown Source)
    at dsi.emc.pac7000.ui.Pac7000UI$6.actionPerformed(Pac7000UI.java:1236)
    at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    at javax.swing.AbstractButton.doClick(Unknown Source)
    at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
    at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source)
    at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at javax.swing.JComponent.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)


    j'ai tout mis, ce n'était peut etre pas nécéssaire, mais ...
    voila donc je ne comprends pas... c'est peut etre en lien avec ma Frame, c'est la fenetre global de mon application, donc elle possede plein de chose, JMenu, JPanel, JTree... peut etre que cela ne lui plait pas ?
    Donc si vous avez une idée, je vous en remercie d'avance de me la faire partagé.

  2. #2
    Membre actif
    Profil pro
    Inscrit en
    Septembre 2005
    Messages
    504
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2005
    Messages : 504
    Points : 288
    Points
    288
    Par défaut
    oups je viens de me rendre compte que l'impression nécésite que la classe soit printable, la mienne ne l'était pas. cela vient peut etre de là...

  3. #3
    Membre actif Avatar de xxaragornxx
    Profil pro
    Inscrit en
    Mars 2003
    Messages
    241
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2003
    Messages : 241
    Points : 253
    Points
    253
    Par défaut
    Citation Envoyé par lilou77
    oups je viens de me rendre compte que l'impression nécésite que la classe soit printable, la mienne ne l'était pas. cela vient peut etre de là...
    Il y a des chances

  4. #4
    Membre actif
    Profil pro
    Inscrit en
    Septembre 2005
    Messages
    504
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2005
    Messages : 504
    Points : 288
    Points
    288
    Par défaut
    c'est bizarre dans les exemple que je vois, si le composant étend JFrame il ne lui rajoute pas l'interface Printable.
    moi mon composant étant JFrame, donc a priori il doit être imprimable non ? vu qu'il possede les méthode paint()...

  5. #5
    Membre régulier
    Profil pro
    Inscrit en
    Novembre 2005
    Messages
    94
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2005
    Messages : 94
    Points : 92
    Points
    92
    Par défaut
    C'est beau une exception quand même hein ? 8)
    je m'interroge sur MyFrame.this, c'est quoi, un document ?
    parceque sinon, c'est çà non ? à mons avis il suffit pas de Printable
    c'est comme l'habit qui fait pas le moine
    A+.

  6. #6
    Membre actif
    Profil pro
    Inscrit en
    Septembre 2005
    Messages
    504
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2005
    Messages : 504
    Points : 288
    Points
    288
    Par défaut
    MyFrame c'est une JFrame, c'est la fenetre principale de l'application, je demande de l'imprimer juste pour voir si ca marche... et apparement non.
    car je vais etre amené a imprimer des Jpanel, et comme je ne sais pas comment il faut faire, je voulais tester avec la JFrame principale.

  7. #7
    Membre régulier
    Profil pro
    Inscrit en
    Novembre 2005
    Messages
    94
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2005
    Messages : 94
    Points : 92
    Points
    92
    Par défaut
    alors là aucune idée, je pense qu'un composant n'est pas imprimable, faudrait une image du composant pour çà, perdu ...
    à la limite, this tout court, où MyFrame, mais MyFrame.this me laisse toujours perplexe... :

  8. #8
    Membre actif
    Profil pro
    Inscrit en
    Septembre 2005
    Messages
    504
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2005
    Messages : 504
    Points : 288
    Points
    288
    Par défaut
    en fait j'ai mis MYFrame.this, car si je met this et comme je suis dans l'interface new java.awt.event.ActionListener, le this est new ActionListener donc il ne le prend pas, je suis obligé de mettre MyFrame.this
    Sinon je vais essayé avec un autre exemple pour voir si cela imprime.

  9. #9
    Membre régulier
    Profil pro
    Inscrit en
    Novembre 2005
    Messages
    94
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2005
    Messages : 94
    Points : 92
    Points
    92
    Par défaut
    ah ok, mais je vois toujours pas la solutions...
    A+

Discussions similaires

  1. Réponses: 4
    Dernier message: 06/09/2005, 09h58
  2. Réponses: 9
    Dernier message: 31/05/2005, 10h05
  3. [Exception]Lors d'un validate sur un jframe
    Par cameleon2002 dans le forum Agents de placement/Fenêtres
    Réponses: 12
    Dernier message: 02/05/2005, 11h27
  4. Faire disparaître menu lors de l'impression
    Par jackrabbit dans le forum Balisage (X)HTML et validation W3C
    Réponses: 3
    Dernier message: 19/12/2004, 20h56
  5. [JDBC] SQL Exception lors d'une Query !
    Par Castagnems dans le forum JDBC
    Réponses: 5
    Dernier message: 30/04/2004, 12h00

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