Printing JTable after turning off double buffering causing repaint problems

I've followed all the instructions to speed up a print job in java by turning off double buffering temporarily by using the following call before calling paint() on the component...
RepaintManager.currentManager(printTable).setDoubleBufferingEnabled(false);
... and then turning it back on afterwards...
RepaintManager.currentManager(printTable).setDoubleBufferingEnabled(true);
but the problem is that if it is a long print job, then the rest of the application (including other JTables) isn't repainting properly at all. I have the printing going on in a separate thread since I don't think it's acceptable UI practices to force the user to wait until a print job finishes before they can proceed with using their application. I've tried controlling the double buffering at the JPanel level as well, but it always affects the entire application until the print spooling is complete.
Does anyone have any suggestions to solve this annoying SWING printing problem?
Thanks,
- Tony

When you post code, make sure and put it between code
tags, so it looks good:
public static void main(String[] args) {
System.out.println("Doesn't this look great?");
    public int print(Graphics g, PageFormat pf, int pageIndex) {
        System.out.println( "Calling print(g,pf,pageIndex) method" );
        int response = NO_SUCH_PAGE;
        Graphics2D g2 = (Graphics2D) g;
// for faster printing, turn off double buffering
        disableDoubleBuffering(componentToBePrinted);
        Dimension d = componentToBePrinted.getSize(); //get size of document
        double panelWidth = d.width; //width in pixels
        double panelHeight = d.height; //height in pixels
        double pageHeight = pf.getImageableHeight(); //height of printer page
        double pageWidth = pf.getImageableWidth(); //width of printer page
        double scale = pageWidth / panelWidth;
        int totalNumPages = (int) Math.ceil(scale * panelHeight / pageHeight);
// make sure not print empty pages
        if (pageIndex >= totalNumPages) {
            response = NO_SUCH_PAGE;
        } else {
// shift Graphic to line up with beginning of print-imageable region
            g2.translate(pf.getImageableX(), pf.getImageableY());
// shift Graphic to line up with beginning of next page to print
            g2.translate(0f, -pageIndex * pageHeight);
// scale the page so the width fits...
            g2.scale(scale, scale);
            componentToBePrinted.paint(g2); //repaint the page for printing
            enableDoubleBuffering(componentToBePrinted);
            response = Printable.PAGE_EXISTS;
        return response;
    }

Similar Messages

  • My bookmarks are lost after turning off the computer unexpectedly (power problem),how can it recovers?

    My bookmarks are lost after turning off the computer unexpectedly (power problem),how can it recovers? Thanks a lot !!!!
    我的书签在电脑突然被断电之后全部丢失了,我该怎么办呢??谢谢啦!!~~~~

    This can also be a problem with the file places.sqlite that stores the bookmarks and the history.
    * http://kb.mozillazine.org/Locked_or_damaged_places.sqlite
    * http://kb.mozillazine.org/Lost_bookmarks

  • Cannot turn off double sided printing on HP 8600 OSX v 10.8.4

    Hello! I cannot figure out how to turn off double sided printing. I do not see an option in the system print dialogue or on the printing settings itself. When I remove the double sided attachment from the back of the printer - it won't feed the paper properly. Help!

    Hi,
    Please follow the steps below in order to disable two-sided printing:
    On the File menu, select Print. The Print window appears.
    NOTE: The Print window might be minimized. Click the blue triangle next to the printer name to see all available settings.
    In the expanded Print window you will find next to Copies the checkbox for Two-Sided. Uncheck that box.
    NOTE: If the checkbox does not appear within the specific application print dialog, skip this step.
    Click the lowest selection box, listed as the name of the program (e.g. TextEdit)
    Will appear as Copies & Pages within Microsoft Office applications.
    Select Layout from the drop-down menu.
    Set the Two-Sided option as Off.
    You may save the settings for future use by clicking Presets > Save Current Settings as Preset... Any used preset will remain default till another preset will be used.
    Regards,
    Shlomi
    Say thanks by clicking the Kudos thumb up in the post.
    If my post resolve your problem please mark it as an Accepted Solution

  • The browser doesn't start after turning off and turning on the computer

    The browser doesn't start after turning off and turning on the computer. I tried to delete the program entirely (along with personal preferences), create a new account, install a different browser versions. All this did not help. (I have Windows 7.) Help, please! Every day I have to reinstall Firefox!

    Hello Nastena, try a clean re-install, certain Firefox problems can be solved by performing a ''Clean reinstall''. This means you '''remove Firefox program files''' and then reinstall Firefox. Please follow these steps:
    '''Note:''' You might want to print these steps or view them in another browser.
    #Download the latest Desktop version of Firefox from http://www.mozilla.org and save the setup file to your computer.
    #After the download finishes, close all Firefox windows (click Exit from the Firefox or File menu).
    #Delete the Firefox installation folder, which is located in one of these locations, by default:
    #*'''Windows:'''
    #**C:\Program Files\Mozilla Firefox
    #**C:\Program Files (x86)\Mozilla Firefox
    #*'''Mac:''' Delete Firefox from the Applications folder.
    #*'''Linux:''' If you installed Firefox with the distro-based package manager, you should use the same way to uninstall it - see [[Installing Firefox on Linux]]. If you downloaded and installed the binary package from the [http://www.mozilla.org/firefox#desktop Firefox download page], simply remove the folder ''firefox'' in your home directory.
    #Now, go ahead and reinstall Firefox:
    ##Double-click the downloaded installation file and go through the steps of the installation wizard.
    ##Once the wizard is finished, choose to directly open Firefox after clicking the Finish button.
    Please report back to see if this helped you!
    * check also if your antivirus or other security software(firewall, antispyware etc) blocks firefox access.
    thank you

  • Turning Off Double Sided Copies

    I need help turning off double sided copies (copy function not the printing function).  On the printer itself, I go into copy settings and find that "Two0Sided" copies is checked off.  I can't uncheck it to return it to single sided copies.  Help!

    There should be an arrow, to get more choices to show. Also the checkbox is just showing you the current selected, you change the setting by touch the big icon, not the checkbox. The touch panel is not a high resolution one, so try to touch the checkbox, result in the icon being selected, that's why the setting didn't change. Try find the 1:1 icon and touch that.
    ======================================================================================
    * I am an HP employee. *
    ** Make it easier for other people to find solutions, by marking my answer with "Accept as Solution" if it solves your issue. **
    ***Click on White “Kudos” STAR to say thanks!***

  • HP 2210xi all in one printer won't turn off so I can try resetting it.

    I have a error message: Remove and check cartridge. I have removed both cartridges, cleaned them and cleaned the points on the printer. I tried to turn the printer off so I can unplug the power cord and see if resetting will help. Pressing the on/off switch does not turn the printer off. I have not tried downloading firmware updates (something I've never done) and will try that if anyone thinks it will help. I've read that my next step would be to buy new cartridges, but since the printer won't turn off I'm concerned that I'll be stuck with $50 worth of ink and still need a new printer. Any help will be appreciated!!

    Hi @3Friends ,
    Welcome to the HP forums.
    I understand you are having a problem with the scan to email feature on your Photosmart 7520.
    I would like to help you.
    Try setting a manual DNS.
    Here is a link, to a post by happytohelp01, that has some nice screen shots and the steps.
    It is for a 7510, but the steps will be the same.
    Efax 7510 still won't work after turning off/on ePrint several times
    If that does not get the scan to email working, you may have to remove, then enable the web services.
    This will be kind of like an uninstall/reinstall, for the scan to email and ePrint features.
    If you have a custom ePrint address, it will be lost.
    Not lost for six months, or a year, but forever.
    Just touch the ePrint icon on the printer
    Go into the settings sub menu, then scroll down and chose remove web services.
    It will bring you back to the main screen, just touch the ePrint icon again, and enable the feature.
    After that go to scan to email and set it up again.
    Please let me know if I can be of further assistance.
    Aardvark1
    I work on behalf of HP
    Please click “Accept as Solution ” if you feel my post solved your issue, it will help others find the solution.
    Click the “Kudos Thumbs Up" on the right to say “Thanks” for helping!

  • Restarting music from last played after turn off!!

    Has anyone been able to figure out how to resume playback of shuffled music after turning off the ipod touch?? When U turn mine off or the battery runs out I have to start the shuffle from the beginning again. Really annoying isn't it?? Are there any fixes or solutions. Also I have downloaded 1.1.3 and it does the same thing.

    Hey sully404847,
    Are you turning the iPod off completely? http://docs.info.apple.com/article.html?artnum=305743
    Just put the iPod to sleep by tapping the sleep/wake button. Then you can wake it and continue playback. You can also double tap the home button to see iPod playback controls while the iPod is locked.
    This article will show you how-to get the most out of your iPods battery.
    http://www.apple.com/batteries/ipods.html
    Jason

  • Efax 7510 still won't work after turning off/on ePrint several times

    I'm trying to send an eFax over and over after turning off and on the ePrint button under the webservices menu but without any success. The message keeps stating that it's not connected to a network. I am 100% sure that it is connected to my wireless network because I check that out and print a copy of the page stating that this printer is connected.
    What could the problem be? Please help!

    Hi daisyforu,
    Welcome to the HP Support forums.  I understand that you are getting an error message about not being connected when you try to enable the web services for your Photosmart 7510.
    The error message you are receiving is indicating that the printer doesn't have an independent connection the internet.  Please set a static ip address and manual DNS servers by following the steps below.
    1)       Please enter the ip address of the printer into the address bar of your browser (Internet Explorer, Chrome, Firefox, or Safari, etc). My screen shots below are from Safari but the location of everything is the same regardless of the browser.  This will bring up the embedded web server of the printer.
    2)      Please click on the network tab.  You should see the Network Summary for your printer. Please click on 'Networking' on the left hand side menu.
    3)      Please click on 'Network Address (IP)' on the left hand side menu.
    4)      Please on the radial button beside "Manual IP" then click on "Suggest a Manual IP Address" button. The Manual IP address, Manual Subnet Mask and Manual Default Gateway should populate for you.  Please click on radial button beside "Manual DNS Server".  For the Manual Preferred DNS Server please enter 8.8.8.8 and for the Manual Alternate DNS Server please enter 8.8.4.4.
    5)      Please click on 'Apply'.  If you get a warning message about changing the ip address please click 'OK'.
    6)      Please turn the printer off by the printer's power button.  Please wait a minimum of 15 seconds and then turn the printer back on.
    7)      Please press the ePrint icon in the upper left hand corner of the printer's front panel. This should prompt you to accept the terms of service.  Please choose 'Accept'.
    8)      When prompted about the automatic updates please choose 'Yes'. The printer should now show the HP logo while the printer communicates with the HP servers. The Web Services information sheet should print with the claim code for your printer.
    Now that you have the ePrint feature is turned on before using the Fax feature I would recommend that you customize your ePrint email address.  I have included a document here on how to do that.
    You should now be able to get your eFax setup.  I have included a document for you on how to do this here.
    Regards,
    Happytohelp01
    Please click on the Thumbs Up on the right to say “Thanks” for helping!
    Please click “Accept as Solution ” on the post that solves your issue to help others find the solution.
    I work on behalf of HP

  • Lost some of contacts after turn off then turn on

    After turn off then turn it on . Some contacts r  gone ; only number r leftovers

    Hello,
    Is it really an iPhone 3G with iOS 5.1? I thought it was no longer supported.
    I had that occurred to me before but I restored it from an existing backup and the problem went away. If you could, you can try and upload your crash logs from ios 5+ and see what is causing the restart.
    If there is nothing to lose (e.g. Data), then you can see if a full restore (e.g. Set it to factor settings)  will help. Below is a link:
    http://support.apple.com/kb/HT1808
    I hope this helps but please feel free to wait for others to input.

  • After turning off private browsing Safari crashes immediately upon launch.

    After turning off private browsing Safari crashes immediately upon launch. I tried soft-resetting, and clearing my cookies and cache. I basically launches in private browsing mode and then immediately tries to switch to regular browsing. When the screen changes, it crashes to desktop.
    Any ideas, other than wiping my iPad?
    (I'm using iOS 5, of course, but it is not available under the Operating System dropdown in this forum)

    I'm seeing the same problem, and it was repeatable for me.  iPad (original 3G, 64GB), iOS 5.  (There are now a couple threads with this same problem.)
    Once the crashes start, it would continue to crash every time I tried to bring up Safari.  It crashes just as it finishes showing the tool bars, but before any content is displayed.
    Manually killing the app did not make the problem go away.
    One time, shutting down and restarting the iPad fixed it, but that solution did not work the next time I went in and out of Private browsing.  Also, once the crashing begins, going back into Private browsing did not stop the crashing.
    The last time it got into the crashing condition, I stopped the crashing by turning off the setting to display the Bookmark bar.  Strange!
    I have like 20 Safari crash logs that I hope will get auto-sent to Apple sometime today (I reenabled the send data to Apple option).

  • Notebook showing network activity after turned off

    Hi, after turn off my notebook HP Probook 4540s with connected ethernet cable and power source, the RJ-45 connector on my notebook still indicates(LED shines) like there is a network transmission in progress. If I disconnects ethernet cable, indication stops. When I reconnect it back, it starts indicating agian. I thought it was by bios settings something like boot on lan, but it doesn't seem so. Is it common for RJ-45 port to indicates even when is computer turned off? Also I have d-link router, maybe is it a d-link setting?
    How to disable network indication when is computer turned off?

    I am sorry, but to get your issue more exposure I would suggest posting it in the commercial forums since this is a commercial product. You can do this HERE.
    http://h30499.www3.hp.com/hpeb/
    HP ProBook 4540s Notebook PC Support
    TwoPointOh
    I work on behalf of HP
    Please click “Accept as Solution ” if you feel my post solved your issue, it will help others find the solution.
    Click the “Kudos, Thumbs Up" on the bottom to say “Thanks” for helping!

  • HT5642 After turning off the notification switches of some apps in notificaton center, there are still notifications. I'm confused. Why?

    After turning off the notification switches of some apps in notificaton center, there are still notifications. I'm confused. Why?

    Just guessing, but I would think, as I look at mine, that it might have to do with when the apps were added to the device. To be honest, identifying this as a bug might not be correct. You are the first person I have seen post something like this, so it must not bother others. You can leave feedback for Apple on the feedback page. Go to http://www.apple.com/feedback and then click on the appropriate link.

  • New iPad Air 2 with a persisting blank screen. Support site suggests a restore after turning off 'Find my iPhone' on the device. How can I do this with a blank screen?

    New iPad Air 2 (December 2014) with a persisting blank screen. Support site suggests a restore after turning off 'Find my iPhone' on the device. How can I do this with a blank screen?

    Thanks JimHdk,
    After a little more searching across various online resources I was able to cure it by holding down the home button and the on/off button for 10 seconds to restart it and it all came back with a clear screen.

  • Turn off double SMS notification on iphone 5

    how do you turn off double SMS notification on the iphone 5.  I've looked everywhere I would think probable and cannot find a way.  Thank you.

    Settings - notofications - messages - repeate alert - never

  • Office Assistant sending auto-reply even after Turning off

    hi
    I came across a strange issue wherein OoO messages are being fired from one particular mailbox even after turning off OoO Office Assistant , i checked there are no rules indeed. Please suggest.
    Aditya Mediratta

    Hi Amit,
    This got fixed by using MFCmapi and deleting out IPM.Note.Rules.OofTemplate.Microsoft .Thanks again for your time.
    Aditya Mediratta

Maybe you are looking for