How to display graphics larger than canvas size?

How do I display graphics larger than canvas size in Java AWT?
I tried setting the canvas size() to a value larger than my monitor size, and then adding scroll bars to the canvas, but the scroll bars and the canvas won't go beyond the monitor size in pixels, which is only 800, so the large graphic I try to display gets cut off at the bottom.
How can I overcome this problem? Has anybody encounter a similar dilemma before?

import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
public class AWTSizing
    public static void main(String[] args)
        LargeCanvas canvas = new LargeCanvas();
        ScrollPane scrollPane = new ScrollPane();
        scrollPane.add(canvas);
        Frame f = new Frame();
        f.addWindowListener(new WindowAdapter()
            public void windowClosing(WindowEvent e)
                System.exit(0);
        f.add(scrollPane);
        f.setSize(400,400);
        f.setLocation(200,200);
        f.setVisible(true);
class LargeCanvas extends Canvas
    int w, h;
    final int PAD = 10;
    Rectangle r1, r2, r3;
    Rectangle[] rects;
    boolean firstTime;
    public LargeCanvas()
        w = 360;
        h = 360;
        firstTime = true;
    public void paint(Graphics g)
        super.paint(g);
        Graphics2D g2 = (Graphics2D)g;
        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                            RenderingHints.VALUE_ANTIALIAS_ON);
        if(firstTime)
            initShapes();
        g2.setPaint(Color.red);
        g2.draw(r1);
        g2.draw(r2);
        g2.draw(r3);
    private void initShapes()
        r1 = new Rectangle(w/4, h/4, w/2, h*3/4);
        r2 = new Rectangle(w/2, h/2, w/2, h/2);
        r3 = new Rectangle(w*5/8, h/6, w*3/5, h*2/3);
        rects = new Rectangle[] { r1, r2, r3 };
        firstTime = false;
        invalidate();
        getScrollPane().validate();
    private ScrollPane getScrollPane()
        ScrollPane scrollPane = null;
        Component c = this;
        while((c = c.getParent()) != null)
            if(c instanceof ScrollPane)
                scrollPane = (ScrollPane)c;
                break;
        return scrollPane;
    public Dimension getPreferredSize()
        Dimension d = new Dimension(w, h);
        if(rects == null)                   // before calling initShapes
            return d;
        Rectangle r;
        for(int j = 0; j < rects.length; j++)
            r = rects[j];
            if(r.x + r.width + PAD > w)
                d.width += r.x + r.width + PAD - w;
            if(r.y + r.height + PAD > h)
                d.height += r.y + r.height + PAD - h;
        return d;
}

Similar Messages

  • How to display a large file in JTextArea

    i am displaying a large file(a multi MB) in a JTextArea, it is showing java.lang.outofmemoryerror
    are there any solutions for this problem or is there any better way other than JTextArea ???

    thanks for replying but its all abt Tables
    i am new to java
    i asked how to display a large Text file in a JTextAreathanx
    --santosh                                                                                                                                                                                                                                                                                                   

  • My wrist is 225mm. Will I be able to find a watch band to fit my larger than average size?

    My wrist is 225mm. Will I be able to find a watch band to fit my larger than average size?

    There are more third party accessories available for iPhones than any other phone, best I can tell. It seems not unreasonable to expect that there will be a similar market for Apple Watch accessories.

  • How Do I Prep Larger Than 4K "Stills" for Final Cut Pro?

    Gentleman,
    Im having a problem exporting my sequence because there is a JPEG which has RGB Color Space that is larger than 4K and apparently Final Cut Pro only will export images that are 4K or Smaller. How do I reduce the size of this Images Color Space to be under 4K so I can Work with it in Final Cut Pro 7 ?

    You should be able to resize it in just about any photo/image editing software such as Photoshop, Preview, iPhoto and many others.
    -DH

  • How to display a page at 100% size?

    When I put the zoom at 100%, the page appears much smaller than real. My monitor is a 24" 1920x1200 pixels with 0.27 mm pixel size (that is 94 dpi)
    I suppose there has to be some way to tell illustrator my screen has 94 dpi for it to display pages at the correct size, but I can't locate it.
    In Adobe Photoshop this option is at Preferences/Units and Rulers but where is in Illustrator?

    When you set in Photoshop "preferences/Units and rulers/Screen resolution" (I'm translating from my spanish menus, so it can be slightly different in english), you are telling the program what is the size of the pixels in your screen. This is enough for the computer to know how to display an image at the real size. If you make a DIN A4 document at 300 dpi in Photoshop, and you have set the mentioned parameter correctly, when you choose "View/Print size", you obtain in your screen a view of the document at the size it is supposed to be printed (so the document will occupy in the screen exactly 29,7 x 21 cm). Note this is different from 100% view (or "Real Pixels"). The fact this parameter is under "Preset resolutions for new documents" is a bit confusing, but it affects how you see any document at Print size, not only the new documents and is totally different from "Print resolution" (but depends on it). You can change the print resolution of any old document at "Image/Image Size..." but you can't change "its" screen resolution because this is a parameter of your computer screen, not of your document.
    If you want to obtain the same effect in Microsoft Word, you have to go to "Control Panel/Screen/Configuration/Advanced Options/General/Dots per Inch Configuration" and this parameter will affect Microsoft Word. When you set the zoom lever at 100% in Word, again you will obtain  in your screen a view of the document at the size it is supposed to be printed.
    In Corel Draw, the corresponding parameter is at "Tools/Options/tool Box/Zoom Tool/Calibrate rulers...". There you can set the parameter numerically or you can use a set of on screen rulers to calibrate it. So when you set the zoom lever at 100%, again you will obtain in your screen a view of the document at the size it is supposed to be printed.
    Notice you're working with vectors in Corel DRaw and Word (well, vector pictograms of letters or as we all know them: fonts) but you are working with bitmaps in Photoshop. That's why the 100% zoom is different in Photoshop than in the other programs (including Illustrator).  and that's also why Photoshop has the Print size option. In the other programs, Print size and 100% would be the same but not in a bitmap program.
    If you take a look in your monitor user manual you most likely will find a page of specifications where it tells you the dot size. This parameter can vary in CRT monitors that raster the image on a phosphor screen but is fixed in LCD monitors that have a fixed led matrix. If you don't have the manual or have a CRT monitor you can calculate the parameter by measuring the display size horizontally  (from leftmost to rightmost displayed pixel) and dividing it by your screen resolution (the number of horizontal pixels).
    In my User manual it says the dot size is 0.27 mm, that means 94 dpi (25.4 mm in an inch divided by 0.27). Or, in case I would have lost the manual, I would just measured the scren width and obtained 518.5 mm that divided by 1920 pixels horizontal resolution gives a result of 0.27 mm per pixel.
    So, my question is ¿Is there some way of setting this parameter in Illustrator?

  • Why does my artwork print slightly larger than actual size? - MacOS 10.9.2

    I have an issue which I have no answer.  Every time I print an artwork for product mockup, say a 3x5 card, it prints slightly larger than a 3x5 card.  I have to manually scale my artwork down to 98.5 in the print dialog to get as close as possible to the actual size.  Its not related to a specific printer.  I have an HP printer and a Canon printer and the issue exists exactly the same between the two.  I'm running Illustrator 17.1 on an iMac running MacOS 10.9.2.  Can you please help make this easier for me?
    Wayne Carey
    Marketing Graphics Designer
    Strike King Lure Company

    Wayne,
    Are you using PostScript printer drivers (or at least PostScript emulation)? Non PostScript drivers may behave a bit like gremlins.
    What happens if you Save As or Print to PDF and then print from that using the actual size/no adaptation to paper size?

  • Why would the display be larger than the screen?

    My Mac has started opening with a screen that is larger than the display. (I may not have the terminology quite right)  Here's a non-techie description...if the phyical display is 1680x1050, Finder or Safari open up at, say, 1720x1200. If I want to have the toolbar visible at the top, I cannot see the dock at the bottom. If I want the Apple to be at the top left corner, I cannot see the time at the top right. In both cases it is one or the other. Restarting has no effect on this annoyance.

    Try holding down control and scrolling down (or up, it depends). That should zoom down to fit. I assume you've checked the preferences to see that you have the right size selected.

  • RoboHelp 8 HTML WebHelp How to display a larger image of a thumbnail by clicking on or rolling over the thumbnail?

    How would you display a larger image of a thumbnail by clicking or rolling over the thumbnail?

    Hi there
    For a mouseover you would have to add some custom developed JavaScript. You could probably find some pre-made on the web if you poked around.
    Generally speaking, any way you slice it you will be using two images. One for the thumbnail and one for the full sized image. You could employ the popup functionalty to pop up the larger image.
    I used to simply create DHTML drop-downs and insert the large images in the drop-down area.
    Cheers... Rick
    Helpful and Handy Links
    RoboHelp Wish Form/Bug Reporting Form
    Begin learning RoboHelp HTML 7 or 8 within the day - $24.95!
    Adobe Certified RoboHelp HTML Training
    SorcerStone Blog
    RoboHelp eBooks

  • My iPod display is larger than the screen, how do,I change it  back?

    I don't know how this happened.  It was fine then I pressed the home button to get out of an app and now the display is huge and it's hard to navigate around the screen.

    Never mind, we figured it out.  Needed to double tap with three fingers to zoom back out.

  • I turned on my iphone this am and the screen display is larger than the phone and I can't resize it. How can I make it smaller?

    The screen display on my iPhone won't resize. How can I make it smaller?

    You have Zoom on... double tap with three fingers to turn it off.   Go into Settings > General > Accessibility to disable it.
    See p. 243... http://manuals.info.apple.com/en_US/iPhone_iOS4_User_Guide.pdf

  • When I open Firefox, it expands to larger than screen-size and I can't use ANY features. How can I fix this?

    When I first open Firefox, it appears fine, then one second later it expands so that I cannot see any thing but the current message. The only way I seem to be able to even exit is to use the Windows Task Manager to kill the application. The other user on the same machine does not have this problem. We are both using Firefox version

    Which security software (firewall) do you have?
    Remove all rules for Firefox from the permissions list in the firewall and let your firewall ask again for permission to get full unrestricted access to internet for Firefox and the plugin-container process and the updater process.
    See:
    * https://support.mozilla.com/kb/Server+not+found
    * https://support.mozilla.com/kb/Firewalls

  • Are graphics larger than 300x300 possible in GarageBand enhanced podcasts?

    I would like to migrate away from Podcast Maker and start using GarageBand. However, as far as I can tell, GarageBand limits enhanced podcast graphics to 300x300 pixels. This is not even nice on modern iPods. Is there a hack to make larger graphics possible? I am looking for at least 640x480 which is possible with Podcast Maker. The button to not force graphics to 300x300 seems non-functional as graphics end up at this size regardless of the status of that check-box.
    Thank you,
    Roger

    I used to have the setting on my iPod set to have the backlit display on during our graphically enhanced podcast too. The only problem, and the reason I switched it back, was that it causes the battery to go down a lot faster. So that is something to consider too. But as far as I know, the user has to change that setting themselves.

  • How to display TEXT more than 500 char in a report as multiple lines.

    Hi Friends,
    i have a requirement like i should display Texts of length more than 500 Characters in a report( ALV LIST) as multiple lines
    I am fetching the data Using FM READ_TEXT
    the output im currently geeting with 150 Char in lenth as a single line
    How we can split the text into multiple lines in a report
    first i would like to know is it possible? if possible please give your valuable suggitions if not is there any alternative way to do this task.
    Thanks & regards
    kumar.

    Hi,
    This is possible but the Solution might not look Standard/Appropriate to you.
    In ALV, you can have Multiple Line Output...There is a Field in the Field Catalogue..called as Row_position...this is by default 0...which means Single row/Line ALV output....You can have this Value in the Range of 0 to 3.......A ALV field with row_position 1, will be displayed in the second line for every record...i.e. you will have multiple line for a single record of ALV.
    In your case......you can use this but you need to split your field in two fields.....but you may end up spliting a single word....but for that also you can design the logic of splitting the Fiel value at SPACE only......
    This may work.......and Sorry if not work......

  • Why are still images importing larger than their size?

    Per instructions in a thread I had here last week, I created all of my DVD still images at 720 x 534 pixels for Premiere Pro CS5.5. But when they are brought into a DVCPRO50 NTSC Standard sequence, they are being heavily clipped. The original in one example is this:
    But when that same images is brought into PP, it is sized up like this:
    It's still proportionally correct, but a lot of the top and bottom of the image are gone. The encoded MPEG-2 sequence and disk I've done as a test display just like that.
    Why is PP doing this, and how can I get it to use images built to the correct size to be used 1:1 in a sequence instead of being scaled to about 115% of size? Hate to compare this way, but this was never an issue with Final Cut Pro, which I'm switching from. Stills created to the size FCP needed of 720 x 540 displayed and finished exactly as they were made in Photoshop. The only image area lost was the normal bit of overscanning DVDs display at on your TV.

    I guess I don't understand.  This is an excerpt from the CS help.  This seems to be inconsistent with what the last two posts said.
    Composition settings presets for square-pixel equivalents of standard definition formats have changed as follows:
    format
    pixel dimensions in After Effects CS4 and later
    previous pixel dimensions
    NTSC D1 square-pixel equivalent
    720x534
    720x540
    NTSC D1 Widescreen square-pixel equivalent
    872x486
    864x486
    PAL D1/DV square-pixel equivalent
    788x576
    768x576
    PAL D1/DV Widescreen square-pixel equivalent
    1050x576
    1024x576

  • How to display graphic flush left in WebHelp

    In my WebHelp home page, I have a banner across the top which
    is a gif image. Ideally I'd like it to display across the full
    width of the page and flush to the left margin.
    I'm using the syntax <body TOPMARGIN=0 LEFTMARGIN=0
    MARGINHEIGHT=0 MARGINWIDTH=0>. This displays fine, ie. flush to
    the left, in the RoboHelp viewer (Ctrl+W) but when the project is
    generated, there is a gap to the left of the image when the page is
    viewed.
    Anyone know any workarounds? It's a cosmetic thing, but would
    be nice to resolve.

    Try this:
    REPORT z_ooalv_logo.
    ****DECLARATION FOR LOGO INSERT
    CONSTANTS: cntl_true TYPE i VALUE 1,
    cntl_false TYPE i VALUE 0.
    DATA:h_picture TYPE REF TO cl_gui_picture,
    h_pic_container TYPE REF TO cl_gui_custom_container.
    DATA: graphic_url(255),
    graphic_refresh(1),
    g_result LIKE cntl_true.
    DATA: BEGIN OF graphic_table OCCURS 0,
    line(255) TYPE x,
    END OF graphic_table.
    DATA: graphic_size TYPE i.
    CALL SCREEN 100.
    &amp;----
    *& Module PICTURE OUTPUT
    text
    MODULE picture OUTPUT.
    DATA: l_graphic_xstr TYPE xstring,
    l_graphic_conv TYPE i,
    l_graphic_offs TYPE i.
    CALL METHOD cl_ssf_xsf_utilities=>get_bds_graphic_as_bmp
    EXPORTING
    p_object = 'GRAPHICS'
    p_name = 'EDS'"IMAGE NAME - Image name from SE78
    p_id = 'BMAP'
    p_btype = 'BCOL'
    RECEIVING
    p_bmp = l_graphic_xstr
    EXCEPTIONS
    not_found = 1
    OTHERS = 2.
    graphic_size = XSTRLEN( l_graphic_xstr ).
    CHECK graphic_size > 0.
    l_graphic_conv = graphic_size.
    l_graphic_offs = 0.
    WHILE l_graphic_conv > 255.
    graphic_table-line = l_graphic_xstr+l_graphic_offs(255).
    APPEND graphic_table.
    l_graphic_offs = l_graphic_offs + 255.
    l_graphic_conv = l_graphic_conv - 255.
    ENDWHILE.
    graphic_table-line = l_graphic_xstr+l_graphic_offs(l_graphic_conv).
    APPEND graphic_table.
    CALL FUNCTION 'DP_CREATE_URL'
    EXPORTING
    type = 'image'
    subtype = cndp_sap_tab_unknown " 'X-UNKNOWN'
    size = graphic_size
    lifetime = cndp_lifetime_transaction "'T'
    TABLES
    data = graphic_table
    CHANGING
    url = graphic_url
    EXCEPTIONS
    dp_invalid_parameter = 1
    dp_error_put_table = 2
    dp_error_general = 3
    OTHERS = 4 .
    IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    EXIT.
    ENDIF.
    CREATE OBJECT h_pic_container
    EXPORTING container_name = 'LOGO'.
    CREATE OBJECT h_picture EXPORTING parent = h_pic_container.
    CALL METHOD h_picture->load_picture_from_url
    EXPORTING
    url = graphic_url
    IMPORTING
    RESULT = g_result.
    ENDMODULE. " PICTURE OUTPUT

Maybe you are looking for

  • URGENT!restrict user frm edit a field data (allow create) in apx applicatn

    hi, I have a table with 3 columns say col1 primary key col2 col3 i'm filling my col1 with a berfore insert trigger i have built an apex application with a report and form page on above table. my end user can create records through the application for

  • How to display a seperate right click menu for each item of a tree control?

    Hi I want to display a specific right click menu when a particular tree item is selected. I know how to create a menu and how to display it. I am using the function GetLabelFromIndex() to get the active tree item and then compare the label and based

  • GUI status in OOPS in ALV

    Hi Gurus,   Am developing the ALV report in OOPS. In that report am displaying 2 grids one after the other. My problem here is am getting the tool bar separately for the 2 grids. So i disabled the tool bar for two grids in layout. And i copied the st

  • Removing the "target server" from process chain jobs

    Dear SAP Community, Please note we are on BW version 3.5 We have a very large number of process chains that are used to load data in the production environment. Many of those process chains have a "target server" specified, so that the jobs will run

  • HT1491 how do i log on to itunes

    I am trying to  log on to itunes.  I  have an id and password but it has been a while.  I can not find where to log in.  I have spent about 1/2 hr.  Please help.  Thanks