Creating an image of a component

hi
i'm working on a small applet. i need to create an image of any component (like JLabel) before it is shown on the screen.
can i do it?

Try:
Image getComponentImage(Component comp) {
    BufferedImage imgBuf = new BufferedImage(comp.getWidth(),comp.getHeight(), BufferedImage.TYPE_INT_ARGB_PRE);
    Graphics gr = imgBuf.createGraphics();
    comp.paint(gr);
    return imgBuf;
}Graeme

Similar Messages

  • Create an Image from a Component

    Can anybody tell me how to create an Image from a Component?
    I intend to create an Image from a JTable now but I want to have a more generic solution of course to be able to create an Image from any Java / Swing component (Applet, JList, JButton, ...).
    Thank you,
    Dirk

    2 ways:
    1) java.awt.Toolkit.createScreenCapture(Rectangle bounds)
    2) This:
         public static BufferedImage grabByPaint(Component comp) {
              boolean visible = comp.isVisible();
              // if not visible, need to make visible to make sure sizes are correct. 
              if(!visible) {
                   comp.setVisible(true);
              Dimension size = comp.getSize();
              BufferedImage bi = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_ARGB);
              Graphics2D g2d = bi.createGraphics();
              comp.paintAll(g2d);
              if(!visible) {
                   comp.setVisible(false);
              g2d.dispose();
              return bi;
         }

  • How to create a image as a component

    Hi
    Thanks for all the help.
    Hope you can help me on this one also.
    I have a few dynamic pages .In each of this page i have a logo(a .jpg file) to be displayed at the top of each page. how do i make an image as a component in the portal & use it in my dynamic pages.
    Kindly reply
    Regards
    Sushant

    Hi,
    You can create an image as a shared component. But you cannot use this image directly on the dynamic page. The image should be used in a template and this template can be used in the dynamic page or any other component. But the problem with dynamic pages is that it does not support templates in release 1 and 2. It would be available only in the next release. The best way would be is to pick up the image from the mid tier.
    Thanks,
    Sharmila

  • Create an image from Component

    I have created an ImageLoader that stores images loaded from the filesystem. I do however need a default image that is not reliant on loading an image from the filesystem, in case any images on the filesystem are not found.
    I have tried to use Components createImage() method, until I read that this can only be used if the Component is visible on screen, which my Component never will be.
    What I really want is a grey rectangle as an ImageIcon by what means I get this I'm not bothered,
    hopefully someone can help

    Use the java.awt.image.BufferedImage class. To create a BufferedImage object, no component need to be visible. Here is some sample code:       BufferedImage image = new BufferedImage(wid, ht, BufferedImage.TYPE_INT_RGB);
           Graphics2D gc = image.createGraphics();
           gc.drawRect(x,y, width, height);Note that BufferedImage is a subclass of Image. So, you can create ImageIcon from a BufferedImage object.
    If you don't want to use BufferedImage, an option would be to create the image from an array of bytes.

  • How do i create an Image in my own class

    Hi!
    I have a class
    public class gBuffer {
    which is used for double and tripple and n-th
    buffer of graphics.
    I need to create an image in the constructor, but
    the only way i could do it is something like:
    Applet a = new Applet();
    Image i=a.createImage(100,100);
    I just could not find any other class where createImage()
    is not abstract.
    How do i do it right?

    You need a real live Component object that will enable
    you to do something like this:
    Component c = get_a_Component_from_somewhere();
    Image writable = c.createImage(100,100);
    Graphics g = writable.getGraphics();
    g.drawxyz(...);
    g.dispose();If you're programming from within an application or servlet,
    with no real GUI components available,
    then you might have a problem. You might create a
    Frame object without ever making it visible.
    -Ken

  • Jdeveloper visual editor do not show images and other component shapes

    I used jdeveloper(10.1.3.3.0) to create an ADF BC application, I create a jsf jsp file and drag and drop components from ADF Faces Core to this file visual editor, but jdeveloper visual editor do not show images and other component shapes.
    Could you tell me how I can fix this problem?
    Thanks,
    Mike

    Actually, I need to make a dummy change to the jsp file and then it will display boxes representing the objects in the visual editor whereas I get an exception in the log:
    javax.servlet.jsp.JspException: Cannot find FacesContext
    This does not talk much to me !
    Thanks

  • Creating a 'high-def' AV Component

    I'm working on a virtual classroom videochat application for
    Communication Server MX. I'm about 4 days into my experience with
    Flash Comm and I'm not very far along.
    The application calls for four small live video spots for the
    professors who are presenting and on larger video spot for the
    classroom camera. I've tried doing this using Flash MX' AVPresence
    component linked to the simple connect component. This setup works
    but gives end-users horrible video quality.
    I've read around and found that the problem is that I am
    essentialy stretching the video by specifying a larger size than
    the default at that is the source of the distortion and pixelation.
    I also found many people who suggested that the solution was to
    build a custom video component that allows enlarging the feed.
    So far I can't find any sort of guide that suggests I can do
    this or explains how. I've got pages of documentation but I don't
    know enough about the stuff to sort out where to start piecing
    together this component.
    Can anyone give me or direct me to some good resources or
    tutorials for creating a higher resolution video component?

    Along with making the video object larger, you also have to
    tell the camera what resolution to capture at (I think the default
    is 160x120).
    Look in the docs for the camera class, specifically the
    setMode() method. Once you change the camera image dimensions to
    match the size of your video object, the picture will clear
    up.

  • Error creating an image of Drive C:, rc =2

    Hello, as mentioned in the subject line above, I get the following error when trying to capture an image of my reference computer:
    Error creating an image of Drive C:, rc =2
    ZTI Error - Non Zero return code by ZTIBackup, rc=2
    ZTI ERROR - Non-zero return code by LiteTouch, rc = -2147467259
    I've looked at other threads and tried suggestions such as adding the "Set Image Folder" / "Set Image Name" into the Task Sequence, but it solved nothing.
    I am running Windows 7 Professional x64 and capturing from a server running MDT 2010.
    Would there be anything else that would cause this?

    I found out there was actually a second log! The one I posted previously was an old one...very strange. Here is the CURRENT ZTIBackup.log:
    <![LOG[Property LogPath is now = C:\MININT\SMSOSD\OSDLOGS]LOG]!><time="16:09:54.000+000" date="06-14-2012" component="ZTIBackup" context="" type="1" thread="" file="ZTIBackup">
    <![LOG[Microsoft Deployment Toolkit version: 5.1.1642.01]LOG]!><time="16:09:54.000+000" date="06-14-2012" component="ZTIBackup" context="" type="1" thread="" file="ZTIBackup">
    <![LOG[Property Debug is now = FALSE]LOG]!><time="16:09:54.000+000" date="06-14-2012" component="ZTIBackup" context="" type="1" thread="" file="ZTIBackup">
    <![LOG[Property DestinationDisk is now = 0]LOG]!><time="16:09:54.000+000" date="06-14-2012" component="ZTIBackup" context="" type="1" thread="" file="ZTIBackup">
    <![LOG[Property DestinationPartition is now = 1]LOG]!><time="16:09:54.000+000" date="06-14-2012" component="ZTIBackup" context="" type="1" thread="" file="ZTIBackup">
    <![LOG[Property DestinationLogicalDrive is now = C:]LOG]!><time="16:09:54.000+000" date="06-14-2012" component="ZTIBackup" context="" type="1" thread="" file="ZTIBackup">
    <![LOG[Drive C: 29305520]LOG]!><time="16:09:54.000+000" date="06-14-2012" component="ZTIBackup" context="" type="1" thread="" file="ZTIBackup">
    <![LOG[Local store path = C:\MININT\StateStore]LOG]!><time="16:09:54.000+000" date="06-14-2012" component="ZTIBackup" context="" type="1" thread="" file="ZTIBackup">
    <![LOG[Total used space: 29305520]LOG]!><time="16:09:54.000+000" date="06-14-2012" component="ZTIBackup" context="" type="1" thread="" file="ZTIBackup">
    <![LOG[Available space at C:\MININT\StateStore: 11652164]LOG]!><time="16:09:54.000+000" date="06-14-2012" component="ZTIBackup" context="" type="1" thread="" file="ZTIBackup">
    <![LOG[Computer backup will use network path (ComputerBackupLocation=AUTO)]LOG]!><time="16:09:54.000+000" date="06-14-2012" component="ZTIBackup" context="" type="1" thread="" file="ZTIBackup">
    <![LOG[Property OSDComputerName is now = ]LOG]!><time="16:09:54.000+000" date="06-14-2012" component="ZTIBackup" context="" type="1" thread="" file="ZTIBackup">
    <![LOG[WARNING - Unable to validation connection because a blank UNC was specified.]LOG]!><time="16:09:54.000+000" date="06-14-2012" component="ZTIBackup" context="" type="2" thread="" file="ZTIBackup">
    <![LOG[Beginning backup of drive C:]LOG]!><time="16:09:54.000+000" date="06-14-2012" component="ZTIBackup" context="" type="1" thread="" file="ZTIBackup">
    <![LOG[About to run command: cmd /c ""C:\WINDOWS\SYSTEM32\imagex.exe" /capture /compress maximum C: "\.wim" "201206141609CDrive" >> C:\MININT\SMSOSD\OSDLOGS\ZTIBackup_imagex.log 2>&1"]LOG]!><time="16:09:54.000+000" date="06-14-2012" component="ZTIBackup"
    context="" type="1" thread="" file="ZTIBackup">
    <![LOG[Return code from command = 2]LOG]!><time="16:09:56.000+000" date="06-14-2012" component="ZTIBackup" context="" type="1" thread="" file="ZTIBackup">
    <![LOG[Error creating an image of drive C:, rc = 2]LOG]!><time="16:09:56.000+000" date="06-14-2012" component="ZTIBackup" context="" type="3" thread="" file="ZTIBackup">
    <![LOG[ZTIBackup COMPLETED.  Return Value = 2]LOG]!><time="16:09:56.000+000" date="06-14-2012" component="ZTIBackup" context="" type="1" thread="" file="ZTIBackup">
    <![LOG[Property BackupScriptComplete is now = YES]LOG]!><time="16:09:56.000+000" date="06-14-2012" component="ZTIBackup" context="" type="1" thread="" file="ZTIBackup">
    <![LOG[ZTI ERROR - Non-zero return code by ZTIBackup, rc = 2]LOG]!><time="16:09:56.000+000" date="06-14-2012" component="ZTIBackup" context="" type="3" thread="" file="ZTIBackup">

  • Which is the best app to create cartoon images on that i can move around to other apps and animate to create cartoons

    which is the best app to create cartoon images on that I can move around to other apps and animate.  I want to create the image only, no background or anything

    Hi Susan,
    Kindly check out Flash pro CC
    For more details: Explore Adobe desktop apps | Adobe Creative Cloud
    Thanks,
    Atul Saini

  • How do I Create interactive images to be used in another website?

    Our office is contracted with a simple website company, so from the begining the framework is there. I want to add an interactive map that has each county hyperlinked to information about that area. I was told that Dreamweaver is the program I would need in order to create it.
    So, I have the program now but every tutorial I read is about making your own website in dreamweaver and I can't find anything about how to create the image to upload into a different website.
    Anyone know how to do this????
    Thank you!

    This helps, thanks. I have the content on the web page (where the hyperlinks will attach to), I have the image of the map, and I am making the shapes for the hotspots, just not how to get it all to link up.
    Also, when I saved a trial (just to make sure it would all work) it doesn't successfully upload as an image onto the website, just a little box with a red X. Any more thoughts anyone? 

  • Class casting, creating an image and decompiling...

    Hi, I've got a couple of questions:
    1)
    How can I fully decompile classes, so with the implementation of the methods? Is it always possible to fully decompile a class file? When is it and when not?
    2)
    I aks this questions before, but I still haven't got it working, so sorry, but I ask it again :) :
    I want to create my own class, for example cMyClass which extends the java.awt.Image class, which has abstract methods. How do these methods(for example getGraphics etc) have to be implemented?
    3)
    I can't cast a Image to cMyClass... why not?
    Someone told me he did the following:
    Canvas c = new Canvas()
    cMyClass oImage = (cMyClass) c.createImage (100, 100);
    and that this worked... I tried to do this too, and it seemed to work, but it actually didn't!!
    I found out that c.createImage returns a null reference!!! That's why Java was able to cast it to my own cMyClass (not a problem to cast a null to something else), but when I created a Image (by doing a lot of unnessacary difficult stuff), and then tried to cast this Image to cMyClass it throw a ClassCastException or something like that...
    How can I cast the java.awt.Image class to my class anyway?
    3)
    Why can't you create a image like i've done above or even like below:
    Canvas c = new Canvas()
    Image oImage = c.createImage (100, 100);
    Why does this return a null reference?
    Isn't there a better way to create an image?
    4)
    The getWidth and getHeight need a I thought observer...? Why is this? I just want the width and height and don't have an observer or something like that. Is there a way around this?
    I tried getWidth(null) but this returns -1
    Please help! :)

    Hi, I've got a couple of questions:
    1)
    How can I fully decompile classes, so with the
    implementation of the methods? Is it always possible
    to fully decompile a class file? When is it and when
    not?You can always get a dump of the bytecode with 'javap -c'. If you don't want to figure things out yourself, try searching google for a class file decompiler, possibly a de-obfuscator.
    De-compilation is completely possible if the original author wanted that, by including debugging information. Depending on the degree of such information and the amount of code obfuscation, the decompiled code may lack variable names, line numbers, field and method names, class names, and even code structure. Names and line numbers are usually not re-creatable automatically, since the information is simply lost, but you can replace them with your own strings when analyzing an unknown class file (using the correct tools). Re-creating the original code structure may work in some cases, but to me the general case looks rather close to the halt problem (i.e. not solvable).
    Use a de-obfuscator, hope you've got good luck, and analyze the bytecode manually if that doesn't work.
    2)
    I aks this questions before, but I still haven't got
    it working, so sorry, but I ask it again :) :
    I want to create my own class, for example cMyClass
    which extends the java.awt.Image class, which has
    abstract methods. How do these methods(for example
    getGraphics etc) have to be implemented?I don't really understand the problem. 'abstract' means on the language level that your subclass must provide an implementation, i.e. a method body. What that method is expected to do is explained in the javadocs for Image. But in fact you're free to do anything. You could play a sound in the getWidth() method (replace with any method name if you want). Just consider the fact that a lot of code calls getWidth in the hope of getting the width of the image, not playing a sound. So much about the language level.
    On a higher level, a subclass of Image should implement a certain way to describe an image. AFAIK this means that your code must know the size of the image and know how to produce the pixels of the image. I can't tell you in general how you must do this, because it depends on your special case. This boils down to the question, why do you want to write a subclass of 'Image'? What new way of describing and image have you come up with?
    3)
    I can't cast a Image to cMyClass... why not?Simple, and that's certainly not an ALT. Because that specific Image is not a cMyClass. It's probably a BufferedImage or similar that was produced by AWT.
    Please read the specs carefully what casting is about.
    Someone told me he did the following:
    Canvas c = new Canvas()
    cMyClass oImage = (cMyClass) c.createImage (100,
    100);
    and that this worked... I tried to do this too, and it
    seemed to work, but it actually didn't!!
    I found out that c.createImage returns a null
    reference!!! That's why Java was able to cast it to my
    own cMyClass (not a problem to cast a null to
    something else), but when I created a Image (by doing
    a lot of unnessacary difficult stuff), and then tried
    to cast this Image to cMyClass it throw a
    ClassCastException or something like that...
    How can I cast the java.awt.Image class to my class
    anyway?You can't, and if you understood casting then you'd understand that it wouldn't make sense.
    3, 4(don't know)
    Maybe stupid question, but for example the BufferedImage, is this
    completly written in Java?
    How is the link made between the OS+hardware and the Java code? I
    mean, displaying images etc. is very platform dependend not?Look for JNI (Java Native Interface). It's a way to link native (e.g. C) code with Java code.

  • Unable to create Disc Image from DVD

    I get the following error when trying to make a copy of a family wedding DVD. I'm using Disc Utility and creating the image as a DVD/CD master (.cdr) file. It gets to about 3/4 of the way and then gives the following error.
    The internal drive is a PIONEER DVD-RW DVR-K05
    Sep 10 22:13:24: Disk Utility started.
    Creating Image “Wedding of xxx & xxx.cdr”
    Reading VOLUME_IDENTIFIER (Apple_UDF : 0)...
    Unable to create “Wedding of Sarah & Federico.cdr” - Input/output error.
    I've tried twice now and the same error. Looks like I might have to use Toast/Popcorn etc?
    Thanks,
    Darren
    iMac G5 2.1GHz 1Gb RAM 260Gb HDD   Mac OS X (10.4.7)  

    I do not know what that error means. However, if you open up the Disk Utility & go into it's Help Menu & in the search field type duplicating a CD or DVD. There you will find detailed instructions on how to create a disc image from a DVD.
    Good possibility your answer may be found there and/or there may have been something you missed in creating a disc image.
    Good luck.

  • How can I create an image gallery with "next" buttons?

    So I am almost done with my portfolio site (YES!)..now I just need the actual content (the images). My site is written in AS3.
    I've watched many tutorials on how to create an image gallery (auto scrolling ones, scrolling ones that require mouse hover, etc etc), but those aren't what I am looking for.
    I want a gallery that looks exactly like this one here:
    http://jalbum.net/res/help/integrating-tutorial.html
    I have a lot of work to display in my porfolio so there must be arrows at the end of the thumbnails so I can add more stuff. So I am just stumped on how to make the image gallery work with the ability to scroll for more photos with the click of the arrows.
    Any ideas? Thank you.

    Watching tutorials and learning from them are two different things.  If you have learned from them you should be able to use what you have learned to devise a gallery such as the one you link to.  If you have learned from them and cannot use what you learned, then you probably need to find/learn more.
    If you study the design you linked you should be able to reason out what elements you need to devise... it is not overly complicated. 
    For the large picture you could have a Loader into which you load whatever image is selected from the thumnails. To get a brief transition you could just set the alpha of the Loader to 0 when an image change is occuring and gradually fade it in after the image has loaded.
    The greatest challenge you are likely to face is in getting the thumbnails to advance back and forth depending on which is selected.  All of the thumbs would be placed in a container (movieclip or sprite) and that would be masked so that only a portion of them is visible. 
    All thumbs that are not selected have their alpha property set to some value less than 1.  Selecting one calls for the file it associates with to be loaded into the Loader.  If the choice happens to lie off screen, then you need to move the movieclip that contains all of the thumbs some set value in the right (+x) or left (-x) direction.
    If you want the thumbnails to wrap infinitely then when one leave the thumbnails area for movement in a direction, you need to take that thumb and relocate it to the other end of the thumbs in the container.

  • Problem in creating 1 image using differnt images

    Dear Fellows I want to create an image by using different images in byte array format. Images may be transparent or normal images. I want final result in byte array. I am using the following technique which is working fine but the problem with this technique is that it takes too much time to create an image. This is because I am using MediaTraker. If I delete the code of MediaTracker then program have undeterministic behavior i.e, sometimes it create the final image properly and sometimes nothing is displayed in final image.
    I need some help from you. If anyone of you know the technique to draw image using different images without using mediaTracker kindly let me know.
    Early replies will be appreciated
    // here is the sample code which i m using for creating image
    byte[] backgroundImage= // read 800 X 600 image from disk and convert it in to byte array
    byte[] image1 = // read 200 X 200 image from disk and convert it in to byte array
    byte[] transparentImage // read 300 X 300 transparent image from disk and convert it in to byte array
    Image img=null;
    Frame frame =new Frame();
    frame.addNotify();
    //creating BufferedImage object to store Final image
    BufferedImage requiredImage= new BufferedImage(800,600,BufferedImage.SCALE_SMOOTH);
    //get Graphics of BufferedImage created above
    Graphics2D g=(Graphics2D) requiredImage.getGraphics();
    ///// begin draw back ground image
    img=Toolkit.getDefaultToolkit().createImage(backgroundImage);
    try
    MediaTracker mt = new MediaTracker(frame);
    mt.addImage(img, 0); // adds image with ID 0
    mt.waitForID(0);
    }catch(Exception myex)
    myex.printStackTrace();
    //draw background starting from x=0, y=0 with 800 X 600 dimentions
    g.drawImage(img,0,0,800,600,null);
    ////////// end draw background image
    ////////// begin draw image1
    img=Toolkit.getDefaultToolkit().createImage(image1);
    try
    MediaTracker mt = new MediaTracker(frame);
    mt.addImage(img, 0); // adds image with ID 0
    mt.waitForID(0);
    }catch(Exception myex)
    myex.printStackTrace();
    //draw image1 starting from x=10, y=10 with 200 X 200 dimentions
    g.drawImage(img,10,10,200,200,null);
    //////////// end draw image1
    //////begin transparentImage
    img=Toolkit.getDefaultToolkit().createImage(backData);
    try
    MediaTracker mt = new MediaTracker(frame);
    mt.addImage(img, 0); // adds image with ID 0
    mt.waitForID(0);
    }catch(Exception myex)
    myex.printStackTrace();
    //draw transparentImage starting from x=400, y=0 with 300 X 300 dimentions
    g.drawImage(img,400,0,300,300,null);
    ///end draw transparent image
    byte []finalResult = //convert requiredImage into byte array;
    you can mail me the solution on my email address [email protected]
    thanks with best regards
    and waiting for someone to reply
    kamran zameer

    is there anyone on this forum to help me??????
    regards,
    kamran zameer

  • Is there a way to create an image of a CC installer that way I can install without internet?

    I work for a college that has a department of over 100 mac computers currently runing 10.6 and above. I am the IT here and am in charge of installing all programs the students use, so ease of installation helps. I know I can install using an internet connection and it seems pretty simple, my issue is that if for some reason I dont have internet connection in the department I wouldnt be able to install the programs. What I want to know is if I can somehow create an image for the CC softwares, such as Photoshop CC, that way I can create more images of that installer, put them onto external hardrives and install that way without using internet. hope thats enough information, thanks for the help.

    Direct Download Links for Adobe Software
    For proper deployment, sign up with the dev center/ enterprise deployment.
    Mylenium

Maybe you are looking for

  • Expert day feedback

    Nice idea.  Looks like some were helped.  My 2 questions received no responses and have not been moved to the other forums (at least as far as Search sees).  It would be nice to provide at least a courtesy response to each question.  Even if it is ju

  • Insert statement

    Hi... I want to make an insert statement with a cursor, and if in the destination table exists allready a record like in start table, I would like to skip to insert that record.....and inserting the other records from the start table...... Can anyone

  • How to print to a specific printer tray

    Post Author: hoochpit CA Forum: Administration I have a customer that wants the same report to print to different printer trays depending on parameters sent it.  We have no problem recognizing which tray it should go to, but cannot get it to print to

  • IPod got OS6 why won't my iPad, says I have the latest version?

    IPod successfully update. Itunes says my 5.1.1 version is the latest, that there is no update for my iPad (original pad). Help anyone...

  • ST22 Dumps in ECC pushed to Slution Manager

    Hi, We have a ECC6.0 and Solution Manager in our system. I wanted to configure that if a ST22 Dump occurs in ECC 6.0, the ST22 dump should be pused to the Solution Manager and i should be able to view it through the Solution Manager. Please let me kn