| | |
Printing in awt
![]() |
•
•
Join Date: Jun 2004
Posts: 609
Reputation:
Solved Threads: 7
Hi everyone,
I want to know how to print the contents of the text area including all its fonts to the printer. I have no idea how to implement this in awt. Could someone show me or e-mail me any sample codings on how the print functionality
can be implemented in awt and tell me what is the name of the api that i should be looking at.
My e-mail is freesoft_2000@yahoo.com
I really hope someone can help me
Yours Sincerely
Richard West
I want to know how to print the contents of the text area including all its fonts to the printer. I have no idea how to implement this in awt. Could someone show me or e-mail me any sample codings on how the print functionality
can be implemented in awt and tell me what is the name of the api that i should be looking at.
My e-mail is freesoft_2000@yahoo.com
I really hope someone can help me
Yours Sincerely
Richard West
•
•
Join Date: Mar 2004
Posts: 18
Reputation:
Solved Threads: 0
Here is a very basic example of how to print out a line of text in Java
Java Syntax (Toggle Plain Text)
import java.awt.*; import java.awt.geom.*; import java.awt.print.*; /** Simple printing application that will demonstrate how to print out simple text */ class MyPage implements Printable { public void paint (Graphics g) // This method will define what will { // be printed on paper Graphics2D g2d = (Graphics2D) g; g2d.setFont(new Font("Arial", Font.BOLD, 30)); g2d.drawString ("Hello World of Paper!", 200, 150); } public int print (Graphics g, PageFormat f, int i) { if (i != 0) // To prevent overflow. i indicates number of pages to print return NO_SUCH_PAGE; paint (g); // Call paint method return PAGE_EXISTS; } } class MyPrinter { public static void main (String[] args) { PrinterJob job = PrinterJob.getPrinterJob(); System.out.println ("Staring printer..."); job.setPrintable(new MyPage()); if (job.printDialog()) // Show the printing dialog { try { job.print(); // Attempt printing } catch (PrinterException e) { e.printStackTrace(); } } } }
![]() |
Similar Threads
- Printing problem (Java)
- Printing JTable Content with Grid (Java)
- Printing JPanel containing JLable, JTable, JButton, JTextPane, JTextArea (Java)
- Windows 2000 Adv Server and "Printing Subsystem" (Windows NT / 2000 / XP)
- Printing Embedded JComponents (Java)
- Printing from java (Java)
- Linux printing questions (*nix Hardware Configuration)
Other Threads in the Java Forum
- Previous Thread: Always on top Frame
- Next Thread: problem with lengthy query
| Thread Tools | Search this Thread |
911 addball addressbook android api append applet application apps array arrays automation binary bluetooth businessintelligence button card character class client code collision component crashcourse css csv database eclipse ee error fractal free game gis givemetehcodez graphics gui html ide image integer integration j2me japplet java javaarraylist javadoc javafx javaprojects jni jpanel julia jvm linux list loan machine map method methods migrate mobile netbeans newbie objects oriented output panel phone physics problem program programming project projects radio recursion replaydirector reporting researchinmotion scanner se server service set sms software sort sql string swing test textfield threads transfer tree trolltech ubuntu utility windows





