Draw images in different Panels

Hi,
I have a JFrame with three JPanels.
How can I draw three different Buffered images to those three JPanels?
Code is appreciated.

devboris wrote:
Hi,
I have a JFrame with three JPanels.
How can I draw three different Buffered images to those three JPanels?Do you know how to draw one BufferedImage in one JPanel? If not, start there.
Code is appreciated.An [SSCCE |http://sscce.org] is appreciated.

Similar Messages

  • Adding different images to different panels

    If I am having a class which is extending Applet not JApplet and in that I am having CardLayout with 4 different panels. If I want to add 4 different images 2 these Panels what is the solution? Can anyone please help?

    sorry
    myPanel p1, p2, p3, p4;
    class myPanel extends Panel
    Image image;
    public myPanel(Image img)
    image = img;
    public void paint (Graphics g)
    if (image == null)
    return;
    g.drawImage(image, 0, 0, this);
    }

  • How to draw image in different dpi?

    I wonder is there any approach can be used to draw a image in different dpi, such as 144dpi, in a JPanel?
    'cause my image processed from other tools is not good, if I can draw image in a high dpi, then the image will looks much better, though the image becomes smaller.
    Note: no SCALE!

    I have a image which is 152dpi, then, how does the Widows draws this image? It looks much better than scale the 72dpi image to the same size.
    Really puzzled-_-                                                                                                                                                                                                                                                                                                                               

  • Drawing Images in awt Panel object

    HI,
    I need to display an image in a Label.
    My project is using awt and not swing. Can anyone help he how to use an setIcon() equivalent in an awt label.
    I have tried to work around a bit and remove the label from the parent container and diaplay an image. but that doesn't seem to be working. Any help in this regard would be greatly appreciated.
    if( form.equalsIgnoreCase("G")){
    Container c = label.getParent();
    label.setVisible( false );
    Graphics g = c.getGraphics();
    Image image = Toolkit.getDefaultToolkit().getImage("abc.gif");
    g.drawImage( image, 10, 10, c );
    g.dispose();
    Thanks

    Hi Subham! Here's an excerpt from the docs for java.awt.Label.
    "A Label object is a component for placing text in a container. A label displays a single line of read-only text. The text can be changed by the application, but a user cannot edit it directly."
    Ergo, you cannot use an image in lieu of text for a Label object. What you can do, though, is to write your own label class, subclassing from java.awt.Component, exactly as the java.awt.Label does and add the capability of using an image rather than just text.
    Hope this helps!
    Cheers!

  • Drawing Graphics in AWT panel

    I was wondering if anybody knows how I would go about drawing onto a Panel as a result of an actionPerformed() call. I got the original code for displaying an image onto the Panel from aresICO on this forum and now I need to be able to click a button on the GUI and have something drawn onto that Panel.
    import java.applet.*;
    import java.awt.*;
    import java.awt.image.ImageObserver;
    public class iPane extends Panel {
         Image im;
         boolean loaded = false;
         public iPane () {
              Toolkit tk = Toolkit.getDefaultToolkit ();
              im = tk.getImage ("Map of Dublin.jpg");
              prepareImage (im, -1, -1, this);
         public void paint (Graphics g) {
              if (loaded)
              g.drawImage (im, 20, 20, this);
         public void update (Graphics g) {
              paint (g);
              // if proper values loaded then:
              //drawRoute (g);
         public void drawRoute (Graphics g) {
              g.setColor(Color.red);
              g.drawLine(273,51,334,61);
              // method takes in values from a file etc.
         public synchronized boolean imageUpdate (Image image, int infoFlags,int x, int y, int width, int height) {
              if ((infoFlags & ImageObserver.ALLBITS) != 0) {
                   loaded = true;
                   repaint();
                   return false;
              else {
                   return true;
         public Dimension getPreferredSize() {
              return new Dimension(im.getWidth(this),im.getHeight(this));
         public Dimension getMinimumSize() {
              return getPreferredSize();
    }; // end iPane class
    This is a the relevant part of the class which uses an iPane object:
    iPane mapPanel;
    public void actionPerformed(ActionEvent e)
         String buttonLabel = e.getActionCommand();
         if (e.getSource() instanceof Button)
              if (buttonLabel.equals("Get Directions"))     
    // What goes in here to draw a line for example?
    // How do I call a method from iPane to draw something?
    Thanks.

    Davey,
    I don't think your approach is correct. The golden rule of Java graphics is that ALL of painting on a component should be done within the componen'ts paint method(). If you write to iPane from outside the class, then if your iPanel needs to be repainted (because, for example, it got obscured by another window and then unobscured) then the route would not be shown.
    You have to think OOD on this.
    The route and the image are properties of the of iPanel. The button push requests a change of those properties and display of the results on the screen.
    This is what I would do:
    1. Create member variables in the class iPanel that define the route.
    2. Have a method which sets those variables. This method should call repaint after setting the variables.
    2. Maybe have another boolean which says whether the routine is to be displayed or not. This method should call repaint after setting the boolean.
    3. Change the paint method to draw the route, if required.
    4. In the class that uses iPanel, simply call the methods in iPanel that set the route properties.
    5. Change your class name to IPanel. All class names should start with an upper case letter.
    e.g.,
    private Point start;
    private Point end;
    private boolean displayRoute
    public setRoute(Point newStart, Point newEnd) {
    start = newStart;
    end = newEnd;
    repaint(); // maybe only call if new value is different
    public void setDisplayRoute(boolean value) {
    displayRoute = value;
    repaint(); // maybe only call if new value is different
    public void paint(Graphics g) {
    g.drawImage( ..... blah
    if (displayRoute) {
    g.drawline ( .... blah
    // Then
    onActionPerformed
    iPanel.setRoute(new Point(1,2), new Point(3,4));

  • Set Cursor.vi fails after it has been called for 30 different panel refs in LV 7.1.1

    Make sure both attached files (Run LabVIEW_Cursor_TestCase.vi, SimpleVI.vi) are in the same folder. Run LabVIEW_Cursor_TestCase.vi notice that the -3 error code is returned from "Set Cursor.vi" after it has been called with 30 different panel refs. If "Set Cursor.vi" is replaced with "Set Busy.vi" the same error occurs.Is there a workaround for this problem other that setting the cursor image manually in user32.dll? I must be able to open more than 30 panels and set them all to busy. In the test case I used a single VI, simply to demonstrate the error.
    Message Edited by Jerred on 05-04-2007 10:06 AM
    Attachments:
    LabVIEW_Cursor_TestCase.vi ‏68 KB
    SimpleVI.vi ‏13 KB

    This bug is fixed in LabVIEW 8.0 and later.  Unfortunately, I know of no workaround in LabVIEW 7.x.  When I encountered this bug in one of my UIs in LabVIEW 7.x, my "fix" was simply to ignore the error outputs from the cursor VIs, and to live with the fact that I had no custom cursors after 30 windows had been opened.
    -D
    Darren Nattinger, CLA
    LabVIEW Artisan and Nugget Penman

  • How to drag image in left panel then drop into right panel??

    Dear friends.
    I have following code, it is runnable, just add two jpg image files is ok, to run.
    I tried few days to drag image from left panel then drop into right panel or vice versa, but not success, can any GUI guru help??
    Thanks.
    Sunny
    [1]. main code/calling code:
    import java.util.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class ImagePanelCall extends JComponent {
         public  JSplitPane ImagePanelCall() {
              setPreferredSize(new Dimension(1200,300));
              JSplitPane          sp = new JSplitPane();
              sp.setPreferredSize(new Dimension(1200,600));
              sp.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
              add(sp);
              ImagePanel     ip = new ImagePanel();
              ImagePanel     ip1 = new ImagePanel();
              ip.setPreferredSize(new Dimension(600,300));
              ip1.setPreferredSize(new Dimension(600,300));
              sp.setLeftComponent(ip);// add left part
              sp.setRightComponent(ip1);// add right part
              sp.setVisible(true);
              return sp;
         public static void main(String[] args) {
              JFrame frame = new JFrame("Test transformable images");
              ImagePanelCall  ic = new ImagePanelCall();
              frame.setPreferredSize(new Dimension(1200,600));
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.getContentPane().add(ic.ImagePanelCall(), BorderLayout.CENTER);
              frame.pack();
              frame.setVisible(true);
    }[2]. code 2
    import java.util.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class ImagePanel extends JComponent {
         private static final Cursor DEFAULT_CURSOR = new Cursor(Cursor.DEFAULT_CURSOR);
         private static final Cursor MOVE_CURSOR = new Cursor(Cursor.MOVE_CURSOR);
         private static final Cursor VERTICAL_RESIZE_CURSOR = new Cursor(Cursor.N_RESIZE_CURSOR);
         private static final Cursor HORIZONTAL_RESIZE_CURSOR = new Cursor(Cursor.W_RESIZE_CURSOR);
         private static final Cursor NW_SE_RESIZE_CURSOR = new Cursor(Cursor.NW_RESIZE_CURSOR);
         private static final Cursor NE_SW_RESIZE_CURSOR = new Cursor(Cursor.NE_RESIZE_CURSOR);
         public Vector images;
         * Create an ImagePanel with two images in.
         * A MouseHandler instance is added as mouse listener and mouse motion listener.
         public ImagePanel() {
              images = new Vector();
              images.add(new TransformableImage("swing/dnd/Bird.gif"));
              images.add(new TransformableImage("swing/dnd/Cat.gif"));
              setPreferredSize(new Dimension(600,600));
              MouseHandler mh = new MouseHandler();
              addMouseListener(mh);
              addMouseMotionListener(mh);
         * Simply paint all the images contained in the Vector images, calling their method draw(Graphics2D, ImageObserver).
         public void paintComponent(Graphics g) {
              Graphics2D g2D = (Graphics2D)g;
              for (int i = images.size()-1; i>=0; i--) {     
                   ((TransformableImage)images.get(i)).draw(g2D, this);
         * Inner class defining the behavior of the mouse.
         final class MouseHandler extends MouseInputAdapter {
              private TransformableImage draggedImage;
              private int transformation;
              private int dx, dy;
              public void mouseMoved(MouseEvent e) {
                   Point p = e.getPoint();
                   TransformableImage image = getImageAt(p);
                   if (image != null) {
                        transformation = image.getTransformation(p);
                        setConvenientCursor(transformation);
                   else {
                        setConvenientCursor(-1);
              public void mousePressed(MouseEvent e) {
                   Point p = e.getPoint();
                   draggedImage = getImageAt(p);
                   if (draggedImage!=null) {
                        dx = p.x-draggedImage.x;
                        dy = p.y-draggedImage.y;
              public void mouseDragged(MouseEvent e) {
                   if (draggedImage==null) {
                        return;
                   Point p = e.getPoint();
                   repaint(draggedImage.x,draggedImage.y,draggedImage.width+1,draggedImage.height+1);
                   draggedImage.transform(p, transformation,dx,dy);
                   repaint(draggedImage.x,draggedImage.y,draggedImage.width+1,draggedImage.height+1);
              public void mouseReleased(MouseEvent e) {
                   Point p = e.getPoint();
                   draggedImage = null;
         * Utility method used to get the image located at a Point p.
         * Returns null if there is no image at this point.
         private final TransformableImage getImageAt(Point p) {
              TransformableImage image = null;
              for (int i = 0, n = images.size(); i<n; i++) {     
                   image = (TransformableImage)images.get(i);
                   if (image.contains(p)) {
                        return(image);
              return(null);
         * Sets the convenient cursor according the the transformation (i.e. the position of the mouse over the image).
         private final void setConvenientCursor(int transfo) {
              Cursor currentCursor = getCursor();
              Cursor newCursor = null;
              switch (transfo) {
                   case TransformableImage.MOVE : newCursor = MOVE_CURSOR;
                        break;
                   case TransformableImage.RESIZE_TOP : newCursor = VERTICAL_RESIZE_CURSOR;
                        break;
                   case TransformableImage.RESIZE_BOTTOM : newCursor = VERTICAL_RESIZE_CURSOR;
                        break;
                   case TransformableImage.RESIZE_LEFT : newCursor = HORIZONTAL_RESIZE_CURSOR;
                        break;
                   case TransformableImage.RESIZE_RIGHT : newCursor = HORIZONTAL_RESIZE_CURSOR;
                        break;
                   case TransformableImage.RESIZE_TOP_LEFT_CORNER : newCursor = NW_SE_RESIZE_CURSOR;
                        break;
                   case TransformableImage.RESIZE_TOP_RIGHT_CORNER : newCursor = NE_SW_RESIZE_CURSOR;
                        break;
                   case TransformableImage.RESIZE_BOTTOM_LEFT_CORNER : newCursor = NE_SW_RESIZE_CURSOR;
                        break;
                   case TransformableImage.RESIZE_BOTTOM_RIGHT_CORNER : newCursor = NW_SE_RESIZE_CURSOR;
                        break;
                   default : newCursor = DEFAULT_CURSOR;
              if (newCursor != null && currentCursor != newCursor) {
                   setCursor(newCursor);
         public static void main(String[] args) {
              JFrame frame = new JFrame("Test transformable images");
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.getContentPane().add(new ImagePanel(), BorderLayout.CENTER);
              frame.pack();
              frame.setVisible(true);
    }[3]. code 3
    import java.awt.*;
    import javax.swing.*;
    import java.awt.image.*;
    public final class TransformableImage extends Rectangle {
         public static final int MOVE = 0;
         public static final int RESIZE_TOP = 10;
         public static final int RESIZE_BOTTOM = 20;
         public static final int RESIZE_RIGHT = 1;
         public static final int RESIZE_LEFT = 2;
         public static final int RESIZE_TOP_RIGHT_CORNER = 11;
         public static final int RESIZE_TOP_LEFT_CORNER = 12;
         public static final int RESIZE_BOTTOM_RIGHT_CORNER = 21;
         public static final int RESIZE_BOTTOM_LEFT_CORNER = 22;
         public static final int BORDER_THICKNESS = 5;
         public static final int MIN_THICKNESS = BORDER_THICKNESS*2;
         private static final Color borderColor = Color.black;
         private Image image;
         * Create an TransformableImage from the image file filename.
         * The TransformableImage bounds (inherited from the class Rectangle) are setted to the corresponding values.
         public TransformableImage(String filename) {
              ImageIcon ic = new ImageIcon(filename);
              image = ic.getImage();
              setBounds(0,0,ic.getIconWidth(), ic.getIconHeight());
         * Draw the image rescaled to fit the bounds.
         * A black rectangle is drawn around the image.
         public final void draw(Graphics2D g, ImageObserver observer) {
              Color oldColor = g.getColor();
              g.setColor(borderColor);
              g.drawImage(image, x, y, width, height, observer);
              g.draw(this);
              g.setColor(oldColor);
         * Return an int corresponding to the transformation available according to the mouse location on the image.
         * If the point p is in the border, with a thickness of BORDER_THICKNESS, around the image, the corresponding
         * transformation is returned (RESIZE_TOP, ..., RESIZE_BOTTOM_LEFT_CORNER).
         * If the point p is located in the center of the image (i.e. out of the border), the MOVE transformation is returned.
         * We allways suppose that p is contained in the image bounds.
         public final int getTransformation(Point p) {
              int px = p.x;
              int py = p.y;
              int transformation = 0;
              if (py<(y+BORDER_THICKNESS)) {
                   transformation += RESIZE_TOP;
              else
              if (py>(y+height-BORDER_THICKNESS-1)) {
                   transformation += RESIZE_BOTTOM;
              if (px<(x+BORDER_THICKNESS)) {
                   transformation += RESIZE_LEFT;
              else
              if (px>(x+width-BORDER_THICKNESS-1)) {
                   transformation += RESIZE_RIGHT;
              return(transformation);
         * Move the left side of the image, verifying that the width is > to the MIN_THICKNESS.
         public final void moveX1(int px) {
              int x1 = x+width;
              if (px>x1-MIN_THICKNESS) {
                   x = x1-MIN_THICKNESS;
                   width = MIN_THICKNESS;
              else {
                   width += (x-px);
                   x = px;               
         * Move the right side of the image, verifying that the width is > to the MIN_THICKNESS.
         public final void moveX2(int px) {
              width = px-x;
              if (width<MIN_THICKNESS) {
                   width = MIN_THICKNESS;
         * Move the top side of the image, verifying that the height is > to the MIN_THICKNESS.
         public final void moveY1(int py) {
              int y1 = y+height;
              if (py>y1-MIN_THICKNESS) {
                   y = y1-MIN_THICKNESS;
                   height = MIN_THICKNESS;
              else {
                   height += (y-py);
                   y = py;               
         * Move the bottom side of the image, verifying that the height is > to the MIN_THICKNESS.
         public final void moveY2(int py) {
              height = py-y;
              if (height<MIN_THICKNESS) {
                   height = MIN_THICKNESS;
         * Apply a given transformation with the given Point to the image.
         * The shift values dx and dy are needed for move tho locate the image at the same relative position from the cursor (p).
         public final void transform(Point p, int transformationType, int dx, int dy) {
              int px = p.x;
              int py = p.y;
              switch (transformationType) {
                   case MOVE : x = px-dx; y = py-dy;
                        break;
                   case RESIZE_TOP : moveY1(py);
                        break;
                   case RESIZE_BOTTOM : moveY2(py);
                        break;
                   case RESIZE_LEFT : moveX1(px);
                        break;
                   case RESIZE_RIGHT : moveX2(px);
                        break;
                   case RESIZE_TOP_LEFT_CORNER : moveX1(px);moveY1(py);
                        break;
                   case RESIZE_TOP_RIGHT_CORNER : moveX2(px);moveY1(py);
                        break;
                   case RESIZE_BOTTOM_LEFT_CORNER : moveX1(px);moveY2(py);
                        break;
                   case RESIZE_BOTTOM_RIGHT_CORNER : moveX2(px);moveY2(py);
                        break;
                   default :
    }

    I gave you a simple solution in your other posting. You never responded to the suggestion stating why the given solution wouldn't work, so it can't be that urgent.

  • LR won't synch same images in different folder

    I need to keep multiple copies of the same images in different folders (to track submissions to different agencies) but LR seems very erratic at synching pictures it thinks already exist in the catalogue - some of the duplicates show up, others not, but it seems impossible to get all folders to synch properly. Is there any way around this?

    Yes, I remember, David. Glad it's still working.
    Assuming the current workflow, I reckon the answer is going to lie in establishing which files are omitted. If filenames don't match any files already in the catalogue, I'd expect all to arrive safely. But if a jpg's name matches an existing file (ignoring the extensions) then there might be a clash. One area is Edit > Preferences > Import where you may want to try ticking Treat JPEG files next to raw files as separate. But see if you can establish the pattern of what gets imported and what's not.
    A pure Lightroom solution would be not to keep all these files. So you would have the master image (a raw or a worked tif), and then create virtual copies for each of the uses that you want to track - right click a thumbnail and Create Virtual Copy. Each VC has a copy name, which I'd suggest setting (Metadata panel) to the usage, Getty, Alamy etc. When you need to send it to the agency, get the VC and export at the size and format required, send the exported file, but don't keep a real file copy - the VC could suffice. I put this more for you to think over.
    John

  • Displaying thumbnail images in another panel when it  mouse clicked

    hi,
    I am using JAI, what i am trying to do is i am decoding the tiff file and creating thumbnail of that images and adding thumbnail images to one panel and enlarged images to another panel using DisplayJAI. Now when i will click i thumbnail images on left panel then that image should be display to another panel on right side. Adding both panel to JSplit panel.
    I have no idia how to do it, i tried to do in different way but not able to do that. I hope anybody can give me the hints about this.
    Thanks

    i am adding thumbnail of all images in left panel and enlarged view of each thumbnail is added in right panel , and what i require that when i click thumbnail in left side it's corresponding enlarged image should be visible, suppose in right panel page no. 1 is visible and when i click thumbnail of 13 page in left panel that should be in viewport of right panel.You should put your right panel inside a JScrollPane and call [scrollRectToVisible() |http://java.sun.com/javase/6/docs/api/javax/swing/JComponent.html#scrollRectToVisible(java.awt.Rectangle)] from your panel. You can put the rectangles corresponding to enlarged images in a hash map with the keys being some unique attribute of your thumbnails in left panel. That will help in getting the rectangle to make visible, real fast. Or, you can just put the rectangles in some array indexed according to the thumbnails in left panel.
    I also want to hide the left panel, i think it's possible by Frame.Yes it is possible, but you said you have both your panels in a split pane, so maybe you can use its setDividerLocation() function to hide your left panel.
    Thanks!

  • Display a color image in front panel.

    Hi there,
    How do I display a color image in front panel? Which graphic indicator should be used to display a color image? I do not want to use Imaq WindDraw.
    Thanks in advance.
    Hugh

    Try this "draw flatten jpg to pic ctrl.vi"
    Ian F
    Since LabVIEW 5.1... 7.1.1... 2009, 2010
    依恩与LabVIEW
    LVVILIB.blogspot.com
    Attachments:
    draw_flatten_jpg_to_pic_ctrl.vi ‏35 KB

  • Problems drawing images form another class

    Ok as the title says I'm having trouble drawing images from a different class. I have a class that represents a plane and it has a draw' method that draws its .gif image.
    public void draw (Graphics g)
    g.drawImage(planepic , xPos, yPos, null)
    then in my main class in the paint method i have
    plane.draw(g);
    I think my problem is the null for my image observer. I tried using null as my image observer and i got a error saying i can't make a static reference to a non static method.
    I've done some research because i never really understood static but i still don't quite get it.
    Also when I use this as my image observer i get a error in my plane object.
    I also just tried passing and making a object for my main class and i still got the static error.
    Any help is appreciated and thanks in advance

    Ok as the title says I'm having trouble drawing
    images from a different class. I have a class that
    represents a plane and it has a draw' method that
    draws its .gif image.
    public void draw (Graphics g)
    g.drawImage(planepic , xPos, yPos, null)
    in my main class in the paint method i have
    plane.draw(g);
    I think my problem is the null for my image observer.
    I tried using null as my image observer and i got a
    error saying i can't make a static reference to a non
    static method. Use a minimal implementation of the ImageObserver to be sure.
    public class Plane implements ImageObserver
    public boolean imageUpdate(
    Image img,int infoFlags,int x,int y,int width,int height)
       switch(infoFlags)
          case ALLBITS:
                    return false;
          case SOMEBITS:
                    return true;
          default:
                return true;
    I've done some research because i never really
    understood static but i still don't quite get it.
    Also when I use this as my image observer i get a
    error in my plane object.
    I also just tried passing and making a object for my
    main class and i still got the static error.
    Any help is appreciated and thanks in advanceWhen you call draw(g) from your other class you hand it a Graphics context that you instantiated somewhere else ie: in another class. Without a more complete example it is really impossible to determine your issue for sure,
    but if I was to guess I would say you need to make sure that the Graphics context handed to the draw(Graphics) method was instantiated from a Component that was already visible. ie: Do a f
    Frame.createImage() from your parent frame after iyou have already called setVisible(true); In other words I suspect you are making and Image from some other Component that is not yet visible. That however is a guess so if not the issue post the rest of the code or at least a minimal implementation that demonstrates this.
    About static:
    static means the class/variable is the same throughout ALL classes of that type and if changed in one instance it will change and thus be the same for all instances.
    You CAN call static by referencing the base class Object without having to instantiate.
    ie:given
    public class SomeClass
    static String name;
    static String getName
       if(name == null)
          name = "DefaultName";
       return name;
    }Thus you could call..
      String name = SomeClass.getName();As opposed to
    SomeClass myClass = new SomeClass();
          myClass.getName();This can get you in trouble if you try to make a method that is static
    that then tries to reference non static variables.
    ie:
    public class SomeClass
    int x;
    static String name;
    SomeClass()
       x=0;
    static String getName
       if(name == null)
          name = "DefaultName";
       x++;
       return name;
    }In this case SomeClass.getName(); will throw and exception because it is trying to access[b] x  from a static context .
    Hope that clears that up for you; if not post a more complete example.
    Good Luck!
    (T)

  • How to make image out of panel?

    hi,
    i have a JPanel object and i drawn something on this panel. it also contains somemore components. can anyone say how to create image (like .jpg) from what is getting displayed in my panel.
    thankx in advance.

    Found this in the newgroups
    If you are using Java 2D, you can create a JPEG image by using the
    com.sun.image.codec.jpeg package. The code below creates a JPEG image and
    saves it to a file.
    public void save(BufferedImage destImage, String filename) {
    try {
    ByteArrayOutputStream boutstream = new ByteArrayOutputStream();
    JPEGImageEncoder enc = JPEGCodec.createJPEGEncoder(boutstream);
    enc.encode(destImage);
    FileOutputStream fimage = new FileOutputStream(new File(filename));
    boutstream.writeTo(fimage);
    fimage.close();
    } catch (Exception e) { }
    The code snippet below shows how to crerate a BufferedImage:
    BufferedImage bi = new BufferedImage((int)imWid,
    (int)(imHt),
    BufferedImage.TYPE_INT_RGB);
    Graphics2D g2d = bi.createGraphics();
    g2d.drawImage(img, dispTx,this);
    img : Your image object.
    dispTx: The Affine Transform.
    You can use other drawImage()methods for drawing images.
    Once the image is drawn, you can save it using the save() method.

  • Blast from the past: How do I draw image maps in Dreamweaver CC 2014?

    Need to update some old stuff, and can´t find where to draw image-maps on images.

    First, you need to be in Design View to get the image map tools to appear.
    Once there, the image map icons should show when you select an image. If they don't, you may have your Properties panel collapsed. In the bottom right corner of the Properties panel, there's a tiny triangle, click that to expand the panel to include the image map tools.

  • How to draw a shape to Panel instead of draw to Frame

    I have a Frame and add a Panel into this Frame. I want to draw a shape to Panel instead of draw to Frame. how do i do?

    You can do two different things:
    1) For temporary drawings that will disappear when the component is repainted, you can use getGraphics() on the Panel, draw on the Graphics, then dispose the Graphics.
    2) For persistant drawings, subclass Panel and override the paint(Graphics g) method. Anything in there will be painted along with the panel. Start with super.paint(g); when you override for good coding practice.

  • Drawing Images. Making them Durable?

    Im trying to create an application that draws images to the screen. So for example, it draws an image (call it image x) where the user left clicks the mouse. It draws fine. Then when the user clicks at a new spot, the first image x is erased when the next is placed on the screen. This isn't what I want, I want all previous images from clicking to say. From searching, it seems my problem is that drawn images are not durable. Other forum posts didn't help me understand the solution to the problem so any help would be wonderful.
    Edited by: goyanks135 on May 12, 2009 6:13 PM

    Thanks for the quick reply, that seems to work best for this application. Another thing, is there any way to generate a BufferedImage that represents the panel? Currently I am using:
    <BufferedImage> = robot.createScreenCapture(<Rectangle>);
    to do so, but would not depending on where the window is on the screen. I couldn't figure out how to determine the windows location. Is there a method to create the BufferedImage or obtain the window's coordinates?
    edit: I was looking at the getLocation() and getSize() methods of the component class. Seems like they should work if I use
    <BufferedImage> = robot.createScreenCapture(new Rectangle (getLocation(), getSize());
    I'm going to bed right now and didn't get it to work. Seems like it should.
    Edited by: goyanks135 on May 12, 2009 7:01 PM

Maybe you are looking for

  • Can't Get the Browser to Install

    Hi- I am not sure if this is the place to ask this but since I am in a bind I wil try it. I need Firefox browser instead of using Safari for an online course I am teaching. Since I figured installing Firefox would not cause problems I was not prepare

  • Export data from a scanned form.

    Hello I have several forms that users will fill out and email back.  The data can then be extracted using Adobe's forms tools.  However, at times the form is returned either on paper or scanned. Is there a way to extract the data from the scanned for

  • [Solved] C question

    Hi, how do I get data to my application like this in C: my_application -u Usr_Name -p passwd Last edited by phr (2008-08-15 10:40:02)

  • HT1414 iPhone 4s will not charge

    What do I do if I accidentally dropped my iPhone 4s (does not have the latest iOS software) in slush (snow and salt mixed together) and the battery won't charge? But, when I power it off it charges by itself and when I turn it on the battery drains f

  • COMO RECUPERO UN ARCHIVO QUE ELIMINE POR ERROR

    COMO RECUPERO UN ARCHIVO QUE POR ERROR ELIMINE?