JPaint resizing the canvas dynamically

Hi guys,
I am in the process of creating a program similar to MSPaint. The problem I am facing right now is how can I resize the image/canvas like in the MS Paint?? Do I need to have a multiple frame or a multiple panel inside?? Any suggestions??

If you open MS Paint you'll know what I mean, you can resize the canvas any time you want. This is what I did so far:
public class JPaintPanel extends JPanel implements JPaintView, ImageObserver{
     private     BufferedImage picture;
     private JPaintController control;
     public JPaintPanel(JPaintController jpc){
          picture = jpc.getImageCopy();
          control = jpc;
          UpdateListener ul = new UpdateListener();
          addMouseListener(ul);
          addMouseMotionListener(ul);
     public void paintComponent(Graphics g){
          super.paintComponent(g);
          Graphics2D g2 = (Graphics2D) g;
          g2.setColor(Color.BLACK);
          g2.drawImage(picture, null, 0, 0);
          control.drawToolActivity(g2);
     private void updateWindow(){
          super.repaint();
     }so I asked paintComponent to draw a blank image here (which is picture). However when I already draw that Image I can't resize it from the user....

Similar Messages

  • Is there a plug in to resize the canvas size in Illustrator CS6?  Not the artboard, the canvas size

    Is there a plug in to resize the canvas size in Illustrator CS6?  Not the artboard, the canvas size

    Reckon that’s what he must mean
    Are you sure, Steve?
    Kurt may agree.

  • Can you specify the background color when resizing the canvas?

    I haven't found this in the Scripting Reference.
    In the "Canvas Size…" dialog box you can specify the "Canvas Extension Color" to "Foreground", Background", "White", "Black", "Grey" or "Other…".
    Can this be scripted?
    I am writing an AppleScript to resize my canvas in order to add a slug to the bottom of the image. Currently my script stores the background color, so I can change it to White to accomplish my goal without discarding the background color (which gets restores at the end of the script). The problem is that if the user has a custom color (i.e. Pantone color) as the background color, the color does not get stored.

    See if this works for you… Just some very basic AppleScript with a call to 'do javascript' in this case the variable 'Solid_Fill' this is a cleaned up piece of scriptlistener output (done very nicely by X's tools you will see a post below to the latest release of this) The scriptlistener output has been turned into a function that javascript can call. Inside of the function call I have put a list arguments passed from AppleScript. So the values 0, 0, 0, 0 in the AppleScript list end up as arguments passed to the functions C, M, Y, K variables. AppleScript objects are 1 based Javascript are 0 based & values the same.
    set Solid_Fill to "function solidFillCMYK(C, M, Y, K) {
    function cTID(s) { return app.charIDToTypeID(s); };
    function sTID(s) { return app.stringIDToTypeID(s); };
    var desc8 = new ActionDescriptor();
    var ref4 = new ActionReference();
    ref4.putClass( sTID('contentLayer') );
    desc8.putReference( cTID('null'), ref4 );
    var desc9 = new ActionDescriptor();
    var desc10 = new ActionDescriptor();
    var desc11 = new ActionDescriptor();
    desc11.putDouble( cTID('Cyn '), C );
    desc11.putDouble( cTID('Mgnt'), M );
    desc11.putDouble( cTID('Ylw '), Y );
    desc11.putDouble( cTID('Blck'), K );
    desc10.putObject( cTID('Clr '), cTID('CMYC'), desc11 );
    desc9.putObject( cTID('Type'), sTID('solidColorLayer'), desc10 );
    desc8.putObject( cTID('Usng'), sTID('contentLayer'), desc9 );
    executeAction( cTID('Mk  '), desc8, DialogModes.NO );
    }; solidFillCMYK(arguments[0], arguments[1], arguments[2], arguments[3]);"
    tell application "Adobe Photoshop CS2"
    activate
    set User_Rulers to ruler units of settings
    set ruler units of settings to pixel units
    set Doc_Ref to the current document
    tell Doc_Ref
    set background layer of last layer to false
    do javascript Solid_Fill with arguments {0, 0, 0, 0} show debugger on runtime error
    move first layer to end
    set Doc_Height to height
    -- set Doc_Width to width did NOT need this
    resize canvas height Doc_Height + 200 anchor position top center
    flatten
    end tell
    set ruler units of settings to User_Rulers
    end tell

  • Hide the Canvas dynamically

    All,
    I am working in 11i instance, I have created a Custom Form using Template.fmb and my requirement is like this...
    we have multiple canvases in one window, dynamically we have to display and hide the canvases and I have used the below code in WHEN_NEW_FORM_INSTANCE trigger but it is not working....
    SHOW_VIEW('ID_CANVAS');
    HIDE_VIEW('ENCLO_CANVAS');
    Can someone help me....
    Thanks,

    One more thing, I have created custom Horizontal Toolbar canvas & Vertical Toolbar canvas and assigned to the window... at runtime toolbars are not visible....I haven't worked with Horizontal or Verticle toolbars very often, however, you have to make sure you change the following properties of your Window object:
    Horizontal Toolbar Canvas and Vertical Toolbar Canvas
    Make sure you set these properties to your toolbar canvases that you created.
    Craig...

  • Regarding resizing the JLabel dynamically

    hi all, again, some question in JLabel
    i have created an simple applet which have many JLabel on it, my question are:
    1. those JLabel just can't show on the applet, where i have set the location and the text on it, but still...can't
    2. how can i dynamically set the location where the JLabel should located at? i mean, the JLabel should follow exactly just in a straight row like below
    Jlabel1 - Jlabel2 - Jlabel3 -... JlabelN
    thank you for reply

    hi, i have done the creation of Jlabel and have the layout of NULL, because i have to fit the Jlabel into a larger panel in only 1 single row, no choice but have to use NULL. but the real problem is that the display of Jlabel just won't show, i have to manually set the length by using Jlabel.setSize(..., ...), why? isn't any other way to resize and make it fit the character in the Jlabel? how?

  • Need help with a basic script to resize image then resize the canvas

    I am new to photoshop scripting, and have come across a need to force an image to be 8"x10" at 300dpi (whether it is vertical or horizontal)
    I need to maintain the correct orientation in the file, so an Action will not work, I believe I have to implement a script to accomplish this.
    I have the below script so far, but I am not certain of how to input the variables / paramters
    doc = app.activeDocument;
    if (doc.height > doc.width) doc.resizeImage("2400 pixels","3600 pixels", "300", "BICUBIC");
    if (doc.height > doc.width) doc.resizeCanvas("2400 pixels","3000 pixels", "MIDDLECENTER");
    if (doc.height < doc.width) doc.resizeImage("3600 pixels","2400 pixels",300,"BICUBIC");
    if (doc.height < doc.width) doc.resizeCanvas(3000,2400,"MIDDLECENTER");
    When I run this script, I get the following error:
    Error 1245: Illegal argument - argument 4
    - Enumerated value expected
    Line: 5
    if (doc.height < doc.width) doc.resizeImage("3600 pixels","2400 pixels",300,"BICUBIC");
    The fact that its failing on lien 5 lets nme know that I have the "If" portions of my script correct, I just dont know how to accomplish the functions correctly.
    Any help would be appreciated!
    Thanks,
    Brian

    I know I'm late here but it seems to me your trying to automate a 8"x10 or 10"x8 300DPI  print.
    To do that you must first crop your image to a 4:5 aspect ratio to prevent distortion unless your shooting with a 4" by 5" camera.   I wrote a Plugin script a couple years ago that could help you do a centered crop.  You could do the whole process by recording a simple Photoshop action that uses two  Plugin Scripts only four steps would be needed.
    Step 1 Menu File>Automate>AspectRatioSelection  (My script based of Adobe Fit Image Plugin script) Set 4:5 Aspect ratio, center,  Rectangle, Replace, no feather. Llike Fit Image this script woks on both Landscape and Portrait images. The Selection will be correct for the images orientation.
    Step 2 Menu Image>Crop
    Step 3 Menu File>Automate>Fit Image set 3000 PX height and 3000 PX width the Image will be Resample so its longest side will be 3000 pixels.  Adobe Fit Image Plugin Script always uses BICUBIC resampling.  I have a modified version of Fit Image  that uses Bicubic Sharper whebndownsizing and BicubicSmoother when up sizing.
    Step 4 Menu Image>Size un check resample set resolution to 300 DPI.
    When you play the actions the Script Dialogs will not be displayed and the setting use when you recorded the action will ne used.
    The Plugin Script are included in my crafting actions package:
    http://www.mouseprints.net/old/dpr/JJMacksCraftingActions.zip
    Contains:
    Action Actions Palette Tips.txt
    Action Creation Guidelines.txt
    Action Dealing with Image Size.txt
    Action Enhanced via Scripted Photoshop Functions.txt
    CraftedActions.atn Sample Action set includes an example Watermarking action
    Sample Actions.txt Photoshop CraftedActions set saved as a text file. This file has some additional comments I inserted describing how the actions work.
    12 Scripts for actions
    My other free Photoshop downloads cam be found here: http://www.mouseprints.net/Photoshop.html

  • Is there a way I can resize a canvas AND the images?

    I have created several banners in adobe each with several images. The only problem is I have realised the canvas size is wrong (too big) is there a way that I can resize the canvas while resizing the images to fit at the same time? I don't want to have to start all my work from scratch all because I have to resize the canvas. Is there a way I won't have to?

    If the proportions are OK Image < Image Size might be an option.
    Have the images been placed as Smart Objects?

  • Problem with image resize after canvas resize in CS6

    In previous versions I have been able to resize the canvas and then resize the image.  For example resize the canvas to 250px x 250 px.  Then resize the image to the same.
    Here is the process I am using:
    Duplicate the layer and then hide it. 
    Resize the canvas (Image > Canvas Size) to 250px x 250 px. 
    Un-hide the layer and then resize the image (Image > Image Size).  When I go into Image>Image Size it says that the image is already 250px x 250px.  However if I try to transform the scale the image is the original size and not 250px x 250px
    The reason for needing this is I resize image size (in bulk) and the canvas size using the batch process (file>automate>batch) and actions.   I loaded the actions file I used in previous versions, but that did not work correctly.  I then went in to do this manually and got the same results.
    Any ideas??

    Please post the Action set *.atn file and name of the action in the set. 
    What you wrote seems like normal operation.
    Duplicate the layer and then hide it. 
    Resize the canvas (Image > Canvas Size) to 250px x 250 px. 
    Un-hide the layer and then resize the image (Image > Image Size).  When I go into Image>Image Size it says that the image is already 250px x 250px.  However if I try to transform the scale the image is the original size and not 250px x 250px
    There is no reason to hide and unhide the layer.
    When you change Canvas Size the only layer the may actually get changed is the "Background Layer" for the bankground layer does not suppoty tranparency so Pixels of some color will be added to the background layer if your increasing canvas size or Pixels will be cropped off the background layer if you decreasing canvas size.  Canvas Size = Document Size = Image size.  Canvas size change does not change the size of other layer.  Only their position over the canvas may change.  Layers other then the background layer can be any size. They can be the same size as the canvas size or they may be larger or smaler then the canvas size and they can have any aspect ratio and any shape.  As you saw when you ise free transform on your layer.

  • Why is the CANVAS so shy all of all sudden?

    Suddenly, when I want to slide the Canvas around to enlarge it full screen, it hides behind the Viewer or the Browser or the Timeline. Brand new phenomena. Any shortcuts for making the Canvas fullscreen and back? And why this new curtailment? - Thanks!
    G5   Mac OS X (10.4.5)   fcp 5.1.2

    The Viewer, Browser, Canvas and Timeline are all different windows that have their own visual hierarchy. If you resize the canvas and then select the viewer and they overlap, the viewer will cover the canvas. Quickest way to get back to your canvas if you lose it is using exposé.
    To preview your movie turn on Digital Cinema Display. Go to the toolbar ----> View ----> Video Playback ---> and Select Digital Cinema Display Playback.
    Now use command + F12 to toggle between cinema display and your standard editing view. If you're using a notebook you'll have to reclaim your F1-F12 keys in system preferences.
    Other hotkeys for navigating between your windows while editing:
    Command + 1 = Viewer
    Command + 2 = Canvas
    Command + 3 = Timeline
    Command + 4 = Browser
    Option + H will give you a list of all the hotkeys.
    Good luck.
    15" MBP, 2.16ghz Core 2 Duo, 2 GB ram   Mac OS X (10.4.10)  

  • How do I stop iPhone Safari from dynamically resizing the visual viewport?

    Sorry I post this here, but I couldn't access the developer forums (no error given, it just keeps returning me to this page https://developer.apple.com/devforums/) I'm not even sure wether that's been moved here and it's just the redirection non working.
    I need to Stop iPhone Safari from dynamically resizing the visual viewport, or in other words, to stop it from trying to "fit" the layout into the viewport.
    Why?
    Because any recalculation javascript does on absolutely positioned elements makes the whole site super IRRESPONSIVE.
    I don't know wether the issue is the element going out the already-set layout viewport (which triggers the page resizing to fit the visual viewport) or just the calculations being made constantly, but I can stop the calculations from happening when not "touching" the screen, but I need a way to stop the page resizing.
    I tried setting the viewport width to 1040px, as my layout width, and it fixed the header's width being narrower than the body (or shifted left?), but the whole page is still resized with every motion-frame (one every 3 seconds, due to overloading the redrawing engine)
    Is there a way to prevent that?

    No, that link doesn't solve it. It just says the same is found everywhere online.
    There's probably no way to do it, as per their way they "accidentally" omitted the oposite case: the page being wider than 980. They only mention what to do if the site is narrower. Something I learned is big companies (with reputation management) could let you run in circles for years no answer rather than telling you something is not possible.
    I'm the developer (can't access the dev forums, don't know why) and I DID setup the viewport, scale and other properties but none of them stopped from re-fitting the new re-sized layout in the viewport. They just ensure the "initial" view.
    I think the feature I'm looking for must be achieved with some JavaScript function targeting Safari-proprietary variable/property… if even possible.
    I just had to make things never reaching the edge until somebody contributes something useful

  • When dragging an image onto a fresh canvas, the resizing feature presnaps the image into the canvas size. I can confirm that this has not happened to me in previous projects. I've also tested this problem by making a new larger document size and dragging

    Contexts: I am very competent with GFX and have worked on many projects.
    When dragging an image onto a fresh canvas, the resizing feature presnaps the image into the canvas size. I can confirm that this has not happened to me in previous projects. I've also tested this problem by making a new larger document size and dragging in the same render. It snaps again. I don't want to re-size from the canvas dimensions, I want to resize from the render's original dimensions.

    Ap_Compsci_student_13 wrote:
    ok sorry but doesn't sscce say to post the whole code?the first S is Short, and yes, it needs to be all the code needed to illustrate the problem and let use reproduce it. If you were developing a new Web framework, your example might be short, but for a student game it's very long.

  • I need to resize my canvas after finishing my layers, how can I also enlarge the entire image?

    I spent many hours working on a project and failed to check canvas size before completing all of my layers. I need a bigger size canvas to print on regular 8.5x11 paper. After I change the canvas size, is there a way to enlarge all of my layers at once, without terribly screwing up the resolution? I'm not completely familiar with many of the available tools in CS6. Thank you:)

    So my guess since I can not see what you did, is instead of using the image>image size to resize the entire document, you added canvas leaving the layers at their original size.
    You can either select all the layers and group them or create a smart object. Then scale the group or object. How much you enlarge the layers will determine the quality change. The exception to that is any layers that are vector like paths and live type as they are resolution independant.

  • How and where do I resize footage? In the Canvas or Viewer

    I shot some footage and there needs to be some resizing...when and where do I do that ...am I looking to work in the canvass, and what makes the resize "permanent"
    Thanks
    Don

    Set the Canvas window to Image+Wireframe mode. Use the wireframe to scale the image any size you want.
    You also do the same thing by loading the clip into the Viewer window and using the Scale control.
    -DH

  • Resizing the flash application dynamically...

    Is it possible to change the size of the flash application so
    it takes up more or less space? Mainly in the realm of making it
    taller vs. shorter vertically, and thus the size of the webpage
    that holds that flash application will also change. Generally, the
    page that contains it will be of less size than the app itself and
    thus the size of the page will depend on the app. Can one resize an
    app and how so?

    My research on the web leads me to believe it's not possible
    to resize the flash application once it's loaded on the user's
    browser. I found one page with a cheat that requires a ton of code
    and counts as a kludge. There must be some other way though.

  • FW CS6 on Mac: how can I lock the docks with the canvas?

    I like the way all of my docs migrate from screen to screen all together when I use Dreamweaver and I seem to recall Fireworks CS5 on a PC behaved the same way. I use a MacBook Pro with an extra display at home and at work and would really like all of my panels, tool, and properties palettes to remain attached to the canvas—unless I undock a set of functions.
    Here's what I found in the Help section:
    Note: Dreamweaver does not support docking and undocking Document windows. Use the Document window’s Minimize button to create floating windows (Windows), or choose Window > Tile Vertically to create side-by-side Document windows. Search “Tile Vertically” in Dreamweaver Help for more information on this topic. The workflow is slightly different for Macintosh users.
    But... where IS that info for Macs?
    Anyone else have a workaround?
    Thanks!

    Yeah, I think part of what you're noticing is the difference in UI between Adobe applications on Mac versus Windows. Macs have traditionally had the floating window approach, which allows for visualization and interaction with elements beneath—like the Desktop or other applications—whereas Windows have a more integrated, full-screen UI. I haven't used a Windows OS in a while, but I remember how jarring it was having first learned Dreamweaver on Windows, and then using that same app on the Mac.
    I believe the Application Frame feature may have been developed to address that difference. Here's the excerpt from "Workspace basics" describing the feature:
    The Application frame groups all the workspace elements in a single, integrated window that lets you treat the application as a single unit. When you move or resize the Application frame or any of its elements, all the elements within it respond to each other so none overlap. Panels don’t disappear when you switch applications or when you accidentally click out of the application. If you work with two or more applications, you can position each application side by side on the screen or on multiple monitors.
    If you are using a Mac and prefer the traditional, free-form user interface, you can turn off the Application frame. In Adobe Illustrator®, for example, select Window > Application Frame to toggle it on or off. (In Flash, the Application frame is on permanently for Mac, and Dreamweaver for Mac does not use an Application frame.)
    So is this solution working for you? I cannot think of any other way to dock all the panels and windows as a single unit.

Maybe you are looking for