Date: Sun, 03 Sep 2006 20:31:36 -0400 From: Nicolas Blais <nb_root@videotron.ca> To: freebsd-java@freebsd.org Subject: Printing with java under FreeBSD Message-ID: <200609032031.42080.nb_root@videotron.ca>
next in thread | raw e-mail | index | archive | help
--nextPart6593792.PQd671nSxB Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi, I've been developing several applications in Java (diablo-jdk15) and am qui= te=20 satisfied with the result on FreeBSD and other OS.=20 My only complaint so far is that I haven't had any success printing with Ja= va.=20 I'm using CUPS-1.2.2.=20 Every little bits of code I find on the net do not work in FreeBSD. Is this= a=20 known issue? Any workaround? Here's one small bit of code I've tried to get to work, but throws an=20 exception: //START import java.awt.*; import java.awt.print.*; import java.awt.geom.*; class PrintObject implements Printable { public int print (Graphics g, PageFormat f, int pageIndex) { Graphics2D g2 =3D (Graphics2D) g; // Allow use of Java 2 graphics on // the print pages : Rectangle2D rect =3D new Rectangle2D.Double(f.getImageableX(), f.getImageableY(), f.getImageableWidth(), f.getImageableHeight()); Ellipse2D circle =3D new Ellipse2D.Double(100,100,100,100); switch (pageIndex) { case 0 : g2.setColor(Color.black); // Page 1 : print a rectangle g2.draw(rect); return PAGE_EXISTS; case 1 : g2.setColor(Color.red); // Page 2 : print a circle g2.draw(circle); return PAGE_EXISTS; default: return NO_SUCH_PAGE; // No other pages } } } public class Sample1 { public static void main (String[] args) { PrinterJob job =3D PrinterJob.getPrinterJob(); job.setPrintable(new PrintObject()); if (job.printDialog()) { try { job.print(); } catch (PrinterException e) { System.out.println(e); } } } } //END =2D-=20 =46reeBSD 7.0-CURRENT #18: Sat Sep 2 14:06:41 EDT 2006 =20 root@clk01a:/usr/obj/usr/src/sys/CLK01A=20 PGP? : http://www.clkroot.net/security/nb_root.asc --nextPart6593792.PQd671nSxB Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (FreeBSD) iD8DBQBE+3Pu4wTBlvcsbJURAu4eAJ9z2lBSdUt9VWME/eXePTznc7JwfQCghl1j 0BIUMh1yLLEELqKfmM9pfUk= =G2hO -----END PGP SIGNATURE----- --nextPart6593792.PQd671nSxB--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200609032031.42080.nb_root>