Displaying a BufferedImage in a GUI

I want to display a BufferedImage in my GUI.
The BufferedImage is a screen snapshot created by the createScreenCapture() method in the Robot class. I know how to save it to file, but how would i display it in a GUI without saving it ??
Would be really grateful for any help.
Thanks
Rob

In the painting method of your GUI, you could cast the Graphics object into a Graphics2D. The Graphics2D has a method
drawImage(BufferedImage img, BufferedImageOp op, int x, int y);

Similar Messages

  • Displaying a BufferedImage

    Hello,
    I'm building a program that needs to display a BufferedImage. I created a sub class of JPanel whom's only purpose is to display a BufferedImage, so instead of using drawImage, could I simply assign the Graphics2D object of my BufferedImage to the one of my component (see code below)?
    paintComponent(Graphics g){
        BufferedImage pic = getPic();
        g = pic.getGraphics();
    }

    Hello,
    I'm building a program that needs to display a
    BufferedImage. I created a sub class of JPanel whom's
    only purpose is to display a BufferedImage, so
    instead of using drawImage, could I simply assign the
    Graphics2D object of my BufferedImage to the one of
    my component (see code below)?
    paintComponent(Graphics g){
    BufferedImage pic = getPic();
    g = pic.getGraphics();
    Hi,
    No that doesn't work. You can't change what g originally references. You only got a copy of that reference in the method.
    What is your actual question?
    /Kaj

  • How to display scope plot in Labview GUI?

    I am trying to figure out how to show TDS8000 scope output plot in LV GUI(?)
    This maybe a two fold question.
    1. I suppose it may be necessary to adjust the scope scale with appropriate level so that the plot will show enough details of information. (e.g., finding Max and Min points)
    2. how to display scope plot in LV GUI?
    It would be a great help if anyone can share an example VI.
    Thanks,

    Hi jjlee,
    It shouldn't be that difficult of a task. Most instrument drivers have
    a simple initialize VI, and then some type of waveform measurement VI.
    You would connect these two VIs and then take the output from the
    waveform measurement (may be waveform acquire or something like that)
    to a graph or chart (depending on if you're outside of inside of a
    loop). That should be all you need to do for the simplest form of this
    application. You would, of course, want to handle errors and close the
    connection to the device when you're done collecting the data.
    Hope this is of some help,
    Regards,
    Matt S.
    LabVIEW Integration Engineer with experience in LabVIEW Real-Time, LabVIEW FPGA, DAQ, Machine Vision, as well as C/C++. CLAD, working on CLD and CLA.

  • Display the workitem in Web GUI Homepage

    Hi Experts,
    How can I display the workitem in Web GUI Homepage?
    I created a workflow and it is sending a workitem but I can' see the workitem sent to my Web GUI homepage.
    Thanks in advance,
    james
    Moderator message: please have a look in the dedicated Workflow forum.
    Edited by: Thomas Zloch on Jan 20, 2011 3:55 PM

    Hi James,
    First of all, i would like to know whether you can see the workitem in SAP Business workplace (GUI) ?
    If yes, then you would find one of my article which would make an interesting reading and would help you in your query.
    [SAP Business Workplace Vs SAP CRM WebUI Worklist|http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/b0c2ff2f-d6ef-2d10-5885-d989e034feac]
    Regards,
    Anand

  • How to display  a calendar on an GUI screen

    Hi,
    I need to dispaly a calendar on GUI screen, for instance if you go to www.hotwire.com, you can see a "Depart Date" field next to this filed there is a small box, click on that you will get calendar. In my screen I had a start date field I need to get the same on my screen too.
    Could anybody had script(Javascript) to display a calendar like that. Please forward to me if anybody had.
    Thanks to All.
    Art

    I use JCalendar for my applications. It's easy to implement and it looks great.
    http://www.toedter.com/en/jcalendar/

  • Error while displaying PCUI page from SAP GUI

    Hi,
    I did a new development in a SAP GUI report program such that when the report program is called in Portal, on clicking a button, PCUI application for service order will appear. This I did by calling the function module CALL_BROWSER and passing the URL
    (for eg:- http://...../irj/servlet/prt/portal/prtroot/com.sap.portal.navigation.portallauncher.default?NavigationTarget=/roles/com.sap.pct.crm.ServiceManager/ServiceCycle/nf/ServiceOrders/BSPOrdersManager&DynamicParameter=CRM_OBJECT_TYPE%3DSERVICEPROCESSCRM%26CRM_BOR_TYPE%3DBUS2000116%26CRM_OBJECT_ID%3DFD3A2213D9F449CE83D7AF4EDCF642BA%26CRM_LOGSYS%3DCRD100%26sap-syscmd%3Dnocookie%26CRM_LOGSYS%3DCRD100%26CRM_BOR_TYPE%3DBUS2000116)
    This is working fine when the connection is HTTP but when the connection is HTTPS, a new window is opening with Portal header details but the PCUI application is not opening.
    Do I have perform any additional steps to get the application opened up in HTTPS connection?
    Thanks & Regards
    G.Raja

    Hi Matthew,
    Thanks for your reply. The CRM version is CRM 4.0 SP6. Unfortunately the notes could not be used in our scenario.
    The URL is created by us and the function module CALL_BROWSER is called to display the PCUI application. The PCUI application is not getting displayed if the connection is secured (HTTPS) connection.
    Thanks & Regards
    G.Raja

  • Displaying special characters in a GUI

    I am fairly new to Java and I'm writing an application that works with manufacturing technical data. I need to include a label for "grams per cubic inch." How do I display the superscript 3 on a label?

    Hello and welcome to the Sun Java forums.
    A local graphical user interface (GUI) application uses the Java Abstract Window Toolkit (AWT) and may use Swing components like JLabels. Applets use these too. Swing components may lay out their text using a subset of HTML, even as local applications.
    A console application (command line interface, CLI) uses System.in and System.out.
    Reply #1 assumes that your application is a local GUI application, not a servlet/JSP/etc.
    You may display a ³ by copy-pasting the character ³ from this sentence into your label's text, or using the escape sequence \u00B3.
    s

  • Displaying a BufferedImage in a JSP

    I want to build a JPG image as a BufferedImage using
    JPEGImageDecoder.decodeAsBufferedImage() and then set this
    BufferedImage object as an attribute of a user's Session (this is all done within a servlet). I then want a JSP to be able to display the image as part of the page, via the session object. I'm doing this because I want to create the images on the server but not write them to disk so that they will expire along with the user's Session and I don't have to do any clean up of the image files. Is there a way to do this ? I have tried something like the below with no success:
    in the servlet:
    HttpSession session = request.getSession(true);
    session.setAttribute("testImage", regionOfInterestImage);
    in the JSP:
    <img src="<%= session.getAttribute("testImage") %>"
    alt="IMAGE NOT FOUND">
    If anyone has an idea as to how I can pull this off then please
    respond ! I can't find much at all on this sort of thing in all the
    references I have available.
    Thanks in advance...
    -James

    I don't know how exactly to do this, but typically you would produce the image in a servlet, setting the mime type appropriately and then have a normal image link <img src="/servlet/url/servletname"> in your jsp page, to display it.

  • Problem displaying TIFF BufferedImage. It's all black.

    Hello,
    I am new to Java2D and I have a problem. I have a BufferedImage, bi1, created from a RenderedOp object (containing a grayscale TIFF image). I now would like to copy a part of bi1 to another BufferedImage, bi2. Creating and displaying bi1 works fine, but when I try to display bi2 it's all black. Since that is the default background color of BufferedImage, I guess this meens that my copying wasn't successful.
    So my question is: How do I set the data in bi2 correctly?
    Thanks in advance.
    My code looks something like this:
    FileSeekableStream stream = null;
    try {
    stream = new FileSeekableStream(args[0]);
    } catch (IOException e) {
    e.printStackTrace();
    System.exit(0);
    ParameterBlock params = new ParameterBlock();
    params.add(stream);
    TIFFDecodeParam decodeParam = new TIFFDecodeParam();
    decodeParam.setDecodePaletteAsShorts(true);
    RenderedOp image = JAI.create("tiff", params);
    int tiff_width = image.getWidth();
    int tiff_height = image.getHeight();
    BufferedImage bi1 = image.getAsBufferedImage();
    BufferedImage bi2 = new BufferedImage(tiff_width, (int)Math.round(tiff_height*0.35), BufferedImage.TYPE_BYTE_GRAY);
         bi2.getRaster().setRect(bi1.getData(new Rectangle(0,(int)Math.round(tiff_height*0.65),tiff_width,(int)Math.round(tiff_height*0.35))));
    ScrollingImagePanel panel = new ScrollingImagePanel(bi2, tiff_width, tiff_height);
    Frame window = new Frame("");
    window.add(panel);
    window.pack();
    window.show();

    The BufferedImage class has method
    public BufferedImage getSubimage(int x, int y, int w, int h);
    Probably you might use it
    bi2=bi1.getSubImage(0,0, newWidth,newHeight);
    hope this helps
    Stas

  • Displays the time in a GUI using NGP

    how can I add a text box to a GUI that displays the current time?
    similar to what is displayed on a windows Start Bar
    I am new to java, creating my first GUI using the NGP version of the swing package

    EWWW :.... Formatted this time.. =)
    Oh, to answer the question:
    import javax.swing.Timer;
    import javax.swing.JLabel;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.util.Calendar;
    import java.text.DateFormat;
    * Time display label with auto update.
    * @author Derisor
    public class TimeLabel extends JLabel implements ActionListener {
      private Timer myTimer;
      private Calendar cal = Calendar.getInstance();
      private DateFormat df = DateFormat.getTimeInstance(DateFormat.LONG);
      public TimeLabel () {
         myTimer = new Timer(1000. this);
         myTimer.start();
      public voidActionPerformed(ActionEvent e) {
         if (e.getSource() == myTimer)
          this.setText(df.format(cal.getTime()));
    }

  • Displaying real-time data using gui meter from multiple channels.

    I am using DAQ USB-6009 for my assignment. Part of my task is to display real-data from multiple channels in the form of gui meters.  eg. irradiance and voltage...
    I used a split signal to separate the signals from different channels coming out of the data output terminal of the DAQ assistant. The problem is that I do not know which vi to connect in between the split signal and the gui meter. I am looking for one vi that is capable of handling signals (measurement)  and outputting the data to the gui meters simultaneously and individually based on the channel they are coming from.

    Thnx for your tip, Dennis.
    However, I have another problem that just occurred to me when my VI manages to execute as I wanted.
    I noticed that the needle on my gui meter will only "appears" to be responding to every changes to its input when I have set it to run continuously and the only way to stop it is via abortion which might leave the resources (eg. external hardware) in unknown state. Is there any safer and workable ways to organise the VIs using while loop?
    I have placed my DAQ assistant, write to measurement file (vi), add function, split signal and gui meters all in 1 single while loop.
        DAQ-------> write to measurement file
                 |
                 |                                                 ​                   |--------------------------------> add function----> gui meters
                 ---------------------------------------------> split signals ---|--------------------------------> add function----> gui meters
                                                      ​                                |--------------------------------> add function----> gui meters
    If I do the following steps,
    1. press run continuously to start the VI
    2. click the same button to disable continuous run when the VI has completed its task.
    3. click the stop button in the front panel to stop the while loop
    Does doing these steps ensure that I will not leave resources in unknown state? Is it a safer way to stop a VI which is running continuously?
    Pardon me for I am new to LabView. Even though, I have read the user's
    manual and tried out all the execises, there are some concepts that I
    need clarification on and mistakes that I need to discover through more hands-on.

  • Featured Problem: Displaying unknown data in a GUI

    The featured problems are problems submitted for your enjoyment and education. In the world of java, there are many many things to learn. It is, naturally, impossible to know them all. If you are new or old to java, this will give your brain a workout. The goal isto come up with the BEST solution to the problem.
    Problem:
    You need to show some data in a GUI List control. The difficulty is that the objects of data and their type will not be known to you until runtime. What is the best way to accomplish this?

    You have a misunderstanding. You have NO CONTROL at all over the objects you are displaying. Reflection is the key, yes, but not on the object side. Instead on the cell renderer side.
    The solution calls for the invention of a ListCellRenderer that allows the user of the render to render on whatever he wants, field or method result. The user tells you what he wants to render on and you render on it. Furhtermore if he can change the target and have your rendere adapt on the fly, that would be better.

  • Simple question about displaying a BufferedImage in Swing

    I have a program that is working on medium-sized BufferedImages (600x600 or so). I really just need to display them. Right now, I'm doing:
    panel.add(new JLabel(new ImageIcon(bufferedImage)));
    It works, of course, but is this the right way to do it? Or is there some better way to express that?
    Thanks

    I guess I associate "icons" with actions, or links to things, or some kind of UI component, rather than just a way to display an image. But it's fine, I'll use it.
    Thanks

  • Whats the easiest way to display a message in a GUI (pop up box)

    What I want is to display messages (like, OK or ERROR) in the GUI in a pop up box (windows), is there any special java component or do I have to create a dialogbox?
    I mean, something similar like the FileChooser.

    Take a look at JOptionPane. Here is a link to the Swing tutorial on JOptionPane:
    http://java.sun.com/docs/books/tutorial/uiswing/components/dialog.html#features

  • Display a BufferedImage to screen

    Hi,
    There maybe an answer somewhere already, but I didn't see it.
    As I understand it, rendering can happen on different outputs. They
    can be screen, printer, or offscreen buffer. Each of these three has
    their own way of creating a Graphics object. If I have a BufferedImage
    (which seems a better way of storing an image if image manipulation
    is required a lot), how do I display it onto screen? Thanks.
    Xiang

    blah blah paint(Graphics g) {
        g.drawImage(bufferedImage, 0, 0, this);

Maybe you are looking for

  • How to get the form printed through the transaction ME42

    hi, How to get the form printed through the transaction ME42. For example : In t.code vf03 . In the main menu there is an option billing document , when we click on that we get a drop down menu which shows issue output to. If a print program call has

  • Problem with Black berry ID with torch 9810

    I can not log in with my Blackberry ID from my Torch 9810 although the log in works via Internet. What could be the cause for this problem? Stefan

  • Explorer 9

    I have a Touch Smart 300-1020 with Vista. Should I install Explorer 9?

  • How can we find the list of user exits for a transaction

    hi all iam new in user exits please send the basic details how can we find the list of user exit for a perticular transaction and how can we determine that a particulr user exit is used for a field regards jagadish

  • Setting a default against a Dynamic parameter

    Post Author: AQMahomed CA Forum: General Hi I have created a crystal report, when running the report I want the parameter to default to a certain value instead of me having to choose the value Does anyone know if this is possible Many Thanx in advanc