Position/Draw graphics on graphics

I'd like to let a textarea draw itself then get it's graphics and add it to another graphics object.
This code always draws the textArea at position (0,0) on the incoming graphics object.
    protected void paintComponent(Graphics g)
     g.setColor(m_bgColor);
     g.fillRect(0, 0, getWidth(), getHeight());
     Graphics2D g2d = (Graphics2D) g.create();
     g2d.setColor(Color.black);
     textArea.setText("1 foo bar\n2 foo bar\n3 foo bar");
     textArea.setSize(25,25);
     // I'd like to do something like this (compare to icon.paintIcon below):
     // textArea.paint(g2d, xLocation, yLocation);
     textArea.paint(g2d);
     icon.paintIcon(this, g2d, 100, 50);
     g2d.drawString("< text >", 200, 20);
     g2d.dispose();
    }or something more general like a drawGraphics in Graphics2D:
     g2d.drawGraphics(textArea.getGraphics(), xLocation, yLocation);Any ideas?

Use Graphics2D translate method.
Don't forget to store AffineTransform before translating and restore it after painting.
Regards,
Stas

Similar Messages

  • Drawing with a graphics tablet in Flash

    Hey community!
    I recently got the newest version of Flash and wanted to do some drawing with my graphics tablet, but whenever i try to draw a freehand line, using the pencil or paintbrush tool, then for some reason, it draws a straight line leading to the bottom left side of the screen, and i have no idea why it is doing this.
    When i use the tablet to draw in Photoshop, then it works absolutely fine, but not in Flash
    Any help will be lovely!!
    Thank you

    Hi,
    The issue is resolved in the latest update of Flash Pro.Please update Flash professional to 14.1.0.96 .Follow the instruction below for the same :
    Installation instructions
    Log out and log in to the CC desktop application. Update the application when prompted.
    You should see the list of new updates as soon as the new CC desktop application is launched.
    Install Flash Professional CC and Mobile Device Packaging app. On a high speed connection, it took me around 8 minutes.
    After the application is installed, you can launch the application directly from the desktop app by clicking on it.
    Thanks & Regards,
    Sangeeta

  • Draw inside movieclip/graphic with Actionscript

    Hi.
    How I can draw inside movieclip/graphic element with Actionscript?
    If i have example movieclip-element in my project and want to draw a single dot in its coordinate (10,10), how I can do that?
    ty m8s!

    The easiest way to draw inside a movieClip is the graphics class.
    You could do something like:
    this.graphics.lineStyle(1, 0x000000);
    this.graphics.moveTo(10, 10);
    this.graphics.lineTo(11, 11);
    This isn't perfect when drawing pixels, however - it only has methods for lines and shapes(circles, rectangles etc).
    If its important for you to draw a single pixel and accuracy is more important you may want to consider converting your Movieclip to a BitmapData class, which has methods for setting Pixels. Realistically though, if you didn't know about the graphics class, then that'll probably be what you're after.

  • Is an Intel HD Graphics 5000 graphics card ok to run premier pro?

    I'm looking to buy a new iMac desktop. Due to a small budget, I am looking a purchasing the 21.5 inch, 1.4GZ, dual-core iNtel Core i5 with 8 GB memory and the Intel HD Graphics 5000 graphics card. The reason I am buying the desktop is to upgrade my workflow. I am currently using a MacBook Pro with a Intel Graphics 4000. Would buying this iMac be a big upgrade? I am looking for the best I can possibly get.

    It's all a great big family http://en.wikipedia.org/wiki/Intel_GMA but with different capabilities and speeds.
    In essence your HD Graphics 3000 should be compatible and capable of running Sims-3.
    Nonetheless it might be neccessary for the developer to release a patch/update.
    Stefan

  • Best way to draw thousands of graphic objects on the screen

    Hello everybody, I'm wanting to develop a game where at times thousands of graphic objects are displayed on-screen. What better way to do this in terms of performance and speed?
    I have some options below. Do not know if the best way is included in these options.
    1 - Each graphical object is displayed on a MovieClip or Sprite.
    2 - There is a Bitmap that represents the game screen. All graphical objects that are displayed on screen have your images stored in BitmapData. Then the Bitmap that represents the game screen copies for themselves the BitmapData of graphical objects to be screened, using for this bitmapData.copyPixels (...) or BitmapData.draw  (...). The Bitmap that represents the screen is added to the stage via addChild (...).
    3 - The graphical objects that are displayed on screen will have their images drawn directly on stage or in a MovieClip/Sprite added to this stage by addChild (...). These objects are drawn using the methods of the Graphics class, as beginBitmapFill and beginFill.
    Recalling that the best way probably is not one of these 3 above.
    I really need this information to proceed with the creation of my game.
    Please do not be bothered with my English because I'm using Google translator.
    Thank you in advance any help.

    Thanks for the information kglad. =)
    Yes, my game will have many objects similar in appearance.
    Some other objects will use the same image stored, just in time to render these objects is that some effects (such as changing the colors) will be applied in different ways. But the picture for them all is the same.
    Using the second option, ie, BitmapDatas, which of these two methods would be more efficient? copyPixels or draw?
    Thank you in advance any help. =D

  • Drawing with paintComponent(Graphics g) problem?

    hey, i just recently learnt from a response to previous posts not to put logic type stuff like if statements in the paintComponent method, but how do i get around the issue of drawing something different based on a boolean expression?
    i want to be able to do something like,
    paintComponent(Graphics g) {
          if(drawCircle == true) {
              g.drawCircle(....)
         }else{
              g.drawRectangle(......)
    }Yes, i know i shouldn't do that as i said i've been told NEVER to do this, but how do i work around this issue?
    thanks

    hey, i just recently learnt from a response to previous posts not to put logic type stuff like if statements in the paintComponent method, but how do i get around the issue of drawing something different based on a boolean expression?If you refer to that [my reply in your former thread|http://forums.sun.com/thread.jspa?messageID=10929900#10929900] , note that I warned you against putting business logic (+if (player.hasCollectedAllDiamonds()&&timer.hasNotTimedOut()&&allEnnemies.areDead()) { game.setState(FINISHED);}+) into your paintComponent(...) method, I didn't ask you to ban logic altogether (+if (player.hasCollectedAllDiamonds()) { Graphics.setColor(Color.GREEN); }+)
    EDIT: Oh, how pretentious I was; obviously you merely refer to [this Encephalopathic's post|http://forums.sun.com/thread.jspa?messageID=10929668#10929668], who warns against program logic in paint code; same misunderstanding though, he certainly only meant that the paintXXx's job is not to determine whether the game is over, only to render the game state (whichever it is, it has been determined somewhere else, not in painting code).

  • Visio Drawing Using Data Graphics with data that has a field that contains Multiple Values.

    I am working on creating a drawing for SMTP connectors.  I decided I would use a Data Graphic connecting to a spreadsheet.  In the spreadsheet there are a few fields that are Multi-Value fields.  For instance SmartHosts contains multiple Ip
    address.  I am trying to get this to format things so that the IPs show on the next line down instead of continuing on the same line until it wraps. 
    Does anyone know a way I could do this?
    Jeff C

    Hi Jeff,
    Arrange the IP values in spreadsheet using Alt+Enter (Use this key pair as a separator between two IP values). Now link this spread sheet to Visio. The values should appear in the same manner in data graphics as your expectation.
    Let me know if you meant something else.
    Thanks,
    Dheeraj 

  • Drawing tooltips on Graphics

    Hi,
    How can I draw tooltip at certain location of Graphics object? I thought this simple solution would work...
    public void mouseClicked(MouseEvent e)
    JToolTip tip = new JToolTip();
    tip.setLocation(e.getPoint());
    tip.setTipText("Node clicked");
    Graphics2D g = (Graphics2D) image.getGraphics();
    tip.paint(g);
    }

    HI, Doovla,
    Could you share the code of making following method wrok?
    public void mouseClicked(MouseEvent e)
    JToolTip tip = new JToolTip();
    tip.setLocation(e.getPoint());
    tip.setTipText("Node clicked");
    Graphics2D g = (Graphics2D) image.getGraphics();
    tip.paint(g);
    Thanks in advance.

  • Drawing without paintComponent(Graphics g)

    Hi to all,
    I use paintComponent(Graphics g) to draw particular rectangles on the screen, then i add some event to these rectangles. So far so good.I handle the mouse click from -->
    public void mouseClicked(MouseEvent e){
    // handling goes here
    But an important part of my handling is to also draw something on the screen.
    How can i do that from the mouseClicked method? Can i draw without using paintComponent(...)?
    I mean that, once the paintComponent(...) method finishes, how can i still draw something on the screen?
    Thanks,
    John.

    You can use
    Graphics gg = component.getGraphics();
    gg.draw ....
    but it will be cleared in the paintComponent method
    Look at this sample, the red rectangle will show up when the mouse
    is presses, and gone when the mouse will be released.
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.util.*;
    public class Shapes extends JFrame
         DPanel pan = new DPanel();
    public Shapes()
         addWindowListener(new WindowAdapter()
              public void windowClosing(WindowEvent ev)
                   dispose();
                   System.exit(0);
         setBounds(10,10,400,350); 
         setContentPane(pan);
         setVisible(true);
    public class DPanel extends JPanel implements MouseListener
         Vector shapes = new Vector();
         Shape  cs;
    public DPanel()
         addMouseListener(this);
         shapes.add(new Rectangle(20,20,100,40));
         shapes.add(new Rectangle(40,80,130,60));
         shapes.add(new Line2D.Double(20,150,200,180));
    public void paintComponent(Graphics g)
         super.paintComponent(g);
         Graphics2D g2 = (Graphics2D)g;
         for (int j=0; j < shapes.size(); j++)
              g2.draw((Shape)shapes.get(j));
         g.setColor(Color.red);
         if (cs != null) g2.draw(cs);
    public void mouseClicked(MouseEvent m) {}
    public void mouseEntered(MouseEvent m) {}
    public void mouseExited(MouseEvent m)  {}
    public void mouseReleased(MouseEvent m)
         repaint();
    public void mousePressed(MouseEvent m)
         for (int j=0; j < shapes.size(); j++)
              Shape s = (Shape)shapes.get(j);
              Rectangle r = new Rectangle(m.getX()-1,m.getY()-1,2,2);
              if (s.intersects(r))
                   cs = s;
                   Graphics g = getGraphics();
                   g.setColor(Color.red);
                   g.fillRect(r.x-5,r.y-5,10,10);
    public static void main (String[] args) 
          new Shapes();
    }

  • Adobe Flash Professional cc - I can't draw with my graphic tablet.

    Selection tool is working, bud brush not. Why? How can I fix it?
    Thanks.

    Hallo,
    I have windows 7 professional (64bit), but in my case it's worse.
              CPU - Intel Core 2 Duo 6300 1,86 Ghz (with integtated  graphics card)
              RAM - 4 Gb
    I know... it's really bad PC.
    Ondra

  • Graphics using graphic API are drawn below the loaded content created using Flash authoring tool

    Here is my problem.
    I am developing a Analog Dial component. Here , I am
    extending UIComponent and loading a swf file generated using Flash
    CS3 authoring tool ( the swf basically has the circle and needle)
    and adding the loaded content as child of Dial class.
    Next I use Graphics API to draw the major and minor ticks on
    the dial.
    As mentioned in the curveTo method of flash.display.Graphics
    class documentation (
    http://livedocs.adobe.com/flex/201/langref/index.html),
    if you are using graphics api and also loading content created
    using the flash authoring environment the vector graphics will be
    drawn underneath the loaded content.
    Well , Is there any way to make the graphics appear on top of
    the loaded contents?

    It appears that this may be accomplished more easily if I do something similar to the StrobeMediaPlayback implementation. Looking at the StrobeMediaPlayback source code it looks like Adobe has done something a little different than their ControlBarPlugin, placing the controlbar and root media element inside separate MediaContainers and then adding those containers to the display list. Is this recommended over using the frameworks ParallelElements? If so, is communication between the control bar and root media element still a matter of just updating the target reference via metadata?

  • I created a web page in MS Word and saved it as html; it has lots of graphics; the graphics load perfectly in Internet Explorer but in Firefox there is simply white space where the graphics should appear

    The web page is not live: I just load it on my computer. When I convert the .docx file to .html, the graphics are saved by MS Word in the usual folder as image001.png, up to image032.png.
    I'm sure this is a trivial problem but I can't crack it.
    Many thanks. RS

    Does that "local" page work in Internet Explorer, but not Firefox?
    If so, it might be a \ vs. / problem with the file path for those images.

  • When I send forward or reply to an e-mail with graphics the graphics do not get sent.

    when I receive an e-mail that has photo's or graphics of any type, and forward them to some one the graphics or photo's to not get sent.

    It should not be variable it should work or not work under specific conditions:
    1. If on 3G/Edge - you will need to use the ATT/Carrier SMTP server. This is because many ISPs (the one that you have your email with) do NOT allow access to their outgoing (SMTP server) from outside their network. If you are not going over your home network (wifi) you are outside.
    2. If on WiFi, then the ATT SMTP server will not work - you have to be going over 3G or Edge.
    This is why you can have multiple SMTP servers listed, but it is not a perfect solution. If the iPhone tries the ISP SMTP server first over 3G - you get the error.
    Some ISPs let you "login" to the SMTP server, and then you can send email using it, even when outside (3G/Edge).
    The easiest thing for me is to just use the AT&T smtp server over 3G. I only switch to wifi rarely, and not for email. If I happen to have wifi on and I want to send email, i turn wifi off.
    Ideally some more detailed config options would be nice where you could specify if your ISP SMTP server was usable over 3G/edge at all.

  • T410: From Graphics: Intel GMA HD Integrated Graphics to Graphics: NVIDIA NVS 3100M with 256MB DDR3

    Hi, I have a Thinkpad T410. I bought it with integrated graphics card. Now i want to upgrade to the other one: Graphics: NVIDIA NVS 3100M with 256MB DDR3. Is that possible? thanks a lot

    You'd have to replace the motherboard.
    A better solution would probably be to get an eGPU; it's way way way faster.
    W520: i7-2720QM, Q2000M at 1080/688/1376, 21GB RAM, 500GB + 750GB HDD, FHD screen
    X61T: L7500, 3GB RAM, 500GB HDD, XGA screen, Ultrabase
    Y3P: 5Y70, 8GB RAM, 256GB SSD, QHD+ screen

  • Graphic card, graphic card macbook pro,

    hey i want to know is it possible to instal a graphic card in a macbook pro 13'3 inch because i found one that has a spec which include the AMD Radeon HD 6750M graphics processor with 1GB of GDDR5 memory on 2.2GHz configuration, so i was wondering if that was even possible?

    No. They are not cards: the chips is surface mounted to the logic board. The only way to upgrade is to buy a new laptop.

Maybe you are looking for

  • Bridge CS3 and error message

    On my old Windows XP with CS3, Bridge would often crash.  No pattern I could see. Recently bought a new Windows 7 PC with iCore 7 processor and installed same software.  Had the same problem as above. I also have just bought a new laptop running Wind

  • Process order confirmation date

    Hi all, I am making a Zreport in PP along with the ABAPER for my client. In the report output there is one column named as "Actual finish date" which as the name suggests is the process order finished date for confirmation. For this I am using "GLTRI

  • Burned CDs won't play in CD player

    Since updating to Leopard, the CDs I burn will only play in the computer. My car player doesn't recognize the disk. I'm burning as an Audio CD. What else could I do? Thanks.

  • Link in a new window

    How can I have a link open in a new window? I did not see any such functions in the link inspector.

  • Loading trouble with reader

    In trying to load reader from the online store, it gets about 80% finished and then gives an error saying I need a registration key. I have had Reader on this computer before and it worked fine but one day it stopped coming up automatically on the li