Drawing on a Canvas

I know this may seem trivial, but for some reason I am having trouble drawing rectangles on an Canvas. Either I get that the Graphics object is null or the objects just don't show up. Any suggestions? Any help would be very much appreciated. Here are the relevant parts of my code:
This code is in a class that extends Canvas:
public void paint(Graphics g) {
g.setColor(Color.black);
g.fillRect((int)obstacleArray[0][0], (int)obstacleArray[i][0][1], tempwidth, tempheight);
g.drawImage(myImg, 0, 0, this);
} // end paint

Nevermind - I solved my problem. I was sending in a height of zero. :)

Similar Messages

  • Drawing mc with canvas on it

    Hey,
    I got a problem with displaying canvas on mc, which is drawn on BitmapData object. Code is more or less:
    var can:Canvas = new Canvas;
    can.setStyle("backgroundColor","blue");
    can.width = 100;
    can.height = 100;
    can.x = 100;
    can.y = 100;
    var mc:MovieClip = new MovieClip
    mc.addChile(can);
    var bd:BitmapData = new BitmapData;
    bd.draw(mc);
    this.beginBitmapFill(bd,new Matrix(),false,false);
    this.graphics.endFill();
    And I dont see the canvas. ValidateNow() or callLater doesn't help either.
    On the other if I add a sprite instead of canvas I can see this sprite on screen.
    What should I do and why validateNow() doesn't help in this case?

    thanks for that :)
    my problem is that the nodes are placed inside a panel to appear as draggable entities on the GUI interface using the google web toolkit. that way I need to somehow not put the JPanels in a JFrame but in the panel created by google web toolkit, which I think you cannot do?

  • Desktop drawing not on canvas

    sir,
    how can we draw directly on the desktop (not ordinery drawing using canvas or in an application).This is possible using VC++ and has implemented in the site gotomypc.com .
    What I want to do exactly is whenever I just drag the mouse on my desktop (not in any of the application)the pixels correspond to the mouse pointer should change to different color.For this there may be one java program which wait for the mouse event (not ordinary java.awt.event s or ordinary swing events )

    I hope I understand your question, but I will try to answer.
    Using VC++ there is an application running, and that is the OS. So, the fact that you can draw directly on the desktop is not surprise.
    In order for Java to work there must be an application running, and all drawing is done within it's window(s).
    Now, if you create your own desktop that is a java application, then you can simulate what you want to do.

  • Drawing To A Canvas

    I have an applet that takes coordinates for numerous points and then displays them on a canvas.
    I have method that sets the required arguments in my canvas class, which should then draw a polygon to the canvas. this is the code of my canvas.
    iport java.awt.*;
    public class PolygonCanvas extends Canvas
         double maxValue;
         double scaleFactor=0;
         int numPoints=3;
         Polygon poly;
         int[] xPoints,yPoints;
    public void setValues(double[] xValues,double[] yValues,int numPoints,double maxvalue)
         scaleFactor=450/maxValue;
              for(int i=0;i<numPoints;i++)
                   int tempInt;
                   double tempDouble;     
                   tempInt=0;
                   tempDouble=0;
                   tempDouble=xValues;
                   tempDouble=tempDouble*scaleFactor;
                   tempInt=(int)tempDouble;
                   xPoints[i]=tempInt;
                   tempInt=0;
                   tempDouble=0;     
                   tempDouble=yValues[i];
                   tempDouble=-(tempDouble*scaleFactor);
                   tempInt=(int)tempDouble;
                   yPoints[i]=tempInt;
         makePolygon(xPoints,yPoints,numPoints);
         public void makePolygon(int[] xPoints,int[] yPoints, int numPoints)
              poly=new Polygon(xPoints,yPoints,numPoints);
         public void paint(Graphics g)
              g.translate(225,225);
              g.drawLine(0,274,0,-274);
              g.drawLine(-224,0,224,0);
              if(poly !=null)
                   g.drawPolygon(poly);
         public Dimension getPreferredSize()
              return new Dimension(450, 450);
         public void update(Graphics g)
              paint(g);
    My main class sets the arguments and sends then to the canvas object, but I get nothing displayed on screen.
    Ive also been instructed to use
    public void update(Graphics g)
    paint(g);
    but when I try and call udate(); to refresh the canvas, but I get an error the the symbol "method update" cannot be resolved.
    Can anyone point me in the right direction, or let me have the location of a tutorial/similar, for this sort of thing.
    Thanks
    cudog

    try calling repaint() at the end of makePolygon

  • Draw Rectangle to Canvas ?

    I am finding that working with drawing shape in Java is a bit hard to understand. I am hoping someone can help me out. I have wanting to draw a simple Rectangle to a Canvas. I am hoping that will give the user the look that a Rectangle has been drawn to the screen and not inside of a JFrame or anything like that.
    Here is my code that does not seam to work.
    Canvas can;
    Graphics g2;
    Rectangle r;
    public void drawShape()
           can = createCanvas();
           g2 = can.getGraphics();
           g2.drawRect(0, 0, 640, 480);
    //create canvas that I call from another class
    public Canvas createCanvas( )
              r.width = java.awt.Toolkit.getDefaultToolkit().getScreenSize().width;
              r.height = java.awt.Toolkit.getDefaultToolkit().getScreenSize().height;
              r.x = 0;
              r.y = 0;
              if(box == null)
                   box = new Canvas();
                   box.setBounds(r);
              return box;
         }

    simple demo, might start you off
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    class Testing
      public void buildGUI()
        JPanel p = new JPanel(){
          public void paintComponent(Graphics g){
            super.paintComponent(g);
            g.drawString("alt-F4 to close",400,300);
            g.drawRect(300,200,300,200);
        p.setBackground(Color.WHITE);
        JFrame f = new JFrame();
        f.getContentPane().add(p);
        f.setUndecorated(true);
        GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().setFullScreenWindow(f);
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.setVisible(true);
      public static void main(String[] args)
        SwingUtilities.invokeLater(new Runnable(){
          public void run(){
            new Testing().buildGUI();
    }more reading here
    [http://java.sun.com/docs/books/tutorial/uiswing/painting/index.html]
    and this
    can.getGraphics();is generally a very bad way to do it

  • Cannot Draw images to Canvas

    Hey guys i am having trouble drawing my images to my canvas can anyone provide me with some advice id really appreciate it. Thanks in advance. here is my code so far. I also posted this question on another forum but no response yet.
    package pgame;
    import javax.swing.*;
    import java.awt.*;
    public class PGame extends JPanel {
         public PGame() {
         add(new PBoard());
        public static void main(String[] args){
        JFrame frame = new JFrame("Game");
        frame.setContentPane(new PBoard());
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        frame.setSize(240,430);
        frame.setResizable(false);
        frame.setVisible(true);
    package pgame;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*; 
    import javax.swing.event.*;
    import java.awt.image.BufferedImage;
    import java.awt.Graphics2D;
    public class PBoard extends JPanel{
    Canvas canvas;
    final int height = 12;
    final int width = 6;
    final int canvas_height = height*32;
    final int canvas_width = width*32;
    private BufferedImage bufferedImage;
    Image image[];
      public PBoard() {
          super();
         image = new Image[4];
         image[0] = Toolkit.getDefaultToolkit().getImage("image1.png");
         image[1] = Toolkit.getDefaultToolkit().getImage("image2.png");
         image[2] = Toolkit.getDefaultToolkit().getImage("image3.png");
         image[3] = Toolkit.getDefaultToolkit().getImage("image4.png");
         canvas = new Canvas();
         canvas.setBounds(20,20,240,430);
         canvas.setSize(canvas_width,canvas_height);
         canvas.setBackground(Color.BLACK);
         add(canvas);
        public void paintComponent(Graphics g){
        super.paintComponent(g); 
        g.setColor(Color.RED);
        g.drawRect(0,0,233,397); // Draw a border
        g.drawImage(image[0],0,0,this);
    }

    Riz01 wrote:
    I have no real reason for it i just did it i was thinking of creating a double buffer and drawing my image through that onto my canvas.A very bad reason for doing this. Swing is double buffered automatically. When you use a Canvas, you lose this. Also, when you combine Swing and AWT components in the same GUI, strange bugs can occur. Please don't do this unless you know why you're doing it, and how to avoid the bugs that it will cause.

  • Stop screen drag when drawing on a canvas

    I'm trying to do a signature capture on a HTML5 canvas. When I try to use a stylus to write on the canvas all it does is drag the screen around. Is there a way to disable the screen drag for certain elements or for the whole web page?
    I've tried the Meta "viewport" setting to size the device width and height and also played with the @media "visual" in the CSS but also with no success.
    Thanks in advance.
    Terry

    It's not possible to do this in the current version of Firefox for Android, but you will be able to do it soon using touch events. As long as the Firefox toolbars are off-screen, you can call "event.preventDefault()" on the "touchstart" event to stop the page from scrolling. For more documentation, see:
    http://www.w3.org/TR/touch-events/
    https://wiki.mozilla.org/Fennec/Features/touch
    Touch events are already supported by Safari and by the default Android Browser. They will be also be supported in Firefox 6 for Android, which will be released in August 2011. You can start testing Firefox 6 with touch event support today by downloading an Aurora build:
    https://wiki.mozilla.org/Mobile/Platforms/Android#Download_Aurora
    (Note: the touch event standard is still in development, and not all browsers support all parts of the specification.)

  • [URGENT]Is it possible to get the drawing on canvas to an imagebuffer?

    Hey Everyone
    I am having serious problems in my project 'Picture Editor'.
    I am drawing objects on to the canvas since this is the only way u can draw in J2me. Now I need to get that drawing on the canvas as an Image or as an imagebuffer(rgb[]) so that I can store it. But is it possible to do that.
    Can anyone help me with this.

    The RecordStores store plain byte arrays. If you want to have something like a filename and such, then you need to come up with your own "format". For example, before the begginning of the pixel data you put in a null terminated string. Then when you read the data, you first read all the bytes up to the fist 0 you find, this part will be the name, and after that you know will come the actual image data. In short, you can put in whatever you want in a RecordStore, you just have to make sure you read things in the same way you wrote them.
    Another option would be to just create separate RecordStores for each image, with the name of the image. But this could become a problem if you are saving a lot of images.
    shmoove

  • Can I add Any Layer on drawing canvas  ? if yes, How  ?

    Hi,
    I am developing a paint application in java JApplet. And I am drawing something like rectangle, free hand, oval, circle on canvas. I want to add Layer, which gives me seperate layer to work without erasing previous. I just read about LayeredPane and GlassPane. Which is suitable for using drawing. If it is layeredPane. then please tell me how to add single layer at single action performing like when I want to press pencil button then the layer will add. And when i want to press rectangle then second layer will add. And if it is GlassPane then how can i use it. I have used Glasspane. It making all buttons disabled. I just want to use it within drawing canvas. Please help me.....
    Thanks in advance
    Manveer

    Hello,
    I have read all documentation of JLayeredPane. Now I want to use it. Firstly I want to tell you that I have used a separate private class that is extending Panel. Then I have used double buffering for drawing anything on it. And after this I have added this class on JApplet by using getContentPane(). Can i add this canvas as layer, which contains images or drawing. Now what i want that When i have draw some thing on drawing canvas. And again want to draw something on canvas. at that time the canvas will add a layer which is a panel with setOpaque(false). which is totally transparent. And after set layer on canvas. the previous drawing remain same not be wash out or lost. And I can see the previous drawing after set layer. Please tell me how to do this. If you have any simple example or any advice for doing right thing. please tell me or send me.

  • Having a problem saving the graphics on a canvas.

    I'm having a problem saving graphics on a canvas. It draws on the canvas but when another window comes up the graphics disappear. I put in a method to take the graphics on the canvas and repaint it with the graphics. But this comes up blank. So I don't know why this is happening. It is probably the paint method but I don't know why. If anyone has any ideas could you please respond because I have had this problem for ages now and it's driving me mad and I have to get this finished or I'm going to be a lot of trouble. I'll show you the code for the class I am concerned with. It is long but most of it can be disregarded. The only parts which are relevent are the paint method and where the drawline e.t.c are called which is in the mouse release
    package com.project.CSSE4;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.ImageFilter;
    import java.awt.image.CropImageFilter;
    import java.awt.image.FilteredImageSource;
    import java.io.*;
    import java.util.*;
    import java.net.*;
    import javax.swing.*;
    import java.sql.*;
    public class CanvasOnly extends JPanel
           implements MouseListener, MouseMotionListener
       public static final int line = 1;
       public static final int freehand = 2;
       public static final int text = 3;
       public static final int mode_paint = 0;
       public static final int mode_xor = 1;
       public Color drawColor;
       public int drawThickness = 1;
       public int drawType = 0;
       public boolean fill = false;
       private boolean dragging = false;
       public int oldx = 0;
       public int oldy = 0;
       private int rectangleWidth;
       private int rectangleHeight;
       private tempLine draftLine;
       private tempText draftText;
       public Canvas pad;
       public static final Font defaultFont =
         new Font("Helvetica", Font.BOLD, 14);
       protected boolean floatingText = false;
       boolean showingPicture;
       protected Image offScreen;
       public JTextArea coor;
       public JButton writeIn;
       Connection connection;
       String codeLine;
       int x = 0;
       int y = 0;
       public CanvasOnly()
           try
                Class.forName("com.mysql.jdbc.Driver").newInstance();
           }catch( Exception e)
                 System.err.println("Unable to find and load driver");
                 System.exit(1);
            pad = new Canvas();
            pad.setBackground(Color.white);
            pad.setVisible(true);
            pad.setSize(400, 400);
           coor = new JTextArea(15, 15);
           writeIn = new JButton("load TExt");
           writeIn.addActionListener(new ActionListener()
                   public void actionPerformed(ActionEvent event1)
                     try
                   Statement statement = connection.createStatement();
                   ResultSet rs = statement.executeQuery("SELECT * FROM submit WHERE file_name = 'cmd.java'");
                   rs.next();
                   String one1 = rs.getString("student_id");
                   //System.out.println("one1 :" + one1);
                   String two1 = rs.getString("file_name");
                   //System.out.println("two1 : " + two1);
                    InputStream textStream = rs.getAsciiStream("file");
                    BufferedReader textReader = new BufferedReader(
                                     new InputStreamReader(textStream));
                    codeLine = textReader.readLine();
                    x = 0;
                    y = -12;
                    while(codeLine != null)
                        y = y + 12;
                        //fileText.append( line + "\n");
                        //canvasPad.drawTheString(line, x, y);
                        drawText(Color.black, x, y, codeLine, mode_paint);
                        codeLine = textReader.readLine();
                     textReader.close();
                    pad.setSize(400, y);
                    Timestamp three1 = rs.getTimestamp("ts");
                    //System.out.println(three1);
                    textReader.close();
                    rs.close();
              }catch (SQLException e)
                System.err.println(e);
              catch(IOException ioX)
                System.err.println(ioX);
            //setSize(300,300);
            drawColor = Color.black;
            pad.addMouseListener(this);
         pad.addMouseMotionListener(this);
         offScreen = null;
       public Image getContents()
         // Returns the contents of the canvas as an Image.  Only returns
         // the portion which is actually showing on the screen
         // If the thing showing on the canvas is a picture, just send back
         // the picture
         if (showingPicture)
             return (offScreen);
         ImageFilter filter =
             new CropImageFilter(0, 0, getWidth(), getHeight());
         Image newImage =
             createImage(new FilteredImageSource(offScreen.getSource(),
                                  filter));
         return(newImage);
        public void setImage(Image theImage)
         // Fit it to the canvas
         offScreen = theImage;
         repaint();
         showingPicture = true;
        synchronized public void paint(Graphics g)
         int width = 0;
         int height = 0;
         //The images are stored on an off screen buffer.
            //offScreen is the image declared at top
         if (offScreen != null)
                  //intislise the widt and heigth depending on if showingpicture is true
              if (!showingPicture)
                       width = offScreen.getWidth(this);
                       height = offScreen.getHeight(this);
                   //width = getWidth(this);
                   //height = getHeight(this);  //offScreen
              else
                   //width = pad.getSize().width;
                   //height = getSize().height;
                   width = pad.getWidth();
                   //width = getSize().width;
                   height = pad.getHeight();
                   //height = getSize().height;
                    //Draws as much of the specified image as has already
                    //been scaled to fit inside the specified rectangle
                    //The "this" is An asynchronous update interface for receiving
                    //notifications about Image information as the Image is constructed
    //This is causing problems
              g.drawImage(offScreen, 0, 0, width, height, pad);
              g.dispose();
         //clear the canvas with this method
        synchronized public void clear()
         // The maximum size of the usable drawing canvas, for now, will be
         // 1024x768
         offScreen = createImage(1024, 768);
         //Creates an off-screen drawable image to be used for double buffering
         pad.setBackground(Color.white);
         //Set the showingPicture to false for paint method
         showingPicture = false;
         repaint();
         synchronized public void drawLine(Color color, int startx, int starty,
                              int endx, int endy, int thickness,
                              int mode)
         int dx, dy;
         Graphics g1 = pad.getGraphics();
         Graphics g2;
         //if image is not intialised to null
         //the getGraphics is used for freehand drawing
         //Image.getGraphics() is often used for double buffering by rendering
            //into an offscreen buffer.
         if (offScreen != null)
             g2 = offScreen.getGraphics();
         else
             g2 = g1;
            //mode is put into the method and XOR is final and equal to 1
         if (mode == this.mode_xor)
                  //calls the setXOR mode for g1 and g2
                  //Sets the paint mode of this graphics context to alternate
                    //between this graphics context's current color and the
                    //new specified color.
              g1.setXORMode(Color.white);//This will
              g2.setXORMode(Color.white);
         else
                  //Sets this graphics context's current color to the
                    //specified color
              g1.setColor(color);
              g2.setColor(color);
         if (endx > startx)
             dx = (endx - startx);
         else
             dx = (startx - endx);
         if (endy > starty)
             dy = (endy - starty);
         else
             dy = (starty - endy);
         if (dx >= dy)
              starty -= (thickness / 2);
              endy -= (thickness / 2);
         else
              startx -= (thickness / 2);
              endx -= (thickness / 2);
         for (int count = 0; count < thickness; count ++)
              g1.drawLine(startx, starty, endx, endy);
              g2.drawLine(startx, starty, endx, endy);
              if (dx >= dy)
                  { starty++; endy++; }
              else
                  { startx++; endx++; }
            //Disposes of this graphics context and releases any system
            //resources that it is using.
         g1.dispose();
         g2.dispose();
         //This method is not causing trouble
         synchronized public void drawText(Color color, int x, int y,
                String text, int mode)
         Graphics g1 = pad.getGraphics();
         Graphics g2;
         if (offScreen != null)
             g2 = offScreen.getGraphics();
         else
             g2 = g1;
         if (mode == this.mode_xor)
              g1.setXORMode(Color.white);
              g2.setXORMode(Color.white);
         else
              g1.setColor(color);
              g2.setColor(color);
         g1.setFont(new Font("Times Roman", Font.PLAIN, 10));
         g2.setFont(new Font("Times Roman", Font.PLAIN, 10));
         g1.drawString(text, x, y);
         g2.drawString(text, x, y);
         g1.dispose();
         g2.dispose();
          //connect to database
      public void connectToDB()
        try
           connection = DriverManager.getConnection(
           "jdbc:mysql://localhost/submissions?user=root&password=football");
                     //may have to load in a username and password
                                                     //code "?user=spider&password=spider"
        }catch(SQLException connectException)
           System.out.println("Unable to connect to db");
           System.exit(1);
      //use this method to instatiate connectToDB method
      public void init()
           connectToDB();
        protected void floatText(String text)
         draftText = new tempText(this.drawColor,
                            this.oldx,
                            this.oldy,
                                        text);
         this.floatingText = true;
        //nothing happens when the mouse is clicked
        public void mouseClicked(MouseEvent e)
        //When the mouse cursor enters the canvas make it the two
        //straigth lines type
        public void mouseEntered(MouseEvent e)
         pad.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
        //When mouse exits canvas set to default type
        public void mouseExited(MouseEvent E)
         pad.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        //used for creating the shapes and positioning thetext
        public void mousePressed(MouseEvent e)
             // Save the coordinates of the mouse being pressed
         oldx = e.getX();
         oldy = e.getY();
         // If we are doing lines, rectangles, or ovals, we will show
         // draft lines to suggest the final shape of the object
         //Draw type is a publc int which can be changed
         if (drawType == this.line)
            draftLine = new tempLine(drawColor, oldx, oldy, oldx,
                                 oldy, drawThickness);
            // Set the draw mode to XOR and draw it.
            drawLine(draftLine.color, draftLine.startx,
            draftLine.starty, draftLine.endx,
            draftLine.endy, drawThickness, this.mode_xor);
        //mouse listener for when the mouse button is released
        public void mouseReleased(MouseEvent e)
             if (drawType == this.line)
              // Erase the draft line
              drawLine(draftLine.color, draftLine.startx, draftLine.starty,
                    draftLine.endx, draftLine.endy, drawThickness,
                    this.mode_xor);
              // Add the real line to the canvas
              //When the imput changes to "mode_paint" it is drawen
              //on the canvas
              drawLine(drawColor, oldx, oldy, e.getX(), e.getY(),
                    drawThickness, this.mode_paint);
              dragging = false;
         else if (drawType == this.text)
              if (floatingText)
                   // The user wants to place the text (s)he created.
                   // Erase the old draft text
                   drawText(drawColor, draftText.x, draftText.y,
                                            draftText.text, this.mode_xor);
                       String str = Integer.toString(e.getX());
                       String str1  = Integer.toString(e.getY());
                       coor.append(str + " " + str1 + "\n");
                   // Set the new coordinates
                   draftText.x = e.getX();
                   draftText.y = e.getY();
                   // Draw the permanent text
                   drawText(drawColor, draftText.x, draftText.y,
                         draftText.text, this.mode_paint);
                   floatingText = false;
         public void mouseDragged(MouseEvent e)
            if (drawType == this.freehand)
              drawLine(drawColor, oldx, oldy, e.getX(), e.getY(),
                    drawThickness, this.mode_paint);
              oldx = e.getX();
              oldy = e.getY();
         else
             dragging = true;
         if (drawType == this.line)
            // Erase the old draft line
            drawLine(draftLine.color, draftLine.startx, draftLine.starty,
              draftLine.endx, draftLine.endy, drawThickness,
              this.mode_xor);
            // Draw the new draft line
            draftLine.endx = e.getX();
            draftLine.endy = e.getY();
            drawLine(draftLine.color, draftLine.startx, draftLine.starty,
              draftLine.endx, draftLine.endy, drawThickness,
              this.mode_xor);
         public void mouseMoved(MouseEvent e)
             if (floatingText)
              // When the user has entered some text to place on the
              // canvas, it remains sticky with the cursor until another
              // click is entered to place it.
              // Erase the old draft text
              drawText(drawColor, draftText.x, draftText.y,
                                draftText.text, this.mode_xor);
              // Set the new coordinates
              draftText.x = e.getX();
              draftText.y = e.getY();
              // Draw the new floating text
              drawText(drawColor, draftText.x, draftText.y,
                        draftText.text, this.mode_xor);
         //declare  a class for the line shown before the is as wanted
        class tempLine
         public Color color;
         public int startx;
         public int starty;
         public int endx;
         public int endy;
         public int thickness;
         public tempLine(Color mycolor, int mystartx, int mystarty,
                      int myendx, int myendy, int mythickness)
             color = mycolor;
             startx = mystartx;
             starty = mystarty;
             endx = myendx;
             endy = myendy;
             thickness = mythickness;
        class tempText
         public Color color;
         public int x;
         public int y;
         public String text;
         public tempText(Color mycolor, int myx, int myy, String mytext)
             color = mycolor;
             x = myx;
             y = myy;
             text = mytext;
    }

    http://www.java2s.com/ExampleCode/2D-Graphics/DemonstratingUseoftheImageIOLibrary.htm

  • Displaying tab page canvas on content canvas in Forms 6i

    Forms [32 Bit] Version 6.0.8.8.0 (Production)
    I have an existing form which has multiple canvases and there are couple of fields on Content canvas and then on the same content a Tab canvas is layed out. I can see both canvases in same layout editor and select and move the tab canvas.
    But when I create a new form and want to layout a tab canvas on top of content, it appears in a separate layout editor window on design time.
    I want it like below:
    -----------content--------------------
    |                                       |
    |                                       |
    |                                       |
    |TabPag1     TabPage2                   |
    |                                       |
    |                                       |
    |                                       |
    |                                       |
    |                                       |
    |                                       |
    -------------content------------------How can I create it so that it appears in same layout editor window at design time and appears in same window like one canvas on runtime.

    In order for the Tabbed Canvas to appear on the Content Canvas in the Layout Editor, you have to actually draw the Tabbed Canvas on the Content Canvas; eg: open your content canvas in the layout editor, click on the tabbed canvas toolbar button and then draw it on your content canvas. If you create the Tabbed Canvas object through the Object Navigator and then set the properties so it would display on the content canvas - it won't be visible on the content canvas with the layout editor.
    This is a bit of a quirk in the Forms Builder and they haven't corrected this in any of the newer versions of Forms yet. :-(
    Hope this helps,
    Craig B-)
    If someone's response is helpful or correct, please mark it accordingly.

  • Photoshop 3D Brushes not drawing in correct place?

    Hi,
    The 3D brushes in Photoshop are all great and very fun to use, especially the newer 3D pencil brushes, but ealrier I was getting quite irritated by the 3D brushes and where they actually draw on the canvas in relation to the 'tip' of the brush cursor on screen.
    The brushes I am specifically talking about are the first set of actual 'paint brushes' typically found on the 2nd row down on the standard brush menu. Usually when I use these, I turn on opacity and flow jitter to respond to brush pressure, and of course the angle is determined by the angle at which I hold my tablet pen as they are 3D simulated brushes.
    I notice that the newer pencil brushes work flawlessly, drawing exactly under the pointed area of the brush cursor, supposedly simulating the look of the lead of a pencil. This works just fine, and is easy to understand where the mark will appear on the canvas when I use them.
    But the paint brush brushes lack this for me, and I'm not sure if its something wrong my end, or if its supposed to be this way? For example, if I tilt my brush at a normal shading angle to try and get a nice even. thick coat of paint from the tip, it instead seems to come out infront of my brush cursor not under it, and as a much thinner line that expected. This is not a big problem but when you try to do very precise tonal work in tight areas of an image, this trick on the eyes gets old fast.
    Anyone have any suggestions as ways to fix this? Or is it suppoed to be like this and is the same for everyone else? If so, I'd persoanly push to try to change this in the next PS version to work more like the pencil brushes do, with the marks they make coming out from under their cursors instead of randomly about half an inch infront of them at times. Hope people understand what I mean: if not I'll try to make a video capture to get what the cursor is doing in relation to whats being drawn.
    Thanks,
    - Ricky

    These are the options I see.

  • How to transfer a figure drawn on a canvas via bluetooth?

    Hi,
    I am developing an application that will draw multiple figures like rectangle, circle,square on a canvas.I want to send this via bluetooth to other device.In which format should i send this?How?
    Thanks
    Aiswarya

    You will need capture the screen. Steps are
    1) Create Image of the size of your canvas.
    2) Get graphics object for this image using getGraphics() method of Image.
    3) Whenever you draw on the canvas, also draw on this image using the graphics object you obtained from Image.
    4) Use getRGB() method of the image to grab the pixels.
    Use JSR 82 to transfer this data over bluetooth.
    Atul

  • How to create 2 scroll bar in 2 canvas

    Hello All,
    I will appreciate if somebody knows how to create 2 scroll bars in 2 Content canvases and all items text item belongs to one data block.
    In data block property it shows only one scroll bar. Their is no property of scroll bar in canvas.
    Regards,
    Atif

    Go to the layout editor.
    Take the Stacked canvas tool in the toolbox
    draw a stacked canvas on the content canvas (the stacked can could be larger than the content one)
    edit you item properties to display on the content canvas
    adjust the window to the same width and weight properties than the content canvas.
    The simplest way it to use the datablock wizard to create the data block, then indicate to show items not on the content canvas but the stacked canvas.
    Francois

  • JMenuBar is hidden by Canvas

    Hi,
    I have a class that extends JFrame, this has a JMenuBar set to it (set with setJMenuBar method of JFrame) and is displayed fine until i try to add a java.awt.Canvas object to the center of the JFrame(using a BorderLayout) . When this canvas has been added then you can still click on the JMenu names in the JMenuBar but the JMenu itself is no hidden behind the canvas. Here is some of the code
    Class that extends JFrame's constructor
    //call the super constructor
              super("My Image Viewer");
              //get the content pane
              c = getContentPane();
              //set the layout of the frame
              c.setLayout(new BorderLayout());
              //create a new MenuHandler
              menuHandler = new MenuHandler();
              //create a new JFileChooser
              fileChooser = new JFileChooser("C:/Documents and Settings/"
                        + "Irene Stephanie/My Documents");
              //create a new file filter
              filter = new ImgFilter();
              //assign the file filter
              fileChooser.setFileFilter(filter);
              //create a new window canvas
              canvas = new WindowCanvas();
              add("Center", canvas);
              //set up the menus
              initMenu();
              //set the JMenuBar
              setJMenuBar(menuBar);
              //Set the window size
              setSize(640, 480);
              //make the window visible
              setVisible(true);Class that extends Canvas
    public class WindowCanvas extends Canvas{
         public WindowCanvas(){
              super();
         public void paint(Graphics g){
         }Please not that it works if you add the JMenuBar to the South position, and that you can draw in the canvas, but you cannot see the JMenu's.
    Any help will be greatly apreciated
    Andy

    A Canvas is a heavyweight component. By default, Swing menus are lightweight components. You need to call
    JPopupMenu.setDefaultLightWeightPopupEnabled(false);before creating your menus.

Maybe you are looking for