Putting an image in a Panel

i have an applet, i want to put an image in a panel. the image(one image) in the panel will also be changable by button event handling.
thank you

You need to follow this steps:
- Create a class who extends Icon class.
- Rewrite paintIcon method using tool in Graphics class (drawImage..)
- Create a JLabel using your cutom icon
- Insert the JLabel into your panel.
That's it!

Similar Messages

  • How do I put an image in a spry tabbed panels tab

    Hello All,
    I am currently working on a site with Spry Tabbed Panels.
    One thing I'm not sure how to do is to put an image in each of the selecting tabs. I've done it before and I've forgot. I also have a site with an example of what I would like to do.
    http://emilymagnuson.com
    The tabs on this site were created with images inside of them. And I would like to know how to do it. I would like to make it work so the image changes when you click, hover, and deselect.
    Thank you.

    To put an image in the foreground, add it to your HTML code:
    <li class="TabbedPanelsTab" tabindex="0">
    <div style="margin-top:9px;"><img src="your_image_here.jpg">Contact</div>
    </li>
    Nancy O.

  • Getting the bounds of a drawn image on a panel

    Hello, I have a problem with getting the bounds of a drawn image on a panel...Since it is drawn as graphics, i tried getClipBounds and since my class extends JPanel i tried to get the bounds from the panel but neither of them worked properly. It only gets the bounds of a jframe that contains the panel.Then i tried to put the panel in a layeredpane and then a container; but this time the image disappeared completely. Hope someone can help or tell me what I am doing wrong. Thanks in advance. Here is the code below:
    By the way what I am trying to do in this code is basically zooming the image in and out by dragging or the mouse wheel. But I need to get the bounds so that I can use this.
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    * @author Admin
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.Image;
    import java.awt.Point;
    import java.awt.RenderingHints;
    import java.awt.Toolkit;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import java.awt.event.MouseMotionListener;
    import java.awt.event.MouseWheelEvent;
    import java.awt.event.MouseWheelListener;
    import java.awt.geom.AffineTransform;
    import java.awt.geom.NoninvertibleTransformException;
    import java.awt.geom.Point2D;
    import javax.swing.JFrame;
    import javax.swing.JLayeredPane;
    import javax.swing.JPanel;
    public class ZoomDemo extends JPanel {
    AffineTransform tx = new AffineTransform();
    String imagePath = "D:/Documents and Settings/Admin/Belgelerim/tsrm/resim.jpg";
    Image image = Toolkit.getDefaultToolkit().getImage(imagePath);
    int width = image.getWidth(this);
    int height = image.getHeight(this);
    int scrwidth = Toolkit.getDefaultToolkit().getScreenSize().width;
    int scrheight = Toolkit.getDefaultToolkit().getScreenSize().height;
    double zoomfac = 1.0;
    int xAdj;
    int yAdj;
    int prevY;
    double scale = 1.0;
    Point pt;
    public static int x;
    public static int y;
    public static int w;
    public static int h;
    public ZoomDemo() {
    this.addMouseWheelListener(new ZoomHandler());
    this.addMouseListener(new ZoomHandler());
    this.addMouseMotionListener(new ZoomHandler());
      repaint();
    @Override
    public void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D g2 = (Graphics2D) g;
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2.drawImage(image, tx, this);
    // x =    (int) g2.getClipBounds().getX();
    // y=     (int) g2.getClipBounds().getY();
    // w=     (int) g2.getClipBounds().getWidth();
    // h=     (int) g2.getClipBounds().getHeight();
    // System.out.println(x+" "+y+" "+w+" "+h);
    //  public int getRectx(){
    //    return x;
    //public int getRecty(){
    //    return y;
    //public int getRectw(){
    //    return w;
    //public int getRecth(){
    //    return h;
    private class ZoomHandler implements MouseWheelListener,MouseListener, MouseMotionListener {
    public void mousePressed(MouseEvent e){
        System.out.println("Mouse Pressed");
    xAdj = e.getX();
    yAdj = e.getY();
    prevY = getY();
    public void mouseDragged(MouseEvent e){
           System.out.println("Mouse Dragged");
    boolean zoomed = false;
    if(e.getY()<prevY){
         zoomfac = zoomfac + 0.1;
         prevY = e.getY();
         zoomed = true;
    else if(e.getY()>prevY){
         zoomfac = zoomfac - 0.1;
         prevY = e.getY();
         zoomed = true;
       scale = zoomfac;
    Point2D p1 = new Point((int)xAdj-(width/2),(int)yAdj-(height/2));
    Point2D p2 = null;
    try {
    p2 = tx.inverseTransform(p1, null);
    } catch (NoninvertibleTransformException ex) {
    // should not get here
    ex.printStackTrace();
    return;
    tx.setToIdentity();
    tx.translate(p1.getX(), p1.getY());
    tx.scale(scale, scale);
    tx.translate(-p2.getX(), -p2.getY());
    tx.transform(p1, p2);
    ZoomDemo.this.revalidate();
    ZoomDemo.this.repaint();
    public void mouseWheelMoved(MouseWheelEvent e) {
    if (e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) {
    Point2D p1 = e.getPoint();
    Point2D p2 = null;
    try {
    p2 = tx.inverseTransform(p1, null);
    } catch (NoninvertibleTransformException ex) {
    // should not get here
    ex.printStackTrace();
    return;
    scale -= (0.1 * e.getWheelRotation());
    scale = Math.max(0.1, scale);
    tx.setToIdentity();
    tx.translate(p1.getX(), p1.getY());
    tx.scale(scale, scale);
    tx.translate(-p2.getX(), -p2.getY());
    ZoomDemo.this.revalidate();
    ZoomDemo.this.repaint();
            public void mouseClicked(MouseEvent e) {
                //throw new UnsupportedOperationException("Not supported yet.");
            public void mouseReleased(MouseEvent e) {
                //throw new UnsupportedOperationException("Not supported yet.");
            public void mouseEntered(MouseEvent e) {
               // throw new UnsupportedOperationException("Not supported yet.");
            public void mouseExited(MouseEvent e) {
               // throw new UnsupportedOperationException("Not supported yet.");
            public void mouseMoved(MouseEvent e) {
               // throw new UnsupportedOperationException("Not supported yet.");
    public static void main(String[] args) {
    //SwingUtilities.invokeLater(new ZoomDemo());
    int scrwidth = Toolkit.getDefaultToolkit().getScreenSize().width;
    int scrheight = Toolkit.getDefaultToolkit().getScreenSize().height;
    JFrame f = new JFrame("Zoom");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setSize(scrwidth , scrheight);
    //JLayeredPane lp = new JLayeredPane();
    //f.add(lp);
    ZoomDemo zd = new ZoomDemo();
    zd.getBounds();
    f.add(zd);
    //int x = (int) zd.getX();
    //int y = (int) zd.getY();
    //int w = (int) zd.getWidth();
    //int h = (int) zd.getHeight();
    //System.out.println(x+" "+y+" "+w+" "+h);
    //zd.setBounds(x ,y ,w ,h );
    //lp.add(zd, JLayeredPane.DEFAULT_LAYER);
    //f.setLocationRelativeTo(null);
    f.setVisible(true);
    //lp.setVisible(true);
    //zd.setVisible(true);
    }Edited by: .mnemonic. on May 26, 2009 11:07 PM
    Edited by: .mnemonic. on May 27, 2009 11:00 AM

    You'll need a stable point in the component to track and orient to the scaling transform(s).
    From this you can construct whatever you need in the way of image location and size.
    Let's try a center&#8211;of&#8211;image tracking point:
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.awt.image.BufferedImage;
    import javax.swing.*;
    import javax.swing.event.MouseInputAdapter;
    public class ZD extends JPanel {
        BufferedImage image;
        Point center;
        AffineTransform at = new AffineTransform();
        Point2D.Double origin = new Point2D.Double(0,0);
        public ZD(BufferedImage image) {
            this.image = image;
            center = new Point(image.getWidth()/2, image.getHeight()/2);
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            Graphics2D g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
                                RenderingHints.VALUE_INTERPOLATION_BICUBIC);
            g2.drawRenderedImage(image, at);
            g2.setPaint(Color.red);
            g2.fill(new Ellipse2D.Double(origin.x-1.5, origin.y-1.5, 4, 4));
            g2.setPaint(Color.blue);
            g2.fill(new Ellipse2D.Double(center.x-1.5, center.y-1.5, 4, 4));
        private void setTransform(double scale) {
            // keep image centered over Point "center"
            double x = center.x - scale*image.getWidth()/2;
            double y = center.y - scale*image.getHeight()/2;
            origin.setLocation(x, y);
            at.setToTranslation(x, y);
            at.scale(scale, scale);
        public static void main(String[] args) throws java.io.IOException {
            java.net.URL url = ZD.class.getResource("images/hawk.jpg");
            BufferedImage image = javax.imageio.ImageIO.read(url);
            ZD test = new ZD(image);
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.add(test);
            f.setSize(500,500);
            f.setLocation(100,100);
            f.setVisible(true);
            test.addMouseListener(test.mia);
            test.addMouseMotionListener(test.mia);
        /** MouseAdapter okay in j2se 1.6+ */
        private MouseInputAdapter mia = new MouseInputAdapter() {
            final double SCALE_INC = 0.05;
            final int SCALE_STEP = 20;
            double scale = 1.0;
            double lastStep;
            public void mousePressed(MouseEvent e) {
                Point p = e.getPoint();
                center.setLocation(p);
                //System.out.printf("center = [%3d, %3d]%n", p.x, p.y);
                setTransform(scale);
                repaint();
            public void mouseDragged(MouseEvent e) {
                // scale up/down with relative vertical motion
                int step = (e.getY() - center.y)/SCALE_STEP;
                if(step != lastStep) {
                    scale += SCALE_INC*((step < lastStep) ? -1 : 1);
                    //System.out.printf("step = %3d  scale = %.3f%n", step, scale);
                    setTransform(scale);
                    lastStep = step;
                    repaint();
    }

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

  • Image on the panel

    Hi Experts,
    I am in the midst of getting an image onto a frame hence have some difficulty, I seek your assistance to place an image on the left of the message. The code is append for your advice, please.
    import java.io.*;
    import java.util.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.lang.*;
    public class Help implements ActionListener {
    Frame frame = new Frame ("Help");
    Button okButton = new Button ("Ok");
    public Help() {
    Panel buttonPanel = new Panel ();
    buttonPanel.add (okButton);
    okButton.addActionListener (this);
    frame.setLayout(new BorderLayout());
    Panel messagePanel = new Panel();
    messagePanel.setLayout(new GridLayout(14,1));
    messagePanel.add(new Label("Sentence 1 - I want to put an image on my left"));
    messagePanel.add(new Label("Sentence 2 - I want to put an image on my left"));
    messagePanel.add(new Label("Sentence 3- I want to put an image on my left"));
    frame.add("North", messagePanel);
    frame.add("South", buttonPanel);
    frame.pack();
    frame.setVisible(true);
         public static void main(String args[])
         new Help();
         public void actionPerformed (ActionEvent a)
              if (a.getActionCommand().equals("Ok"))
                   frame.dispose();
    }

    Hi there,
    Here is your program with 3 images on the left and 3 labels on their right. Let me know if you have any questions.
    Berk Can Celebisoy
    import java.io.*;
    import java.util.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.lang.*;
    public class ForumTest extends Frame implements ActionListener { 
      Button okButton;
      Image image1, image2, image3;
      Toolkit toolkit;
      public ForumTest() {     
         toolkit = Toolkit.getDefaultToolkit();
         image1 = toolkit.getImage("redButton.gif");      
         image2 = toolkit.getImage("greenButton.gif");      
         image3 = toolkit.getImage("blueButton.gif");      
            okButton = new Button ("Ok");     
             okButton.addActionListener (this);     
         ImagePanel imagePanel1 = new ImagePanel(image1);
         ImagePanel imagePanel2 = new ImagePanel(image2);
         ImagePanel imagePanel3 = new ImagePanel(image3);
         Panel buttonPanel = new Panel ();
          buttonPanel.add (okButton);
         Panel messagePanel = new Panel();
          messagePanel.setLayout(new GridLayout(3, 3));
          messagePanel.add(imagePanel1);
          messagePanel.add(new Label("Red button"));
          messagePanel.add(imagePanel2);
          messagePanel.add(new Label("Green button"));
          messagePanel.add(imagePanel3);
          messagePanel.add(new Label("Blue button"));
            this.setLayout(new BorderLayout());     
            this.add("North", messagePanel);
         this.add("South", buttonPanel);     
         this.pack();
         this.setVisible(true);
      public static void main(String args[]) {
        ForumTest forumTest = new ForumTest();
      public void actionPerformed (ActionEvent a) {
        if (a.getActionCommand().equals("Ok"))
          this.dispose();   
    class ImagePanel extends Panel {
      Image img;
      ImagePanel(Image img) {
        this.img = img;
      public void paint(Graphics g) {
         g.drawImage(img, 0, 0, this);
    }

  • Putting an Image in my CoordinateArea

    Hey,
    I would like to be able to place an image within my CoordinateArea, and I also want this image to be able to respond to being clicked on when the mouse is clicked between certain co-ordinates. Here is my code so far...
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.MouseEvent;
    import javax.swing.event.MouseInputListener;
    public class tourWelby extends JFrame {
    JLabel label = new JLabel();
    JPanel panel = new JPanel();
    Point clickPoint = new Point();
    Point cursorPoint = new Point();
    private static void createAndShowGUI() {
    JFrame.setDefaultLookAndFeelDecorated(true);
              JFrame frame = new JFrame("TourWelby");
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              tourWelby controller = new tourWelby();
              controller.buildUI(frame.getContentPane());
              //Create and set up the content pane.
              frame.getContentPane().setBackground(Color.BLACK);
              // Create the menu bar
              JMenuBar menu = new JMenuBar();
              menu.setBackground(Color.BLACK);
              //Build the menus.
              JMenu file = new JMenu("File");
              file.setBackground(Color.BLACK);
              file.setForeground(Color.WHITE);
              JMenu test = new JMenu("Test");
              test.setBackground(Color.BLACK);
              test.setForeground(Color.WHITE);
              // Install the menu bar in the frame
              frame.setJMenuBar(menu);
              menu.add(file);
              menu.add(test);
              //Display the window.
              frame.pack();
              frame.setVisible(true);
              frame.setResizable(false);
              frame.setSize(800,700);
         private void buildUI(Container container) {
    container.setLayout(new BoxLayout(container,
    BoxLayout.PAGE_AXIS));
    CoordinateArea theArea = new CoordinateArea(this);
    container.add(theArea);
    label = new JLabel();
              label.setBackground(Color.BLACK);
              label.setForeground(Color.WHITE);
    resetLabel();
    container.add(label);
    public void updateCursorLocation(int x, int y) {
    if (x < 0 || y < 0) {
    cursorPoint = null;
    updateLabel();
    return;
    if (cursorPoint == null) {
    cursorPoint = new Point();
    cursorPoint.x = x;
    cursorPoint.y = y;
    updateLabel();
    public void updateClickPoint(Point p) {
    clickPoint = p;
    updateLabel();
    public void resetLabel() {
    cursorPoint = null;
    updateLabel();
    protected void updateLabel() {
    String text = "The cursor is at ";
                   if (cursorPoint != null) {
    text += "("
    + cursorPoint.x + ", " + cursorPoint.y + ") ";
    label.setText(text);
         public static void main(String[] args) {
    //Schedule a job for the event-dispatching thread:
    //creating and showing this application's GUI.
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
    public void run() {
    createAndShowGUI();
    public static class CoordinateArea extends JComponent implements MouseInputListener {
    Point point = null;
    tourWelby controller;
    Dimension preferredSize = new Dimension(800,700);
    public CoordinateArea(tourWelby controller) {
    this.controller = controller;
                   setBorder(BorderFactory.createMatteBorder(3,3,3,3, Color.RED));
    addMouseListener(this);
    addMouseMotionListener(this);
    public Dimension getPreferredSize() {
    return preferredSize;
    //Methods required by the MouseInputListener interface.
    public void mouseClicked(MouseEvent e) {
    int x = e.getX();
    int y = e.getY();
    if (point == null) {
    point = new Point(x, y);
    } else {
    point.x = x;
    point.y = y;
    controller.updateClickPoint(point);
    repaint();
    public void mouseMoved(MouseEvent e) {
    controller.updateCursorLocation(e.getX(), e.getY());
    public void mouseExited(MouseEvent e) {
    controller.resetLabel();
    public void mouseReleased(MouseEvent e) { }
    public void mouseEntered(MouseEvent e) { }
    public void mousePressed(MouseEvent e) { }
    public void mouseDragged(MouseEvent e) { }
    How do I go about putting an image in the CoordinateArea and making it clickable? Do I need to use an ImageIcon?
    Thanks in advance.

    Hi again everyone. I've gone and rethought my code and started again from scratch. Here is what I have come up with..
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.MouseListener;
    import java.awt.event.MouseEvent;
    import java.awt.event.*;
    public class tourWelby extends JFrame  implements MouseListener {
    public void mouseReleased(MouseEvent e) { }
    public void mouseEntered(MouseEvent e) { }
    public void mousePressed(MouseEvent e) { }
    public void mouseDragged(MouseEvent e) { }
    public void mouseExited(MouseEvent e) { }
    public void mouseClicked(MouseEvent e) { }
    public static void main (String args[]) {
         new tourWelby();
         public tourWelby() {
         super("Test");
        Container content = getContentPane();
         Point clickPoint = new Point();
         Point cursorPoint = new Point();
         JLabel label = new JLabel();
         label.setText("Test");
         label.setBackground(Color.WHITE);
         label.setForeground(Color.WHITE);
         JPanel theArea = new JPanel();
         theArea.setPreferredSize(new Dimension(800, 600));
         theArea.setBackground(Color.BLACK);
         theArea.add(label);
         theArea.addMouseListener(this);
         addMouseListener(this);
         content.add(theArea);
             pack();
             setVisible(true);
         setResizable(false);
    }Basiclly now, I think I need to add the mouseListener to the JPanel. However I'm not sure where I need to put the "public void updateCursorLocation" code and such that I had before (before, I used some samples of code from another program, and I wasn't entirely sure how it worked). If someone could help me (again!) with getting the MouseListener to change the label on the JPanel, to reflect where the cursor is (as in my previous code) I would again, be most appreciative. Thanks.

  • Fit image to a panel ?

    hello,
    i have a panel to which i wnat to add an image. this image i want it to fit all the panel.
    how can i do that ?
    if there is a sample code it is appreciated.
    thank u !

    thank you puce it is appreciated.
    i just found a method called constrain(http://www.informit.com/guides/content.aspx?g=java&seqNum=77) that do the job. here is a compilable code ( but gives an error at runtime) hope u can help me out here.the code code is very simple, u have a JTabbedPane to which u have to add a image(put whatever image in you working directory) here is the code:
    import java.awt.*;
    import javax.swing.*;
    import java.awt.image.BufferedImage;
    public class ImagePanel extends JPanel {
        private BufferedImage img;
       * Constrains an Image (or BufferedImage) to a specific width and heigth; if the source
       * image is smaller than width X height then its size is increased to fit
      public static BufferedImage constrain( Image src, int width, int height )
        try
          // Get the source Image dimensions
          int srcWidth = src.getWidth( null );
          int srcHeight = src.getHeight( null );
          // Compute the width to height ratios of both the source and the constrained window
          double srcRatio = ( double )srcWidth / ( double )srcHeight;
          double windowRatio = ( double )width / ( double )height;
          // These variables will hold the destination dimensions
          int destWidth = width;
          int destHeight = height;
          //if( windowRatio > srcRatio )
          if( windowRatio < srcRatio )
            // Bind the height image to the height of the window
            destHeight = ( int )( ( ( double )width / ( double )srcWidth ) * ( double )srcHeight );
          else
            // Bind the width of the image to the width of the window
            destWidth = ( int )( ( ( double )height / ( double )srcHeight ) * ( double )srcWidth );
          // Create a new BufferedImage and paint our source image to it
          BufferedImage destImage = new BufferedImage( destWidth,
                                 destHeight,
                                 BufferedImage.TYPE_USHORT_565_RGB );
          Graphics g = destImage.getGraphics();
          g.drawImage( src, 0, 0, destWidth, destHeight, null );
          // Return the new BufferedImage
          return destImage;
        catch( Exception e )
          e.printStackTrace();
        return null;
        public ImagePanel(String img) {
            this(new ImageIcon(img).getImage());
        public ImagePanel(Image img) {
         this.img=constrain(img,this.getWidth(),this.getHeight());
            /*this.img = img;
            Dimension size = new Dimension(img.getWidth(null),img.getHeight(null));
            setPreferredSize(size);
            setMinimumSize(size);
            setMaximumSize(size);
            setSize(size);
            setLayout(null);*/
        public void paintComponent(Graphics g) {
            g.drawImage(img,0,0,null);
          public static void main(String[] args){
           JFrame frame = new JFrame("Converter");
           frame.setSize(1500,1500);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            ImagePanel p = new ImagePanel(".\\button.gif");
              frame.add(p);
              frame.pack();
            frame.setVisible(true);
    }

  • Putting an image into a JFrame or a JPanel

    Hello everybody,
    I'd like to know how to put an image (a real one, not a small icon we can't see it!) into a JFrame, or a JPanel, or included into a miscellanea element (label, textfield or somethiong else).
    Thanks,
    Regards
    Cedric

    Hi Cedric,
    If the image format is Jpg or gif, then the best way to insert the image
    into the Frame or panel is to use JLabel. You can pass the argument to the file as parameter to JLabel construction.
    For other formats, you have the option of using drawimage in paint function of applets.
    Hope this helps.
    Best Regards,
    Chandru

  • I can't figure out the Keynote title option. I'm a newbie so forgive my ignorance. I want to put an image in the swing arm, but I can't figure it out.

    I even tried opening in Motion and inserting it there, but when I bring it back to fc it's not there. I also want to change the background to an image or at least solid white. When I put an image in the Dropzone it doesn't show up. Any help would be GREATLY appreciated!

    To change the title background to use a clip in the drop zone, do just as Jim said.
    Also, place the clip that want to appear in the "swing arm" right below the title in the timeline.

  • I can't view multiple images in tabbed panels in photoshop CC (do not have this problem in PS5 or 6)

    I can't set up multiple images in tabbed panels in photoshop CC (do not have this problem in PS5 or 6). Has anyone had this problem with CC and if so do they know the fix?

    I just discovered something really weird.  If I open the images in
    photoshop (and the tabs are not showing) and then open another window on
    top of photoshop (for example word or safari) , then the images and tabs
    show in the photoshop window.  But if I move Pshop to the front screen then
    the tabs disappear!

  • Creating an image from a panel

    Hi everybody,
    I have a panel which extends JPanel, and wrote an image() method to extract the drawn image off the panel. For some reason, though, when I call this method, I get a dialog with a black box centered in it, and not the appropriate image.
    My SSCCE is as follows:
    import java.awt.Dimension;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.image.BufferedImage;
    import javax.swing.ImageIcon;
    import javax.swing.JDialog;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.SwingUtilities;
    public class MyPanel extends JPanel {
        private BufferedImage image;
        public BufferedImage image() {
            int x = getWidth();
            int y = getHeight();
            //image = new BufferedImage(x, y, BufferedImage.TYPE_INT_RGB);
            image = new BufferedImage(200, 200, BufferedImage.TYPE_INT_RGB);
            Graphics2D g2 = image.createGraphics();
            SwingUtilities.paintComponent( g2, this, new JPanel(), 0, 0, x, y );
            g2.dispose();
            return image;
        public static void main( String args[] ) {
             MyPanel canvas = new MyPanel() {
                  public void paintComponent( Graphics g ) {
                       Graphics2D g2 = (Graphics2D)g;
                       for( int i = 1; i <= 20; i++ ) {
                            int pos = i*50;
                            g2.drawString( "This is a test", pos, pos );
             JDialog test = new JDialog();
            JLabel label = new JLabel( new ImageIcon( canvas.image() ) );
            JScrollPane scroller = new JScrollPane( label );
            scroller.setPreferredSize( new Dimension( 500, 500 ) );
            test.add( scroller );
            test.pack();
            test.setVisible( true );
    }I'm pretty sure it has something to do with the sizing of the image and the timing of the repainting--when I uncomment the commented line in image(), I get an error saying width and height can't be less than or equal to 0. But anyway, I need to paint and then show an image of what was painted, not the actual painted panel--that's what I'm having trouble with. If anyone could help me out, I'd appreciate it. Can anyone help me fix this, please?
    Thanks,
    Jezzica85
    Edited by: jezzica85 on Jun 1, 2009 6:16 AM

    Odd choice to both have the panel with a getImage() method, and also override paintComponent(Graphics).
    Here is an alternate form of your code.
    import java.awt.*;
    import java.awt.image.BufferedImage;
    import javax.swing.*;
    public class MyPanel extends JPanel {
      private BufferedImage image;
      public BufferedImage image() {
        int x = 200;
        int y = 200;
        image = new BufferedImage(x,y, BufferedImage.TYPE_INT_RGB);
        Graphics2D g2 = image.createGraphics();
        g2.setColor(Color.yellow);
        g2.fillRect(0,0,x,y);
        g2.setColor(Color.black);
        for( int i = 1; i <= 20; i++ ) {
          int pos = i*50;
          g2.drawString( "This is a test", pos, pos );
        g2.dispose();
        return image;
      public static void main( String args[] ) {
        Runnable r = new Runnable() {
          public void run() {
            MyPanel canvas = new MyPanel();
            JDialog test = new JDialog();
            JLabel label = new JLabel( new ImageIcon( canvas.image() ) );
            JOptionPane.showMessageDialog(null, label);
            JScrollPane scroller = new JScrollPane( label );
            scroller.setPreferredSize( new Dimension( 500, 500 ) );
            JOptionPane.showMessageDialog(null, scroller);
        EventQueue.invokeLater(r);
    }

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

  • I had all photos on a Windows desktop.  Got a mac laptop, installed LR5, and put all images from Windows onto an external hard drive.  When I go to import them into LR on the Mac, they are all locked.  Help, please.  Thanks

    I had all photos on a Windows desktop.  Got a mac laptop, installed LR5, and put all images from Windows onto an external hard drive.  When I go to import them into LR on the mac, they are all locked.  Help, please!

    "I plugged the external into the Mac and moved a folder of images onto the desktop.  It looks like it went from read only to not locked.  Is this possible?"
    Yes, that's exactly what happened. If you buy another drive, you could copy from your existing drive to the new and your files will be read/write. The new drive will have to be formatted as an HFS drive (that's the Mac's format). If you need to format it, you use Disk Utility which is in the Utilities folder on your Mac. Be careful with that -- it wipes out whatever is currently on the drive. Make sure you format the right drive.
    I keep all my images on an external drive, too. In fact, I have two matching drives and sync them so I always have a backup.

  • How to put an image in a data grid in Flex Builder 2

    Hi All,
    I need to populate a data grid with some text data received
    from a web service and, in a particular column of the datagrid, I
    have to put an image depending of a specific data returned me by
    the web service.
    It seems that there is the possibility to add an image in
    data grid column with the cellRenderer properties, but this
    property is available only for ActionScript 3.
    I'm developing an application in Flex Builder 2 that run
    ActionScript 2 and cellRenderer properties is not available. Is it
    right?
    If no, I will can use this cellRenderer properties in my
    application. Please, can you show me an example?
    If yes, there is a way to insert an image in datagridcolumn
    with ActionScript 2?
    Thank you very much
    Regards

    Flex Builder 2 uses Actionscript 3.
    You will need to write a renderer for for this column.
    There are a lot of examples of datagrids with images in them.
    here is one from the livedocs
    http://livedocs.adobe.com/flex/201/html/wwhelp/wwhimpl/common/html/wwhelp.htm?context=Live Docs_Book_Parts&file=cellrenderer_072_28.html

  • How to put an image in the popup help of a page item?

    I am using APEX 2.2. I want to put an image in the help text of a page input item.
    This is the help text:
    Some help text....
    <p><img src="&APP_IMAGES.auto_lov.jpg" /></p>This is rendered as:
    <p><img src="wwv_flow_file_mgr.get_file?p_security_group_id=0&p_flow_id=103&p_fname=auto_lov.jpg" /></p>As you can see, the application id is not returned.
    If I put exactly the same text in a html region, the image is correctly displayed:
    <p><img src="wwv_flow_file_mgr.get_file?p_security_group_id=844129086577364&p_flow_id=103&p_fname=auto_lov.jpg" />So, is it possible at all to put in image in the popup help text of a page item?

    I solved it by putting the jpg file in an images directory on the web server instead of in the database. Not really what I want, but it works.
    <p><img src="&IMAGE_PREFIX./apps/auto_lov.jpg" /></p>

Maybe you are looking for