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?

Similar Messages

  • Draw line with float values possible

    Hi,
    Using Canvas drawing is possible to draw line with float values.
    graphics.drawLine(int,int,int,int);
    graphics.drawLine(float,float,float,float);Thanks and regards,
    Rakesh.

    not possible
    graphics.drawLine(float,float,float,float);...there's no such method in MIDP API: [click here for javadoc of Graphics class methods|http://java.sun.com/javame/reference/apis/jsr118/javax/microedition/lcdui/Graphics.html#drawLine(int,%20int,%20int,%20int)]

  • What is the issue? When printing a 30x42 drawing PDF with 5 pages. The first drawing prints properly, but none of th eothers do. IF I print each separately, by selecting "current page" they print fine. Oh this is for Acrobat XI Standard.

    RE Acrobat XI Standard. When printing a 30x42 Drawing PDF with more than 1 page only the first page prints properly the rest are not the proper size or centered. Did I miss a setting? For now I can work around it by printing each page using the "Current Page" setting, but this delays me when there is more than 20 pages etc..

    RE Acrobat XI Standard. When printing a 30x42 Drawing PDF with more than 1 page only the first page prints properly the rest are not the proper size or centered. Did I miss a setting? For now I can work around it by printing each page using the "Current Page" setting, but this delays me when there is more than 20 pages etc..

  • "Cannot draw document with negative rows to credit note"

    Hi Experts,
    A General query :
    I create an AR invoice with two items one with qty 1 and the other with qty (-ve 1)  on posting this invoice the second item / row with negative qty gets closed automatically. Now, I require to post a AR Credit note to this invoice i get the following status error message "cannot draw document with negative rows to AR credit note" when copying to a AR Credit note and it is the same the other way when copying from
    How is it possible to create a  AR credit note to the above scenario. Any sugestions
    V.  2007A SP01 PL05
    Regards,
    Rakesh N

    Hi Rakesh N,
    version 8.8 supports fully the scenario you outline & I would recommend you upgrade to benefit from the new functionalities introduced in that version. Please have a look at the [8.8 landing page|https://service.sap.com/~sapidb/011000358700000199032009].
    Using stand-alone documents & internally reconciling in the lower versions works beautifully on the accounting side yet impacts also the stock side, where corrections in stock value & item cost must be carried out manually.
    All the best,
    Kerstin

  • Can j2me draw line with double values.

    Hi,
    Can any body know how to darw line in j2me with double values.
    I don't want use draw Line with int.
    Shall i use svg or j2me has solution.
    Thanks and regards,
    Rakesh.

    not possible
    graphics.drawLine(float,float,float,float);...there's no such method in MIDP API: [click here for javadoc of Graphics class methods|http://java.sun.com/javame/reference/apis/jsr118/javax/microedition/lcdui/Graphics.html#drawLine(int,%20int,%20int,%20int)]

  • Tutorial: Azure AD Integration with Canvas LMS

    Click reply and tell us what you think:
    Tutorial: Azure AD Integration with Canvas LMS
    Markus Vilcinskas, Knowledge Engineer, Microsoft Corporation

    Thanks for this.  Do you have a similar set of instructions to use the "use an existing single sign-on" option so we could leverage our Azure Identities but with our ADFS system (we're not currently syncing passwords to Azure AD)?

  • Working with canvas. Rectangle won't fill.

    Hey, i'm working with canvas.
    [code]
    GraphicsContext g2d;
    g2d.strokeRect(x, y, w, h); //Rect gets drawn.
    g2d.setStroke(Color.WHITE); //Strokes are white, works as well.
    g2d.setFill(Color.BLUE); //Nothing happens. i expect the rectangle to be filled blue. Am i doing something wrong?
    [/code]
    Thanks y'all.
    edit: lmao, trying to format my text.

    import javafx.application.Application;
    import javafx.scene.Scene;
    import javafx.scene.canvas.Canvas;
    import javafx.scene.canvas.GraphicsContext;
    import javafx.scene.layout.Pane;
    import javafx.scene.paint.Color;
    import javafx.stage.Stage;
    public class CanvasFillRectTest extends Application {
        @Override
        public void start(Stage primaryStage) {
            Canvas canvas = new Canvas(400, 400);
            GraphicsContext gc = canvas.getGraphicsContext2D();
            gc.setFill(Color.BLUE);
            gc.setStroke(Color.WHITE);
            gc.fillRect(50, 50, 300, 200);
            gc.strokeRect(50, 50, 300, 200);
            Pane pane = new Pane();
            pane.getChildren().add(canvas);
            Scene scene = new Scene(pane, 400, 400, Color.CORNFLOWERBLUE);
            primaryStage.setScene(scene);
            primaryStage.show();
        public static void main(String[] args) {
            launch(args);
    edit: lmao, trying to format my text.
    Choose "Use Advanced Editor" at the top... then select your code, press the "Insert" button marked >>, and choose syntax highlighting, Java.

  • Drawing lines with smooth curves

    Hi,
    I'm trying to make a map for an underground system in a PC game and I want something similar to the one Transport for London has:
    http://www.tfl.gov.uk/assets/downloads/standard-tube-map.gif
    I'm a total newbie with Adobe Illustrator, but I'm trying it as I've heard it's what Transport for London uses.
    My question is then, what would be the easiest way of accomplishing multiple lines with different colours and smooth curves, like the lines in my reference picture?
    Thanks in advance,
    Martin

    Martin,
    In addition to what Kurt said, you may draw paths with straight segments and then round the corners afterwards, using Effect>Stylise>Round Corners (you may Object>Expand Appearance to obtain actual roundings).

  • Cannot Draw Freehand with Tablet in PSE8

    I'm sort of a newbie at Photoshop, so I don't know if I need to enable something or if it's just a bug.
    Anyway, I just installed Photoshop Elements 8 onto my laptop that is running Windows Vista Home Premium. I open the Editor and I can draw freely with my mouse, but not with my Bamboo Pen tablet. When I try to draw something with my tablet, all PSE8 does is show one straight line or not show any lines at all. Am I just doing something wrong?
    By the way, I've uninstalled and reinstalled this software 5 times. No use. It didn't change anything.

    First, make sure the mouse is not on the tablet when attempting to use the stylus (pen).
    Check that you have something checked in the brush options panel. See this page:
    http://www.the-graphics-tablet.com/photoshop-elements.html
    Video on using tablet options:
    http://www.youtube.com/watch?v=ghMvJ1VL79E&feature=channel
    You might also check the Wacom site and see if the driver is up to date.
    http://www.wacom.com/downloads/drivers.php
    BTW, I'm pretty sure you should reboot/restart the computer after updating the drivers.
    You might also check your Bamboo Tablet properties. You'll want to do that anyway. Here's a video on doing that:
    http://www.youtube.com/watch?v=0dgcZpKWQIU

  • Is Draw compatible with iPad 3th gen?

    Is Draw compatible with iPad 3th gen? I can install the app and open it,  but not use it. I have reinstalled Draw, installed iOS 8.3, closed all other apps and restarted the iPad with no result.

    It should work just fine.  The requirement is iOS 7.0 minimum.
    Does the app launch?
    Can you log in with your CreativeCloud ID?
    Can you create a screenshot of the last part that works?
    I would suggest: uninstall it, then reinstall it.  Sometimes apps on my iPad don't finish installing completely - reinstalling from the App store solves the problem.

  • How can we use Alert with Canvas

    Hello to all
    How can I use alert with Canvas .
    I want whenever user do mistake then a alert message should come.
    Thanks in advance
    Mukund

    And where is the problem? Sample code can be found all over the place... just look for it.

  • [svn] 4746: User-submitted patch for SDK-16147 - HaloBorder does not take border widths into account when drawing background with rounded corners .

    Revision: 4746
    Author: [email protected]
    Date: 2009-01-29 15:36:59 -0800 (Thu, 29 Jan 2009)
    Log Message:
    User-submitted patch for SDK-16147 - HaloBorder does not take border widths into account when drawing background with rounded corners.
    Bugs: SDK-16147 (bug), SDK-16963 (patch)
    Ticket Links:
    http://bugs.adobe.com/jira/browse/SDK-16147
    http://bugs.adobe.com/jira/browse/SDK-16147
    http://bugs.adobe.com/jira/browse/SDK-16963
    Modified Paths:
    flex/sdk/branches/3.x/frameworks/projects/framework/src/mx/skins/halo/HaloBorder.as

  • Advance level drawing problem with Jframe and JPanel need optimize sol?

    Dear Experts,
    I m trying to create a GUI for puzzle game following some kind of "game GUI template", but i have problems in that,so i tried to implement that in various ways after looking on internet and discussions about drawing gui in swing, but i have problem with both of these, may be i m doing some silly mistake, which is still out of my consideration. please have a look at these two and recommend me one of them, which is running without problems (flickring and when you enlarge window the board draw copies (tiled) everywhere,
    Note: i don't want to inherit jpanel or Jframe
    here is my code : import java.awt.BorderLayout;
    public class GameMain extends JFrame {
         private static final long serialVersionUID = 1L;
         public int mX, mY;
         int localpoints = 0;
         protected static JTextField[][] squares;
         protected JLabel statusLabel = new JLabel("jugno");
         Label lbl_score = new Label("score");
         Label lbl_scorelocal = new Label("local score");
         protected static TTTService remoteTTTBoard;
         // Define constants for the game
         static final int CANVAS_WIDTH = 800; // width and height of the game screen
         static final int CANVAS_HEIGHT = 600;
         static final int UPDATE_RATE = 4; // number of game update per second
         static State state; // current state of the game
         private int mState;
         // Handle for the custom drawing panel
         private GameCanvas canvas;
         // Constructor to initialize the UI components and game objects
         public GameMain() {
              // Initialize the game objects
              gameInit();
              // UI components
              canvas = new GameCanvas();
              canvas.setPreferredSize(new Dimension(CANVAS_WIDTH, CANVAS_HEIGHT));
              this.setContentPane(canvas);
              this.setDefaultCloseOperation(EXIT_ON_CLOSE);
              this.pack();
              this.setTitle("MY GAME");
              this.setVisible(true);
         public void gameInit() {     
         // Shutdown the game, clean up code that runs only once.
         public void gameShutdown() {
         // To start and re-start the game.
         public void gameStart() {
         private void gameLoop() {
         public void keyPressed(KeyEvent e) {
         public void keyTyped(KeyEvent e) {
         public void gameKeyReleased(KeyEvent e) {
              PuzzleBoard bd = getBoard();
              for (int row = 0; row < 4; ++row) {
                   for (int col = 0; col < 4; ++col) {
                        if (e.getSource() == squares[row][col]) {
                             if (bd.isOpen(col, row)) {
                                  lbl_score.setText("Highest Score = "
                                            + Integer.toString(bd.getPoints()));
                                  setStatus1(bd);
                                  pickSquare1(col, row, squares[row][col].getText()
                                            .charAt(0));
         protected void pickSquare1(int col, int row, char c) {
              try {
                   remoteTTTBoard.pick(col, row, c);
              } catch (RemoteException e) {
                   System.out.println("Exception: " + e.getMessage());
                   e.printStackTrace();
                   System.exit(1);
         // method "called" by remote object to update the state of the game
         public void updateBoard(PuzzleBoard new_board) throws RemoteException {
              String s1;
              for (int row = 0; row < 4; ++row) {
                   for (int col = 0; col < 4; ++col) {
                        squares[row][col].setText(new_board.ownerStr(col, row));
              lbl_score.setText("Highest Score = "
                        + Integer.toString(new_board.getPoints()));
              setStatus1(new_board);
         protected void setStatus1(PuzzleBoard bd) {
              boolean locals = bd.getHave_winner();
              System.out.println("local win" + locals);
              if (locals == true) {
                   localpoints++;
                   System.out.println("in condition " + locals);
                   lbl_scorelocal.setText("Your Score = " + localpoints);
              lbl_score
                        .setText("Highest Score = " + Integer.toString(bd.getPoints()));
         protected PuzzleBoard getBoard() {
              PuzzleBoard res = null;
              try {
                   res = remoteTTTBoard.getState();
              } catch (RemoteException e) {
                   System.out.println("Exception: " + e.getMessage());
                   e.printStackTrace();
                   System.exit(1);
              return res;
         /** Custom drawing panel (designed as an inner class). */
         class GameCanvas extends JPanel implements KeyListener {
              /** Custom drawing codes */
              @Override
              public void paintComponent(Graphics g) {
                   // setOpaque(false);
                   super.paintComponent(g);
                   // main box; everything placed in this
                   // JPanel box = new JPanel();
                   setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
                   // add(statusLabel, BorderLayout.NORTH);
                   // set up the x's and o's
                   JPanel xs_and_os = new JPanel();
                   xs_and_os.setLayout(new GridLayout(5, 5, 0, 0));
                   squares = new JTextField[5][5];
                   for (int row = 0; row < 5; ++row) {
                        for (int col = 0; col < 5; ++col) {
                             squares[row][col] = new JTextField(1);
                             squares[row][col].addKeyListener(this);
                             if ((row == 0 && col == 1) || (row == 2 && col == 3)
                             || (row == 1 && col == 4) || (row == 4 && col == 4)
                                       || (row == 4 && col == 0))
                                  JPanel p = new JPanel(new BorderLayout());
                                  JLabel label;
                                  if (row == 0 && col == 1) {
                                       label = new JLabel("1");
                                       label.setHorizontalAlignment(JLabel.LEFT);
                                       label.setVerticalAlignment(JLabel.TOP);
                                  else if (row == 4 && col == 0) {// for two numbers or
                                       // two
                                       // blank box in on row
                                       label = new JLabel("2");
                                       label.setHorizontalAlignment(JLabel.LEFT);
                                       label.setVerticalAlignment(JLabel.TOP);
                                  else if (row == 1 && col == 4) {
                                       label = new JLabel("3");
                                       label.setHorizontalAlignment(JLabel.LEFT);
                                       label.setVerticalAlignment(JLabel.TOP);
                                  else if (row == 4) {
                                       label = new JLabel("4");
                                       label.setHorizontalAlignment(JLabel.LEFT);
                                       label.setVerticalAlignment(JLabel.TOP);
                                  else {
                                       label = new JLabel("5");
                                       label.setHorizontalAlignment(JLabel.LEFT);
                                       label.setVerticalAlignment(JLabel.TOP);
                                  label.setOpaque(true);
                                  label.setBackground(squares[row][col].getBackground());
                                  label.setPreferredSize(new Dimension(label
                                            .getPreferredSize().width, squares[row][col]
                                            .getPreferredSize().height));
                                  p.setBorder(squares[row][col].getBorder());
                                  squares[row][col].setBorder(null);
                                  p.add(label, BorderLayout.WEST);
                                  p.add(squares[row][col], BorderLayout.CENTER);
                                  xs_and_os.add(p);
                             } else if ((row == 2 && col == 1) || (row == 1 && col == 2)
                                       || (row == 3 && col == 3) || (row == 0 && col == 3)) {
                                  xs_and_os.add(squares[row][col]);
                                  // board[ row ][ col ].setEditable(false);
                                  // board[ row ][ col ].setText("");
                                  squares[row][col].setBackground(Color.RED);
                                  squares[row][col].addKeyListener(this);
                             } else {
                                  squares[row][col] = new JTextField(1);
                                  // squares[row][col].addActionListener(this);
                                  squares[row][col].addKeyListener(this);
                                  xs_and_os.add(squares[row][col]);
                   this.add(xs_and_os);
                   this.add(statusLabel);
                   this.add(lbl_score);
                   this.add(lbl_scorelocal);
              public void keyPressed(KeyEvent e) {
              public void keyReleased(KeyEvent e) {
                   gameKeyReleased(e);
              public void keyTyped(KeyEvent e) {
         // main
         public static void main(String[] args) {
              SwingUtilities.invokeLater(new Runnable() {
                   @Override
                   public void run() {
                        new GameMain();
      thanks a lot for your time , consideration and efforts.
    jibby
    Edited by: jibbylala on Sep 20, 2010 6:06 PM

    jibbylala wrote:
    thanks for mentioning as i wasn't able to write complete context here.Yep thanks camickr. I think that Darryl's succinct reply applies here as well.

  • 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.

Maybe you are looking for

  • How can I get  the MDX-statement which is generated in a query?

    Can I somehow get the MDX statement, which is generated when I create a Query via BeX Query Designer? I am using JCo to connect to BW (3.0b) and to execute MDX statements from a standalone JAVA-application. It would be very helpful to have the statem

  • INVALID_PROCESS_ATTACH_ATTEMPT  - Solution

    I've been experiencing a Blue Screen of Death error with iTunes 7 since launch. I've finally isolated what the cause of this problem is. Apparently there is a correlation between anti-virus software and firewall software which sometimes may cause a c

  • Ipfw, iTunes and syslog

    Hi, I've added my own ipfw rules, but now I can't get Apple Remote (from iPhone) to work. It reports that it cannot connect because there are some firewall rules (sic!). I've enabled iTunes'es listening port (3869), allowed anything to 244.0.0.0/4 to

  • Batch JPG to 72 DPI

    I have read through threads on changing dpi through batch process, but I can not find answer I am looking for. I have about 200 images I have to convert to 72dpi 1024x768 JPG's from TIF's. I understand that the resolution of 72dpi is not necessary fo

  • Sytem variable for no of pages

    Hi, Can any one tell me, is any system variable to find the total no of pages in a simple report. ex: sy-pagct ( but it is obsolete).