Really need help in printing JTextArea. Please help me
Hi,
i want to print the content of JTextarea which span more than 1 page.i have tried all suggestion in the forums but still have the same result.
it only print the first page.
Please help me.
attached is the code for printing:
public class PrintUtilities implements Printable {
private Component componentToBePrinted;
public static void printComponent(Component c) {
new PrintUtilities(c).print();
public PrintUtilities(Component componentToBePrinted) {
this.componentToBePrinted = componentToBePrinted;
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);
public int print(Graphics g, PageFormat pageFormat, int pageIndex) {
/* get component width and table height */
Dimension dimension = componentToBePrinted.getSize();
double compWidth = dimension.width;
double compHeight = dimension.height;
/* get page width and page height */
double pageWidth = pageFormat.getImageableWidth();
double pageHeight = pageFormat.getImageableHeight();
double scale = pageWidth / compWidth;
/* calculate the no. of pages to print */
final int totalNumPages= (int) Math.ceil( ( scale * compHeight ) / pageHeight );
if (pageIndex > totalNumPages) {
return(NO_SUCH_PAGE);
} else {
Graphics2D g2d = (Graphics2D)g;
g2d.translate(pageFormat.getImageableX(), pageFormat.getImageableY());
g2.translate( 0f, 0f );
g2.translate( 0f, -pageIndex * pageHeight );
g2.scale( scale, scale );
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
public static void disableDoubleBuffering(Component c) {
RepaintManager currentManager = RepaintManager.currentManager(c);
currentManager.setDoubleBufferingEnabled(false);
/** Re-enables double buffering globally. */
public static void enableDoubleBuffering(Component c) {
RepaintManager currentManager = RepaintManager.currentManager(c);
currentManager.setDoubleBufferingEnabled(true);
THANKS
Use freely downloadable smart jprint class AtDocumentPrinter from http://www.activetree.com. This package alos allows you to print contents of any kind of JTextComponent such as JTextField, JTextArea, JEditorPane, and JTextPane.
It breaks the text, images and forms into multiple pages by breaking horizontally and vertically. JTable printing is specially interesting.
Similar Messages
-
PLEASE HELP ME. Some important emails have gone to an archive mail box and i really need them. Can someone please help me with how to view the archive email box and the emails that are in there?
http://kb.mozillazine.org/Recovering_deleted_mail_accounts
-
I need help
Thanks for a reply
The cable that I'm using came with my 5th gen nano. The 6th gen Ipod shows that it's connected but the computer doesn't see it, so I don't think that it's the cable.
I did try this before when looking at the troubleshooting guide and nothing happens. It just resets and then the Ipod screen tells me that it's connected to the computer. It still is unseen by Itunes and no where to be found in my computer.
I don't have another computer to plug it into at the moment but I may be able to visit a friend that owns a decent PC in a few days. If that doesn't work out I will be getting a new lap top in a week and I'm hoping that it will work on that, but it won't be a Mac. So, let's say it works when I plug it into one of these computers, should I reset my Ipod from there or is there something else I should do? -
I wanted to start a Digital Printing business please help with Photoshop
Hi I wanted to start a digital printing business please help me with photoshop.
I've never used the program before and dont know how to design either. I got the trial edition of the photoshop extended and do I need to take some form of lessons or how do I start learning photo shop to do things like Banners, posters, signage, digital printing in other words...Before you invest any money in a startup business you MUST make sure you are able to compete with the competition. What you are saying is a bit like - I want to start a bakery but I cant cook and don't know how to use an oven - this might sound negative but try imagine the taste of the cakes....
If you really want to enter into the market your best bet would be to hire a designer/someone who knows about printing/profiling etc as printing can be complex, especially when you bump into technical problems.....You can always learn along side him/her. I don't want to put you off so GO FOR IT!!, but it is tough out there at the moment. -
Our iTunes will not open. It reads that we need the English version? Please help.
If I download a new iTunes will I lose everything we have?Same issue for me. Was running 10.5.3 due to the bug in 10.6 with Apple TV. Upgraded to 10.6.1 since it was supposed to solve the issues. ANd no I can;t open iTunes at all.
Annoyed that 10.6 was shipped with the bug with the Apple TV sortting of titles.
Really p*ssed off that 10.6.1 which was supposed to fix this has totally borken iTunes for me.
Time to try to revert to 10.5.3 again.
Apple, what's happened with Q/A.
(My setup - latest patched Lion, upgraded via Automatic update; so nothing out of the ordinary.) -
I know that how to convert any documents to pdf file, but don't know how to get barcode on it. I am using windows 8.1. and want to see barcode on my documents before the print. Please help.
Hi Frank ,
Please refer to the following link and see if this helps.
https://helpx.adobe.com/acrobat/kb/error-organizer-database-damaged-reset-1.html
Regards
Sukrit Dhingra -
I have some trouble with Safari!
Everytime i google something, I expect safari to open the link i click in the same window and same tab - as it did before - but now it always opens a new tab! I'm getting really tired of that! So please help me! I want safari to open the google search link in the same window and tab! How to fix that?
Please help me!!!
Thank you!From the Safari menu bar, select
Safari ▹ Preferences ▹ Extensions
Turn all extensions OFF and test. If the problem is resolved, turn extensions back ON and then disable them one or a few at a time until you find the culprit. -
Uloading ebook using iProducer rec'd error: ERROR ITMS-9000: "Unable to parse nav file: toc.ncx" at Book. I don't understand and need help fixing it. Please Help if you've the knowledge.
Many ThanksYep, i just did it again. The entire scroll-bar widget, complete with formatted text, graphics, etc., pasted itself nicely in another book. Two different files, the same widget.
I use the scroll-bar widgets for most of my texts. (I have audio buttons on the side, and the scripts are within the widget, to the side). My only text is within widgets, and text boxes, naturally.
I am following your recommendation: cleaning files, etc. I am remaking the book anew. I need to convince the EPUB bot or whatever that my file looks and works nicely on all my devices. You would expect an error message when previewing the book: 'Hey Amigo, your file is flawed, stop working on it, and get back to the drawing board." Should be able to try again next Monday. -
my iphone 4G buy from japan, i need to use in indonesian, please help me, i spent much money for this phone.....
froggy_vic wrote:
so even if your phone is unlocked you wouldn't be able to use it anywhere else.
Absolutely not true. There is no difference, spec wise, between the iPhone sold in Japan & the GSM iPhone sold everywhere else. iPhones in Japan use UMTS 2100. -
my i phone 4 cannot charge continously. it will charge then after few seconds its off then charge again. I cannot open it because it runs out of battery do i need a new battery?please help.
You could always check to make sure itunes is updated to 10.7 but im sure gdgmacdude is
right.
thanks
gdgmacdude
Hey dude
are there anymore hardware failure errors u know of
im kinda a novice apple man and could use all the help i can get
capp -
Hi, ı have a problem once I push the power button and it starts to opening but small symbol turning and turning, it really lasts so long. could you please help me? is it so slow to open a mac pro.
OS X Version Number?
Repair Disk
Steps 2 through 8
http://support.apple.com/kb/PH5836 -
I am having trouble installing a dell network laser printer so my mac will print. Please help
I am having trouble installing and printing my Dell laser 1700 network printer. I keep doing the install and it won't print. I previously had it installed but because I had to get a new router the IP address changed and i no longer can print with the old or load a new printer. Please help me.
CLICKY CLICK----> What to do when you can't print
-
Hi! I'm in the middle of updating the softwear and its not moved and it's been over half an hour. Will it load as I need it for work! Please help!
hold down the home/sleep button together until you see the apple logo and then releaswe.
-
hot to erase icloud accounts? i have free, but I need only one... please help.
all different... i want save just dis one [email protected]
-
HT201303 My ipad has been disabled. I need to enable it. Please help!
Hello, my ipad has been disabled for sometime and I need to enable it. Please Help!
FORCE IPAD INTO RECOVERY MODE
1. Turn off iPad
2. Turn on computer and launch iTunes (make sure you have the latest version of iTune)
3. Plug USB cable into computer's USB port
4. Hold Home button down and plug the other end of cable into docking port. Do not release button until you see picture of iTunes and plug (very important)
5. Release Home button.
ON COMPUTER
6. iTunes has detected iPad in recovery mode. You must restore this iPad before it can be used with iTunes.
7. Select "Restore iPad"...
Note: Data will be lost -
Dear Apple,please help me.the glitch and lags on games made me sad beause i am too love with my 4s. Why iOS 7 really made me sad...please help me.im beg for you.
www.apple.com/feedback/iphone.html
No one from Apple is listening on these forums.
Maybe you are looking for
-
Shared Calendar Invites Keep Repeating
Off the top, this is likely a rare situation, but with my setup, it happens often. We have three iCloud accounts that regularly invite each other to events through Calendar, however, these calendars are also shared (read-only) to each other. The sh
-
LDAP authentication not minding user set
I have a publishing rule for an internal website setup with LDAP authentication setup for two different domains, the domain the TMG 2010 is joined to (domain1) and another external domain (domain2). I want users from either domain to be able to auth
-
Hello all, I would like to know what kind of validation we should avoid in PI while designing on an Interface? Like if PI need information from SAP system (suppose target) , in that case where should be the validation included? or is it somehing can
-
Sudden change in network settings - can no longer access web sites
All of a sudden, I am no longer able to access any web sites on my Mac Mini. Everything was working fine and then yesterday I tried to get on-line to look something up and it didn't work. I restarted the computer, checked internet connectivity - whic
-
Superdrive malfunctions on G5, but works fine in new account
My Pioneer DVD-RW DVR-106D superdrive on my G5 2x2 is having problems reading data DVDs (takes a very long time to load data, sometimes doesn't work at all). Also, DVD burns do not work as well as in the past. I have found that if I create a new acco