Printing a JComponent, but it doesn't scale to fit the papers size

Hello all,
I derived a class "GraphPanel" from "JPanel" and did some simple graphics in the paint()-Method.
The paint-Method uses the getSize().width and height-properties so that the lines and images it draws always scale to the components size. This works fine.
The class GraphPanel also implements the Printable-Interface and I implemented the print-Method as follows:
    public int print(Graphics g, PageFormat pf, int page) throws PrinterException {
        if (page > 0) {
            return NO_SUCH_PAGE;
        Graphics2D g2d = (Graphics2D)g;
        g2d.translate(pf.getImageableX(), pf.getImageableY());
        AffineTransform at = new AffineTransform(pf.getMatrix());
        g2d.transform(at);
        this.print(g);
        return PAGE_EXISTS;      
    } // printI wanted the JPanel to be print out: scaled over all the papers' size (no matters if this means shrinking or blowing up the drawings).
The result wasn't what I expected: the size of the printing depends on the size of the JPanel at the screen :-(
Please can anybody give me a hint for doing this scaling?
Thanks a lot,
Thorsten

What if you add this line
g2d.scale( pf.getImageableWidth()/getWidth() , pf.getImageableHeight()/getHeight() );just before you print
this.print(g);

Similar Messages

  • Flash Catalyst CS5.5 Scale to fit the Browser size.

    Hello,
    I've create a website and when i preview on my browser ( 1280x664 website size) it look very good ,but when i try to see it from a different desktop will smaller or bigger size my website is croped ,some important functions are croped.
    I've been all the day looking in internet trying to fund a solution how to fix this but nothing.
    I saw an article that explaind how to fix that in flash catalyst cs5 and i tried to but didnt work
    so please help me to tell me how to make this work, i want just my website to get scaled
    ''to work in any monitor size''
    Thank you

    Could you add a link to your site here at all ? That would help with some workarounds maybe.
    I have noticed that many of the professional websites designed by web-agencies use a common design. They design the content to fit the majority of users who can view and do seem to view at around 800 x 450 - take a look at this as a good reference point.
    They then place the main content in a container - and centre it - so that it moves with fluidity - as the users resize the browser window, the content stays central on the page. Often a background image is used behind the main content - and the background image can be scaled to fit the window.
    There are some good examples like Carl Cox's Intec Label Website and some more at a great London Design Agency called bobbentleydesign.com
    You will note that many of these sites use the same method. Since such reputable designers use the same methods I would assume there's a damn good reason to do it that way, it must be the best way available . . . if there was a reliable way to scale everything then I would bet these pro's would be doing so - but they dont.
    Sorry I do not have the kind of solution that you are looking for. I am not a pro and very new to CS5 myself but I hope it may help you out. I think you are looking for something that can not be done effectively or consistently but I may be wrong. Perhaps someone knows but in the meantime . . . work around it.

  • TS1253 I have a printer epson TX210, but it doesn't work with my time-capsule. What need to do?

    I have a printer epson TX210, but it doesn't work with my time-capsule. What need to do?

    What have you tried?
    You are going to get nowhere quick with the 6.1 utility in Mountain Lion if this is the only OS you have available.
    Look up how to install 5.6 utility under ML. At least then you can see printers. That is assuming you are trying to use USB.
    Has this worked ever on Mountain Lion? Did you download the drivers for that printer for ML?
    Plug it into a computer directly.. does it work? If it doesn't work locally it sure will not work via the network.

  • I scanned an image and want to use the image trace tool, but it doesn't pick up all the lines.  Is there a way to darken the lines before using the image trace tool?

    I scanned an image and want to use the image trace tool, but it doesn't pick up all the lines.  Is there a way to darken the lines before using the image trace tool?  Help!

    If the scan is in B&W, then play with the Threshold setting here
    If it's in Color, then you will have to open the scan in a Raster editing software (like Photoshop) and play with the Brightness/Contrast settings to make the lines bolder.

  • I am trying to install Kodak printer ESP C310 but it says a firewall is blocking the installation. Can you help?

    I am trying to install Kodak printer ESP C310 but it says a firewall is blocking the installation. Can you help?I am using windows XP. I have searched port 5353 and this is enabling Bonjour.

    You could check this article, but it is about Firefox itself not having access.
    : http://kb.mozillazine.org/Firewalls
    Could you provide the exact wording and punctuation of the message, and try Googling that yourself -- when you google leave out unimportant words and punctuations, group words that are still together as in original message within quotes or with hyphens so that google will look for those words together in that order.

  • Trying to export video in mpeg 2 but compressor doesn't come up in the export drop down window. Any ideas?

    trying to export video in mpeg 2 but compressor doesn't come up in the export drop down window. Any ideas?

    Export the file using "Current Settings" and enable "self contained".
    Once the export is complete, open up Compressor, drop in your file, select the desired output settings and turn Compressor loose. If you have set up a Quick Cluster and have a multi core Mac, Compressor will use all available cores. It will be a faster process.
    x

  • Why can I not import the videos from my iPhone 4 onto my desktop (Windows Vista)? When I plug in it imports the photos without a problem but it doesn't seem to import the videos.

    Why can I not import the videos from my iPhone 4 onto my desktop (Windows Vista)? When I plug in it imports the photos without a problem but it doesn't seem to import the videos.

    1.Download the Flash setup file from here: <br />
    [http://fpdownload.adobe.com/get/flashplayer/current/install_flash_player.exe Adobe Flash - Plugin version]. <br />
    Save it to your Desktop.<br />
    2. Close Firefox using File > Exit <br />
    then check the Task Manager > Processes tab to make sure '''firefox.exe''' is closed, <br />
    {XP: Ctrl+Alt+Del, Vista: Shift+Ctrl+ESC = Processes tab}
    3. Then run the Flash setup file from your Desktop.
    * On Vista and Windows 7 you may need to run the plugin installer as Administrator by starting the installer via the right-click context menu if you do not get an UAC prompt to ask for permission to continue (i.e nothing seems to happen). <br />
    See this: <br />
    [http://vistasupport.mvps.org/run_as_administrator.htm]

  • HT1386 I installed Snow Leopard and have the latest version of iTunes. However, when I connect my iPhone, it charges and iPhoto opens, but iTunes doesn't seem to recognize the iPhone. It simply doesn't appear in the left column. What gives?

    I installed Snow Leopard and have the latest version of iTunes. However, when I connect my iPhone 4S, it charges and iPhoto opens, but iTunes doesn't seem to recognize the iPhone. It simply doesn't appear in the left column. What gives?

    http://support.apple.com/kb/TS1591

  • My iPod show that my battery is receiving energy and that it is "charging," but it doesn't actually charge. The battery never increases; it only decreases. Even when I have it physically plugged in and charging, it loses battery whenever I am using an APp

    My iPod shows that my battery is receiving energy and that it is "charging," but it doesn't actually charge. The battery never increases; it only decreases. Even when I have it physically plugged in and charging, it loses battery whenever I am using an APP or anything. I'm thinking that the chip that receives the energy is damaged or worn out. Is there anyway to fix it without going to the store? My USB chords is fine. It charges other iPods fine. Including a second generation iPod which means my 4th generation iPod should not have an physical battery problem. Any suggestions? Thank you so much!

    - See:      
    iPod touch: Hardware troubleshooting
    - Try another cable. Some 5G iPods were shipped with Lightning cable that were either initially defective or failed after short use.
    - Try another charging source
    - Inspect the dock connector on the iPod for bent or missing contacts, foreign material, corroded contacts, broken, missing or cracked plastic.
    - Make an appointment at the Genius Bar of an Apple store.
    Apple Retail Store - Genius Bar                          

  • I am running Windows XP, SP3. I have tried to run Firefox 4 several times but it doesn't work properly. The main page comes up showing the logo, below that is the search box, and below that is another box with nothing in it.

    I am running Windows XP, SP3. I have tried to run Firefox 4 several times but it doesn't work properly. The main page comes up showing the logo, below that is the search box, and below that is another box with nothing in it.

    The external DVD/CD Writer will Not appear on your desktop when you attach it to your iMac.  It will appear in "Finder", which is in your Dock.
    Hope this helps

  • TS1398 I can see the public network and it show the the conected bars at the top, but it doesn't prompt me to the main page to log in

    I can see the public network and it show the the conected bars at the top, but it doesn't prompt me to the main page to log in

    I tried that, I am staying at a hotel and it shows the network and it shows the conectivity bar at the top, generally it sends me to the main wifi page and asks me to type a password... but it doesn't even send me to that page at all, I did a network reset and still not working

  • HT2404 I'm trying to update apps and download new ones on mi ipad, but it doesn't work... the icons say "waiting" and nothing happens for days!

    I'm trying to update apps and download new ones on mi ipad, but it doesn't work... the icons say "waiting" and nothing happens for days!Help!

    Here are a bunch of things that you can try to get the downloads to resume.
    Reboot the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider - let go of the buttons.
    Make sure that you do not have a stalled download in iTunes - a song or podcast .... if you have a download in there that did not finish, complete that one first. Only one thing can download at a time on the iPad so that could be what is causing the problem.
    If that doesn't work - sign out of your account, restart the iPad and then sign in again.
    Settings>iTunes & App Store>Apple ID. Tap your ID and sign out. Restart the iPad by holding down on the sleep button until the red slider appears and then slide to shut off. To power up hold the sleep button until the Apple logo appears and let go of the button.
    Go back to Settings>iTunes & App Store>Sign in and then try to update again. Tap one waiting icon only if necessary to start the download stream.
    You can also try deleting the waiting icons - tap and hold down on an icon until it wiggles - the tap the X on the icon to delete it. Then try to download again.
    You can try resetting all settings. Settings>General>Reset>Reset All Settings. You will have to enter all of your app preferences and device settings again.
    If all else fails, download the updates or the apps in iTunes on your computer and then sync the content to your iPad.

  • Site automatically scale to fit the browser window

    hello all!
    i'm working on a site that i'd like to automatically scale to fit the browser window, without any scrolling and while preserving its aspect ratio.
    my client is very particular about the design & does not want the width & height of the images & text to change like they do in a responsive site- he just wants the site to scale to fit in a browser window. Yikes!!!
    could anyone give me a hand with this please?
    thanks so very much!
    -sharon

    Hi Andreas
    I'm really looking forward to hearing about your tests tonight. As I said to Elaine (above) I will be delighted if someone proves me wrong. I'm just looking for a solution.
    I've just had another quick go on Edge Animate to try out your suggestions:
    My findings are that it doesn't matter whether a graphic is wrapped in a div or not. If the graphic has L, T , W & H pixel values and the surrounding div group is set to L, T , W & H % values, the L & T will scale down but the W & H will not - the graphic will just stay the same size when the browser is shrunk. The only way to get the graphic to scale down is to change its L, T , W & H to % - but, as I've said it won't retain its aspect ratio.
    As soon as images are imported, the situation changes. The layout preset offers 4 more options including 'Scale background image'. And Background image settings now appear offering W 100%, H Auto by default. These both seem essential to achieving scale-to-fit. I've tried images with and without being wrapped in a div. Just as with graphics, I find that if I add the % to the div then the image doesn't scale. But if I add the % to the image it scales perfectly.
    As far as I can see the problem is that, with graphics, the link width and height feature doesn't seem to work properly. I would expect that if I create a graphic 100px square then change W & H to %, then both W & H would be the same %. But I get all sorts of results. It doesn't seem to make a difference if I fix the percentages so W & H are both 100%. Changing from Global to Applied doesn't seem to affect anything either. Surely if W & H are set to 100% (and linked) then a graphic should remain square regardless of browser size? I can't find any combination that will allow this. Is it just me? Am I doing something stupid?
    Good luck tonight.
    Cheers

  • In putting together a book I can move photos onto a page and enlarge the picture but is there a way to reduce the picture size? some cases I want a smaller picture and if I change the size of the picture box I only get a portion of the image. I wnt to red

    picture size...in putting together a book I can move photos onto a page and enlarge the picture but is there a way to reduce the picture size? some cases I want a smaller picture and if I change the size of the picture box I only get a portion of the image. I want to reduce the image to fit the size of the box.

    If you right click on the image on the page in the context menu select photo box alignment and then select one of scale to fit {centered, Left-aligned, Right-aligned}
    That should do what you are loking for.

  • I disconnected my printer from my iMac to move them and now I can't get the printer to work. I have restarted the computer but it doesn't seem to recognize the printer

    printer assistance

    Turn the printer off then back on. If that didn't help, open System Preferences > Print & Scan (or Print & Fax) for a prior Mac OS X then select the Print ab.
    If you see the printer on the left, select it then click -  (minus)
    Now click + to reset the printer.
    Might also help to clear the queue.
    Click:  Open Print Queue
    Delte any files in the list then click delete.

Maybe you are looking for