Accueil > Forum > > > > Impresssion sous Java
Impresssion sous Java
jeudi 6 novembre 2003 à 09:40:58 |
Impresssion sous Java

kainblueriver
|
Voila je souhaiterais imprimer une interface graphique contenant plusieurs JPanel et le Pb est que je sais pas comment faire  . J'ai consulter deja plusieurs articles sur le sujet mais ils sont pas tres clairs, et quand je les tests ils m'impriment que les JPanel mais pas le texte qu'il y a dessus (ce qui est légèrement embetant). Si on pouvais me donner un coup de pouce ce serait sympa  kainblueriver
|
|
mercredi 12 novembre 2003 à 15:02:24 |
Re : Impresssion sous Java

tominfo
|
Créer une classe comme celle çi :
import java.awt.*; import javax.swing.*; import java.awt.print.*;
/** A simple utility class that lets you very simply print * an arbitrary component. Just pass the component to the * PrintUtilities.printComponent. The component you want to * print doesn't need a print method and doesn't have to * implement any interface or do anything special at all. * <P> * If you are going to be printing many times, it is marginally more * efficient to first do the following: * <PRE> * PrintUtilities printHelper = new PrintUtilities(theComponent); * </PRE> * then later do printHelper.print(). But this is a very tiny * difference, so in most cases just do the simpler * PrintUtilities.printComponent(componentToBePrinted). * * 7/99 Marty Hall, http://www.apl.jhu.edu/~hall/java/ * May be freely used or adapted. */
public class PrintUtilities implements Printable { /** le composant à imprimer */ private Component componentToBePrinted;
/** imprimer composant * @param c le composant */ public static void printComponent(Component c) { new PrintUtilities(c).print(); } /** constructeur * @param componentToBePrinted compsant à imprimer */ public PrintUtilities(Component componentToBePrinted) { this.componentToBePrinted = componentToBePrinted; } /** print method **/ public void print() { PrinterJob printJob = PrinterJob.getPrinterJob(); printJob.setPrintable(this); if (printJob.printDialog()) try { printJob.print(); } catch(PrinterException pe) { System.out.println("Error printing: " + pe); } } /** print method * @param g graphisme * @param pageFormat format * @param pageIndex index * @return valeur de retour de l'impression */
public int print(Graphics g, PageFormat pageFormat, int pageIndex) { if (pageIndex > 0) { return(NO_SUCH_PAGE); } else { Graphics2D g2d = (Graphics2D)g; g2d.translate(pageFormat.getImageableX(), pageFormat.getImageableY()); disableDoubleBuffering(componentToBePrinted); componentToBePrinted.paint(g2d); enableDoubleBuffering(componentToBePrinted); return(PAGE_EXISTS); } }
/** The speed and quality of printing suffers dramatically if * any of the containers have double buffering turned on. * So this turns if off globally. * @see enableDoubleBuffering * @param c composant */ public static void disableDoubleBuffering(Component c) { RepaintManager currentManager = RepaintManager.currentManager(c); currentManager.setDoubleBufferingEnabled(false); }
/** Re-enables double buffering globally. * @param c composant */ public static void enableDoubleBuffering(Component c) { RepaintManager currentManager = RepaintManager.currentManager(c); currentManager.setDoubleBufferingEnabled(true); } }
|
Ensuite tu n'as plus qu'à faire PrintUtilities pu = new PrintUtilities(); puis pu.print(MaFrame); (ou monPanel,...)
|
|
Cette discussion est classée dans : java, jpanel, impresssion
Répondre à ce message
Sujets en rapport avec ce message
Communication entre 2 classes pour une applet [ par Warwick ]
Bonjour, je débute le java, et j'ai quelques petits problèmes pour faire communiquer 2 classes entre elles et j'aurais besoin de votre aide...Mon appl
Quand est ce que Java Repaint ??? [ par Saris ]
Bonjour à tous, si quelqu'un peut m'aider svpVoici mon probleme : J'ai des image affichee sur un JPanel. Mon JPanel est mon interface graphique et dep
Java 3d et les JPanel [ par vincent_vz ]
Bonjour, j'ai a nouveau un probleme :-DDonc voila j'ai une application java normal jusque la... avec des JtabbedPane...chaque jtabbed pane contien un
java jdbc [ par paranouya ]
bonjours s'il vous plait je j'arrive pas à réussir pour mettre en forme une fenetre dans une aplication voici le code que j'ai établie import java.
java jdbc mysql [ par paranouya ]
bonjours;je suis entraine de la réalisation d'une application mais pour la classe de l'authentification j'ai réalisé le code suivant import java.awt.*
Swing java JFrame [ par rayhana1 ]
je suis une débutante en java. J'ai un problème dans la réalisation d'une interface graphique, voici le : premièrement j'ai créé un fenêtre simple (JF
interface graphique en java avec JCreator [ par meryazer ]
bonjour à tousvoila mon probleme:je desire faire une interface graphique en java, avec JCreator et codé à la main, mais le soucis c'est je ne sais pas
java applets graphics jpanel applet [ par forX ]
bonjour ,je suis débutant en java et je tente de faire quelque chose.j'ai un programme avec un jpanel et un autre avec un graphics (les 2 en applet
Java Desktop Application & JPanel [ par komus ]
Bonjour,Je vous expose mon problème. Je veux développer une classe qui hérite de JPanel pour ensuite l'utiliser pour les fenetre que je crée. Je trava
[JAVAMAIL] MessagingException Erreur [ par saturne2005 ]
Bonjour Je suis nouveau dans le domaine, j'ai fait un petit programme de réception de mail, ça fonctionne très bien avec les messageries internet com
Livres en rapport
|
Derniers Blogs
XNA IS DEAD!XNA IS DEAD! par richardc
Depuis la semaine dernière (et grâce aux TechDays 2012), je me penche activement sur la nouvelle version de Windows, aka Windows 8. Vous me direz, il était temps puisque la première preview date de Septembre dernier.
OK. Remarquez, on n'en est qu'aux...
Cliquez pour lire la suite de l'article par richardc TECHDAYS PARIS 2012 : WINDOWS SERVER "8" QUOI DE 9 !TECHDAYS PARIS 2012 : WINDOWS SERVER "8" QUOI DE 9 ! par ROMELARD Fabrice
Speakers: Fabrice Meillon et Stanislas Quastana Cette session est basée entièrement sur celle donnée lors de la BUILD cet hiver. Il n'y a pas d'ajout d'information en rapport avec cet évènement passé. Windows 8 Server sera intégralem...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice [HTML5] AUTOUR DU W3C : NOUVEAUX STANDARDS ET WEB MOBILE (LILLE)[HTML5] AUTOUR DU W3C : NOUVEAUX STANDARDS ET WEB MOBILE (LILLE) par Gio
Je m'y prends un peu tard je sais, mais bon je suis développeur web et donc hyper fainéant ! Toujours dans le cadre des technologies émergentes, ici HTML5, parce qu'on aime HTML5 chez Wyg , nous seront présent, le vieux ( Aurélien V.) et moi, pour pr...
Cliquez pour lire la suite de l'article par Gio [WP7] DYNAMICALLY CHANGE STARTUP PAGE[WP7] DYNAMICALLY CHANGE STARTUP PAGE par KooKiz
Let's say that you want to allow the user to customize the startup page of your application. You can easily change the startup page by editing the 'NavigationPage' attribute in the manifest file. But the manifest cannot be modified once the applicatio...
Cliquez pour lire la suite de l'article par KooKiz
Forum
RE : URL ET JAVARE : URL ET JAVA par Pylouq
Cliquez pour lire la suite par Pylouq
Logiciels
DocTranslate (V3.1.0.0)DOCTRANSLATE (V3.1.0.0)DocTranslate est un traducteur de document Microsoft Word, PowerPoint et Excel. Il permet d'autom... Cliquez pour télécharger DocTranslate Tribler (2012)TRIBLER (2012)Tribler est un client pair à pair (P2P/Peer-to-Peer) open source avec la capacité de regarder des... Cliquez pour télécharger Tribler OneSwarm (2012)ONESWARM (2012)Le peer-to-peer qui protège votre vie privée, c'est OneSwarm.
Ce logiciel de peer-to-peer crypté... Cliquez pour télécharger OneSwarm PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA TV DEVIENS HELLLOOO FLASH
LA TV SUR VOTRE ORDINATEUR.
Toute une plateforme Multi... Cliquez pour télécharger PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO Academy System (17.2.1.0)ACADEMY SYSTEM (17.2.1.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System
|