Canvas.getHeight() and getWidth()

Hi all,
I'm completely stuck. I don't know what to do. I developed a complete MIDlet and now I'm running it to remove any kinks I put in while developing. And one kink I can not get out of my system. I'm running the code in the WIreless Toolkit from Sun (version 2.5).
I made (I think) a simple game, just to learn working with Bluetooth and Midp. My game isbased on the venerable Pong, which should be played between two mobiles. One of the mobiles will act as server, the other one as client. The server starts with waiting for a connection, the client starts with connecting to the server. Both server and client use the same code.
After connecting the Client starts with sending its width and height to the server, who will decide on the dimensions of the playing field. In theory a good approach, but what gets send over is nothing more that zero dimensions. I have been looking at this problem for the good part of a week, created several posts to the forums, and I still have no sollution for this problem. Who can help me finding the non-zero dimensions of the playing field.
Some code so you know what I'm doing:
First the MIDlet constructor:
    public MyMIDlet() {       
        // Retrieve the display for this MIDlet
        theDisplay = Display.getDisplay(this);
        // Set up the initial screen for the MIDlet
        createStartScreen(null);
        // Create the game object
        myGame = new MyGame (this);
    public void commandAction(Command command, Displayable displayable) {
         // Some code omitted
         else if (command == OKCOMMAND){
            // Start the game
            myGame.setSelection (gameType.isSelected(0));
            new Thread(myGame).start();
         else { /* do nothing, one of the other keys was pressed */ }
    }Next the MyGame object:
     public MyGame (MyMIDlet theParent) {     
          myMIDlet = theParent;
          myData   = new MyData ();
     public void run() {
          // Some code omitted
          if (!isGameStarted) {
               // Determine if this game should start as a server or
               // a client
               if (isServer) {
                    // Wait for other MyMIDlet to connect
                    connection = waitForConnection();
               else {
                    // Establish a connection to a MyMIDlet
                    connection = connectToServer();
                    if (connection == null) {
                         return;
               try {
                    ins  = connection.openInputStream();
                    dins  = new DataInputStream (ins);
                    outs  = connection.openOutputStream();
                    douts = new DataOutputStream (outs);
               catch (IOException ioException) {
                    displayMessage("IO Error",
                              "An error occurred while opening " +
                              "the input and output streams (IOException: " +
                              ioException.getMessage() + ")");
                    try {
                         connection.close();
                    catch (Exception exception) {
                         displayMessage("Exception",
                                   "An error occurred while closing the connection " +
                                   "(Exception: " + exception.getMessage() + ")" );
               // Create game canvas
               myCanvas = new MyCanvas(this, myData, FONT);
               myMIDlet.setCanvas(myCanvas);
               myCanvas.addCommand(LEFTCOMMAND);
               myCanvas.addCommand(RIGHTCOMMAND);
               myCanvas.setCommandListener(myMIDlet.getCommandListener() );
               // Negotiate game screen size
               myData = negotiateScreenSize(isServer);
                        // Rest code omitted
     private MyData negotiateScreenSize(boolean isServer){
          if (isServer) {
               try {
                    // Code to de-serialize data containing among others the dimensions
                                myData.resurrect(dins);
                    // Set field dimensions to smallest screen
                    setFieldDimension(myData);       
               catch (IOException ioException) {
                    displayMessage("IO Error",
                              "An error occurred while reading " +
                              "screen dimensions, (IOException: " +
                              ioException.getMessage() + ")");
          else {
               try {
                    myData.setFieldDimension(myCanvas.getWidth(), myCanvas.getHeight());
                                // Code to serialize data containing among others the dimensions
                    myData.transfer(douts);
               catch (IOException ioException) {
                    displayMessage("IO Error",
                              "An error occurred while writing " +
                              "screen dimensions, (IOException: " +
                              ioException.getMessage() + ")");
          return myData;
     }For good measures, I add code from the MyCanvas constructor. The first place you can ask the dimensions of the screen:
    public MyCanvas(MyGame theGame, MyData theData, Font theFont) {
         myGame = theGame;
        myData = theData;
        font   = theFont;
        // Let Server start the match
        isServerGame = true;
        // Get dimensions of the screen
        height = getHeight();      
        width  = getWidth();
        myData.setFieldDimension(width, height);
System.out.println ("myCanvas.constructor, set height=" + height + " and width = " + width + "."); 
}      The last line prints out the following information:
myCanvas.constructor, set height=0 and width=0.I have added more of these lines in my code to give me the values of the screen dimensions. I always get zero values.
Who knows what I need do to get the correct values?
Maik

can u please show the code of mycanvas classI found the problem. Its in the code you are asking for. To get access to the height and width from outside the MyCanvas object I added the following code:
    public int getHeight (){
         return height;
    public int getWidth() {
         return width;
    }And ofcourse this was bugging my code. So I changed the constructor of myCanvas to:
        myGame = theGame;
        myData = theData;
        font   = theFont;
        // Let Server start the match
        isServerGame = true;
        // Get dimensions of the screen
        height = super.getHeight();
        width  = super.getWidth();
        bpData.setFieldDimension(width, height);And the problem was solved. Thanks for pointing me to the code with the build in bug.
Regards,
Maik

Similar Messages

  • GetCaretPosition and getWidth for ParmInputField

    Am I crazy?
    Or does getCaretPosition and getWidth for "ParmInputField" show "true length - 1" with the Sun's JVM (true to their other length functions) and "true length" in the Microsoft JVM.
    For example: The word "BIRD" returns a 3 from sun and a 4 from Microsoft's VM.
    At the moment, I see no choice but to use code this routine twice... once for Sun and once for Microsoft. The program will have to decide which block of code to call based on JVM being used. Yuck.

    can u please show the code of mycanvas classI found the problem. Its in the code you are asking for. To get access to the height and width from outside the MyCanvas object I added the following code:
        public int getHeight (){
             return height;
        public int getWidth() {
             return width;
        }And ofcourse this was bugging my code. So I changed the constructor of myCanvas to:
            myGame = theGame;
            myData = theData;
            font   = theFont;
            // Let Server start the match
            isServerGame = true;
            // Get dimensions of the screen
            height = super.getHeight();
            width  = super.getWidth();
            bpData.setFieldDimension(width, height);And the problem was solved. Thanks for pointing me to the code with the build in bug.
    Regards,
    Maik

  • How can I export an image from Illustrator same canvas size and custom resolution?

    Hey all.  i am using Adobe Illustrator CS5 for creating images for iPhone app icons the size of image 374 px 374 px and 264 ppi. i created an image same size and ppi .the problem after export the image file size changing to  1371px x 1371px and 264 ppi pixel dimension.How can I export same canvas size and same resolution file from illustrator

    10111980,
    If you just forget about PPI and use Save for Web, you will get the 374 x 374 pixel size.
    The 1371 x 1371 pixels is because you somehow increase the resolution by 264/72.
    You should never mix pixel by pixel sizes and PPI.
    The 374 x 374 pixels is the actual image size. At 264 PPI that will be about 1.417 inches. At 72 PPI that will be about 5.194 inches.

  • Increasing canvas size and re-clipping (intentionally)

    Hi,
    So I bolluxed up a little bit while creating my first full-bleed print piece. I used Ps to edit the image, Ai to add some stuff, and ignored Id completely for the printer. Now I have a perfect 8.5 x 11 image that I want to print all the way to the edges without scaling; I left white bleeds 1.8" but apparently that won't suffice.
    I'm trying to go back into photoshop and increase the canvas size (8.75 x 11.25 to include bleeds), and with it, extend the image that was originally clipped when I trimmed the document from a vertical picture (12 x 16 or whatever) to fit the standard letter paper size. When I do that, I get only white areas around the canvas.
    Can anyone provide a solution to create full-color bleeds the way they should have been done originally? I have tried changing the canvas size and re-placing another layer of the image behind the existing one (with the hopes that it would clip automatically), but it didn't work. At this point, should I worry about bringing anything into InDesign?
    Thanks,
    - boda

    The Nish Adeel,
    > i wants to increase my fla canvas size from all sides...
    when we
    > increase the size of a file it increases from right and
    bottom , i
    > want to make it from all four sides like photoshop ...
    is there any
    > way to do this.
    There is a way to do this; unfortunately, it's not an
    automatic feature
    like in Photoshop. The approach you'll need to take is to
    update the
    document dimensions (basically, the canvas size) as desired,
    then use the
    Edit Multiple Frames button on the lower left of the Timeline
    panel to
    manually move all assets on the main timeline. To do this,
    you'll have to
    make sure all layers are unlocked. To do this quickly, click
    the
    Lock/Unlock All Layers button at the top, between the eye and
    the square
    buttons, until you see that all locks have been removed (one
    or two clicks
    will do it). In the Modify Onion Markers button next to the
    Edit Multiple
    Frames button, choose Onion All. Select Edit > Select All,
    then use the
    arrow buttons to move your assets.
    David Stiller
    Co-author, Foundation Flash CS3 for Designers
    http://tinyurl.com/2k29mj
    "Luck is the residue of good design."

  • Canvas children and mouseOver

    Simply put, I have a repeating canvas that contains buttons,
    an image, and a text field. When the user rolls their mouseOver the
    canvas, a child canvas becomes visible with buttons inside of it.
    Works great when you make sure that the mouse stays only over true
    canvas area and not over a child inside of the canvas. If it falls
    over a child, it fires the mouseOut and the buttons become
    invisible. Essentially, you can't click on the buttons because they
    are a child and the mouseOut goes off, making them invisible! How
    can I keep the mouseOver alive, even over a child?
    Thanks!

    check the parent of the event "target", not the parent of the
    event.
    In Flex, events can possibly participate in three phases:
    1) cascading phase as the event goes from the top of the
    display list through all parents of the control that dispatched the
    event.
    2) targeting phase, as the event goes through the target, the
    control that dispatched the event.
    3) bubbling phase as the event goes back up the display list
    through parents of the control that dispatched the event.
    - not all events bubble
    - you may need to add an event listener twice, and have the
    arg to addEventListener for bubbling to true and then false if you
    want to listen during cascading and bubbling phases.
    Now you are probably confused, so ignore some of what I said,
    and concentrate on listening to mouseOver events in the Cnavas, and
    then when the event handler is called, examine the target and
    possibly currentTarget properties of the event object to see if it
    is the child of the Canvas, and then act as appropriate.

  • Canvas, Timeline and Browser missing.

    Hey,
    My canvas timeline and browser are all missing.
    In window their greyed out too.
    I cant even import any files?..
    What do i need to do?.
    Thanks.
    the only windows i have is the Viewer: Slug and Tool Palette

    Sorry! I have just noticed you have cured it!
    Ian.

  • How to batch or individual import Canvas .CVX and .CNV files into AI CS6(mac)?

    Is anyone aware how to batch or individually import Canvas .CVX and .CNV files into AI CS6(mac)? I have a large old graphics library representing 10 years of work which would be very nice to convert into Illustrator CS6...
    Thanks a lot for any hint -
    stefan

    JETalmage wrote:
    ...export them as an EPS or another file type that windows will recognize...
    It's not a matter of exporting a file that Windows will recognize; it's a matter of exporting a file format that Illustrator can import or open.
    A Mac OS version of Canvas is under development, by the way.
    JET
    My bad. Typo on my part. I meant one that Adobe will recognize.
    Too early yet. I shouldn't try to type before I get my first morning tea.
    --OB.

  • Jpanel.getHeight() or getWidth returning 0?

    I am not sure why they are doing that. I initially set the size of the panel to a specific height and width, wouldn't get height and get width return that height or width? My code is below...
    gameWindow()
              super();
              JButton button = new JButton("start");
            JFrame f = new JFrame("Missle Command, Part Duex!");
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);       
            f.getContentPane().add(getUIPanel(), "Last");
              f.addMouseListener(new pointsListener());
            f.setSize(500,800);
            f.setLocation(200,200);
            f.setVisible(true);
              f.add(this);
    }This code returns 0...
    public city(JPanel thePanel, int pos, int pos2)
              //constructor
              double gameXX = thePanel.getWidth();
              double gameXY = thePanel.getHeight();
              System.out.println("The height and x Position of the Variables "+gameXX+" " +gameXY);//<-I get zero when I print this.  Strange!
    }

    Two possible causes:
    1) You're adding the panel after the frame has already been made visible.
    f.setVisible(true);
    f.add(this);If that's what 'this" refers to. If not, the code is still wrong regardless. During GUI construction you shouldn't be adding stuff after making the frame displayable. And you also shouldn't add more then one component to BorderLayout.CENTER.
    2) Upon making the frame visible, the installed LayoutManagers size up everything and decide to make your panel 0x0. Why would they do this? Because it's a custom panel and you never set the preferred size.

  • Opening the Canvas window and the Timeline from the browser

    I am on an Intel 2x2.66 Dual Core using OS 10.4.11 and working in FCP 6.04.
    I know this is a stupid question but having been a composer all my life, I am not up to speed on FCP and I seem to be unable to find the answer in my manual.
    I dragged a QuickTime movie to the browser window. It is 500x375 in dimension and uses a H.264, AAC codecs. (info I got from the Get Info window).
    The video shows up and plays in the Viewer window but I cannot get the Canvas window nor the Timeline to open.
    I have tried selecting the sequence from the list in the browser and then control clicking it and looking at the shortcut menu there. The manual says I should choose Open Timeline from this shortcut menu but that is not even a choice I have. I don't mean it is grayed out, I mean there is no Open Timeline choice on the menu.
    As an alternate, the manual suggests selecting the sequence and then choosing View > Sequence in Editor. I tried this also. There is no Sequence in Editor choice under the View menu. There is a Clip in Editor choice but when I select that it simply opens the movie in Quicktime.
    I am aware that I am probably forgetting something simple or doing something stupid but I cannot figure it out. Help would be much appreciated.
    Thomas

    the simple fact that is being eluded to here is that without an active sequence in the project (shown in the browser) there is no canvas or timeline. If you delete your sequence from the browser, the timeline and canvas will disappear, and you will have to create a new sequence, then open that sequence by double clicking it, to get those windows back. Canvas and Timeline display sequence content. No sequence, no c/t.

  • Depth, 3D, canvas restriction and masks -in Motion 4.

    Hello.
    I'm a digital artist, and work with Maya in combination with Motion 3.
    Is there an improvement in the "compound blur" filter. Does Motion 4 support depth in the image based on grayscale images, rendered out of 3D packages?
    The "compound blur" found in Motion 3 is quite buggy, and I've been forced to find several work arounds in order to use it.
    I saw in another post, that Motion and Cinema 4D, can work together. Does Motion support 3D files, like camera movement from other packages, like Maya also? A plugin?
    Is there still a canvas restriction in Motion 4?
    In Motion 3 using masks based on images, can give quite a few problems, for apparently no good reason at all. The mask seems to change size, and you'll have to find workarounds and so on. Is this still a problem in Motion 4? Any experiences?
    Thanks for your time!

    The camera data can only be exported from C4D 11.5 AFAIK.
    I'm not seeing issues with image masks in M4 yet.

  • JDAPI with multi canvas form and LAF questions

    I'm trying to use jdapi to apply LAF project on my forms, it works great with simple forms, but with multi canvases and blocks form it doesn't apply LAF for all of them. I can follow the code of the done one for the rest, but i have questions:
    do i have to set a different bean for each block?
    who overrides, the bean or the property set for the item?
    and sorry i have another questions concerning LAF:
    can i define a new scheme, and if yes, how?
    if i want to show an image for a button, the path should be relative to what? as till now i failed to set an image for a button.
    Thanks

    Hello,
    I have just tested and the result is OK.
    I have built a Forms module with 2 content canvases, each one containing a block.
    After running the JDAPI_LAF tool, the new module contains a LAF_BLOCK with two Bean area, each one one a different canvas.
    <p>Concerning the image on the button, the syntax is explained in the documentation</p>
    See the SET_IMAGE method.
    Francois

  • HTML5 Canvas: addChild and position

    Hey Guys
    I have an item on the stage called 'square1', I have added a symbol from the library and given it the name 'circle1'.
    I wish to position circle1 at the exact location of square1, my question is - how would I go about doing that?
    Thanks

    Knowing JavaScript is going to be essential for you to use Canvas. If you really don't want to get your hands into the code you should do your best with the timeline.
    If you're ready to take the canvas plunge then JavaScript has to become a tool for you. The second page of what I linked would show you that for almost every bit of ActionScript you might be used to, there's a translation over to JavaScript that's necessary. So every time you go to do something you're going to be right back here.
    The best option just might be for you to take a look at EaselJS. There's lots of very simple demos that can get you started with HTML5/Canvas and will give you answers you want in Flash. Take a look:
    CreateJS | A suite of Javascript libraries and tools designed for working with HTML5

  • Setting canvas width and height objectdraw

    I would like to kno how to set the window height and width so users cannot resize it. I would like the methods to be out of the library objectdraw
    Thanks

    motherboarddude wrote:
    [http://eventfuljava.cs.williams.edu/library/objectdrawJavadocV1.1.2/index.html] no clue
    What does 'no clue' mean? That you have no clue if it is J2SE? The answer is no, it is not J2SE (or even a Sun standard extension like JavaHelp or JOGL). We know nothing about that API and can provide no help with it.
    (And in future, try to make your replies specific enough that people do not have to 'guess' what you mean. That becomes irritating, very quickly.)
    OTOH a brief perusal of the JavaDocs suggests the API has no component that extends Frame or JFrame, so the answer to your request that it use one of the methods of your custom library is "No, it provides no functionality to restrict the size of the frame the user is offered - since that frame will come from the J2SE".
    Of course, if you simply wanted to ensure the drawing canvas is never resized, simply add it as a 'no args' element in a GridBagLayout with no other GUI components in it. If the GBL is used as described, the component will be centered within it. Add a JScrollPane to the component in case the user shrinks the frame smaller than the preferred size of the drawing area. In Java 1.6+, call setMinimumSize() after packing, and you can afford to lose the scroll pane.

  • Increase canvas conditionally and Conditonal copyright logo

    Hi,
    I want to increase the Canvas size of image conditionally depends on height or width of images. But the script is not giving proper results.
    Can Anyone help me in this. And also i have done bold for the text as comments. Even i need help in the comment mentioned line also
    Thanks in Advance,
    Script goes here:
    var cm3_5 = 3.5;
            var cm5 = 5;
            var cm8 = 8;
            var cm12 = 12;
            var cm13 = 13;
            var cm16 = 16;
            var cm17 = 17;
            var cm20 = 20;
            var cm21 = 21;
            var cm24 = 24;
            var cm25 = 25;
            var cm28 = 28;
            var cm28_5 = 28.5;
            var cm30 = 30;
            var cm30_5 = 30.5;
            var cm32 = 32;
            var cm32_5 = 32.5;
            var cm34 = 34;
            var cm34_5 = 34.5;
            var cm36 = 36;
            var doc=app.activeDocument;
                if(doc.width>doc.height)
                     if (doc.width<cm3_5){
                     var originalRulerUnits = app.preferences.rulerUnits;
                    app.preferences.rulerUnits = Units.CM;
                    doc.resizeCanvas(doc.width + 0.5, doc.height +0.5, AnchorPosition.MIDDLECENTER);
                    app.preferences.rulerUnits = originalRulerUnits;
                    }else  if (doc.width<cm5){
                     var originalRulerUnits = app.preferences.rulerUnits;
                    app.preferences.rulerUnits = Units.CM;
                    doc.resizeCanvas(doc.width + 0.75, doc.height +0.75, AnchorPosition.MIDDLECENTER);
                    app.preferences.rulerUnits = originalRulerUnits;
                    }else  if (doc.width<cm8 && doc.width>cm4){
                     var originalRulerUnits = app.preferences.rulerUnits;
                    app.preferences.rulerUnits = Units.CM;
                    doc.resizeCanvas(doc.width + 1, doc.height +1, AnchorPosition.MIDDLECENTER);
                    app.preferences.rulerUnits = originalRulerUnits;
                    }else  if (doc.width<cm12 && doc.width>cm8){
                     var originalRulerUnits = app.preferences.rulerUnits;
                    app.preferences.rulerUnits = Units.CM;
                    doc.resizeCanvas(doc.width + 1.5, doc.height +1.5, AnchorPosition.MIDDLECENTER);
                    app.preferences.rulerUnits = originalRulerUnits;
                    }else  if (doc.width<cm20 && doc.width>cm17){
                     var originalRulerUnits = app.preferences.rulerUnits;
                    app.preferences.rulerUnits = Units.CM;
                    doc.resizeCanvas(doc.width + 2, doc.height +2, AnchorPosition.MIDDLECENTER);
                    app.preferences.rulerUnits = originalRulerUnits;
                    if (doc.width<cm24 && doc.width>cm20){
                     var originalRulerUnits = app.preferences.rulerUnits;
                    app.preferences.rulerUnits = Units.CM;
                    doc.resizeCanvas(doc.width + 3, doc.height +3, AnchorPosition.MIDDLECENTER);
                    app.preferences.rulerUnits = originalRulerUnits;
    //Here the Error getting not able to increase canvas. How i want to write canvas conditionally
            if(doc.height>doc.width)
                     if (doc.width<cm8 && doc.height>cm5){
                     var originalRulerUnits = app.preferences.rulerUnits;
                    app.preferences.rulerUnits = Units.CM;
                    doc.resizeCanvas(doc.width + 1, doc.height +1, AnchorPosition.MIDDLECENTER);
                    app.preferences.rulerUnits = originalRulerUnits;
    //Here After the canvas depend on width i should run different waterks. Please  suggest to write conditionally
             if (doc.width<cm8 && doc.height>cm5){
            case1 var fileRef = new File(Folder.desktop + "/Watermark/Logo-8pt.png");//Here width or height is in between 8cm - 12cm i want to run 8pt logo.
            case2 var fileRef = new File(Folder.desktop + "/Watermark/Logo-10pt.png");//Here width or height is in between 13cm - 16cm i want to run 10pt logo.
                var fileRef = new File(Folder.desktop + "/Watermark/Logo-12pt.png");//Here width or height is in between 17cm - 20cm i want to run 12pt logo.
                var fileRef = new File(Folder.desktop + "/Watermark/Logo-14pt.png");//Here width or height is in between 21cm - 24cm i want to run 14pt logo.
                var fileRef = new File(Folder.desktop + "/Watermark/Logo-16pt.png");//Here width or height is in between 25cm - 28cm i want to run 16pt logo.
                var fileRef = new File(Folder.desktop + "/Watermark/Logo-18pt.png");//Here width or height is in between 28.5cm - 30cm i want to run 18pt logo.
                var fileRef = new File(Folder.desktop + "/Watermark/Logo-20pt.png");//Here width or height is in between 30.5cm - 32cm i want to run 20pt logo.
                var fileRef = new File(Folder.desktop + "/Watermark/Logo-22pt.png");//Here width or height is in between 32.5cm - 34cm i want to run 22pt logo.
                var fileRef = new File(Folder.desktop + "/Watermark/Logo-24pt.png");//Here width or height is in between 34.5cm - 36cm i want to run 24pt logo.
                //Here one more thing also i want to wrie if width in beween 12cm to 13cm(Eg., 12.5, 12.8, 12.6, 12.1). See Case1 & 2.
        var sourceDoc = app.open(fileRef); 
        sourceDoc.activeLayer.duplicate (doc);
        sourceDoc.close(SaveOptions.DONOTSAVECHANGES);

    Hi,
    Thanks for the reply
    Used to work on product images. procedure goes like this:
    1. Cut the product
    2. Change colour mode
    3. Make path
    4. Clear background
    5. Trim
    6. Increase canvas(Relative)
    7. Save as tiff
    Here i am getting error in No.6 Step (The canvas should increase Conditionally Depend on image size in Cm's. If Width is more than height it should consider Width.  If height is more than width it should consider height.). i have standards like this much width means this much canvas(relative) should increase. So the standards are mentioned as variable at the start of the script. So i want to write Canvas as conditionally.
    Script goes here:
            var cm3_5 = 3.5;
            var cm5 = 5;
            var cm8 = 8;
            var cm12 = 12;
            var cm13 = 13;
            var cm16 = 16;
            var cm17 = 17;
            var cm20 = 20;
            var cm21 = 21;
            var cm24 = 24;
            var cm25 = 25;
            var cm28 = 28;
            var cm28_5 = 28.5;
            var cm30 = 30;
            var cm30_5 = 30.5;
            var cm32 = 32;
            var cm32_5 = 32.5;
            var cm34 = 34;
            var cm34_5 = 34.5;
            var cm36 = 36;
                    var doc=app.activeDocument;
                    var originalRulerUnits = app.preferences.rulerUnits;
                    app.preferences.rulerUnits = Units.CM;
                if(doc.width>doc.height)
                     if (doc.width<cm3_5){
                    doc.resizeCanvas(doc.width + 0.5, doc.height +0.5, AnchorPosition.MIDDLECENTER);
                    }else  if (doc.width<cm5){
                    doc.resizeCanvas(doc.width + 0.75, doc.height +0.75, AnchorPosition.MIDDLECENTER);
                    }else  if (doc.width<cm8 && doc.width>cm4){
                    doc.resizeCanvas(doc.width + 1, doc.height +1, AnchorPosition.MIDDLECENTER);
                    }else  if (doc.width<cm12 && doc.width>cm8){
                    doc.resizeCanvas(doc.width + 1.5, doc.height +1.5, AnchorPosition.MIDDLECENTER);
                    }else  if (doc.width<cm20 && doc.width>cm17){
                    doc.resizeCanvas(doc.width + 2, doc.height +2, AnchorPosition.MIDDLECENTER);
                    if (doc.width<cm24 && doc.width>cm20){
                    doc.resizeCanvas(doc.width + 3, doc.height +3, AnchorPosition.MIDDLECENTER);
    //Here the Error getting not able to increase canvas. How i want to write canvas conditionally
            if(doc.height>doc.width)
                     if (doc.width<cm8 && doc.height>cm5){
                    doc.resizeCanvas(doc.width + 1, doc.height +1, AnchorPosition.MIDDLECENTER);
    //End of canvas
    doc.changeMode(ChangeMode.RGB);
    //Here again i want to put watermarks depend on size again (If Width is more than height it should consider Width.  If height is more than width it should consider height.). So i need to write here also conditionally
    add watermarks kindly suggest. How to write.
    //Here After the canvas depend on width i should run different watermarks. Please  suggest to write conditionally
             if (doc.width<cm8 && doc.height>cm5){
            case1 var fileRef = new File(Folder.desktop + "/Watermark/Logo-8pt.png");//Here width or height is in between 8cm - 12cm i want to run 8pt logo.
            case2 var fileRef = new File(Folder.desktop + "/Watermark/Logo-10pt.png");//Here width or height is in between 13cm - 16cm i want to run 10pt logo.
                var fileRef = new File(Folder.desktop + "/Watermark/Logo-12pt.png");//Here width or height is in between 17cm - 20cm i want to run 12pt logo.
                var fileRef = new File(Folder.desktop + "/Watermark/Logo-14pt.png");//Here width or height is in between 21cm - 24cm i want to run 14pt logo.
                var fileRef = new File(Folder.desktop + "/Watermark/Logo-16pt.png");//Here width or height is in between 25cm - 28cm i want to run 16pt logo.
                var fileRef = new File(Folder.desktop + "/Watermark/Logo-18pt.png");//Here width or height is in between 28.5cm - 30cm i want to run 18pt logo.
                var fileRef = new File(Folder.desktop + "/Watermark/Logo-20pt.png");//Here width or height is in between 30.5cm - 32cm i want to run 20pt logo.
                var fileRef = new File(Folder.desktop + "/Watermark/Logo-22pt.png");//Here width or height is in between 32.5cm - 34cm i want to run 22pt logo.
                var fileRef = new File(Folder.desktop + "/Watermark/Logo-24pt.png");//Here width or height is in between 34.5cm - 36cm i want to run 24pt logo.
                //Here one more thing also i want to wrie if width in beween 12cm to 13cm(Eg., 12.5, 12.8, 12.6, 12.1). See Case1 & 2.
        var sourceDoc = app.open(fileRef);
        sourceDoc.activeLayer.duplicate (doc);
        sourceDoc.close(SaveOptions.DONOTSAVECHANGES);
    I hope i explained my problems clearly.
    Thanks in Advance,
    Regards,
    Suresh

  • A Canvas, Button and TextField

    What is the best way to fit these 3 components to a JFrame?
    I want the Canvas object to take 90 % of the page and the textfield and Button along the bottom?
    Cheers ...

    About like this:
        Container c = getContentPane();
        Canvas can = new Canvas();
        can.setSize(350, 350);
        c.add( can );
        JPanel jp = new JPanel();
        jp.setLayout( new FlowLayout() );
        jp.add( new JButton("hi") );
        jp.add(new JTextField("hi back at ya") );
        c.add( jp, BorderLayout.SOUTH);
        pack();

Maybe you are looking for

  • I wish to do a clean-install of Lion due to abnormal behaviour.

    Currently I have Lion on my iMac.  I have been having abnormal behavior as of late and I wish to start fresh as I am think a piece of software is causing my troubles.  I just cannot pinpoint what it is.  So I wish to do a complete erase and refresh o

  • Office 2008 in Lion

    Hello,      I'm thinking about getting Lion for my mac, but I want to know how it will effect my Office for Mac 2008 Home and Student Edition. Also If I can use it or if I need to download an update. Thanks!

  • Can an iphone with a case fit in the michael kors wallet clutch?

    can an iphone with a case fit in the michael kors wallet clutch? I was thinking of getting it but I do not want to take my pittsburgh penguins case off just so it can fit inside of it.

  • IBook G4 into Windows machine

    Hi all, I would like to turn my 2004 iBook G4 (1.33 GHz Power PC G4) into a Windows machine.  It hasn't been my main computer for more than two years, so I'd like to have some other functionality out of it. I know very little about Windows and and Bo

  • How do I keep folder/album structure on import?

    I have a large directory tree of images I'd like to import into iPhoto 6. Like this: Nature / California / Big Sur / <pictures> Nature / California / Lake Tahoe / Sunsets / <pictures> Nature / California / Lake Tahoe / Snowboarding / <pictures> Natur