Display image using JPanel

i have got buffered image from webcam using jmf. i want to display it on JPanel.
i override paint() but it doesn't display as it captures
when i maximize window it then displays
urgent help needed

The bounds of your JPanel may be incorrect. You should try the setBounds(int x, int y, int width, int height) method on it.
Please past your code for more help :p

Similar Messages

  • Display image in JPanel without saving any file to disk

    Hi,
    I am fetching images from database. I am saving this image, display in JPanel and delete it. But this is not actually I want.
    I wish to fetch this image as stream , store in memory and display in JPanel without saving any fiel in disk.
    I wonder if it is Possible or any used implementation that I can use in my project. Any idea or experienced knowledge is enough.
    Thanks

    In what format is the image coming to you from the database? If it's an InputStream subclass, just use javax.imageio.ImageIO:
    InputStream in = getImageInputStream();
    BufferedImage image = null;
    try {
       image = ImageIO.read(in);
    } finally {
       in.close();
    // ... Display image in your JPanel as you have beenIf you receive the image as an array of bytes, use the same method as above, but with a ByteArrayInputStream:
    byte[] imageData = getImageData();
    ByteArrayInputStream in = new ByteArrayInputStream(imageData);
    BufferedImage image = null;
    try {
       image = ImageIO.read(in);
    } finally {
       in.close();
    // ... Display image in your JPanel as you have been

  • How to display image using from open dialog box?

    I've developed a program that can display image by named the file that I want to display in my program.
    But how can I display an image from an Open Dialog Box?
    I attch here with my program.
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.filechooser.*;
    public class SuDisplayTool6 extends JFrame implements InternalFrameListener,ActionListener
    JTextArea display1;
    JDesktopPane desktop;
    JInternalFrame displayWindow;
    JInternalFrame listenedToWindow;
    static final String SHOW = "Show Image";
    static final int desktopWidth = 800;
    static final int desktopHeight = 600;
    private static final int kControlX = 88 ;
    private DrawingPanel panel;
    public SuDisplayTool6(String title)
    super("Internal Frame");
    desktop = new JDesktopPane();
    desktop.putClientProperty("JDesktopPane.dragMode","outline");
    desktop.setPreferredSize(new Dimension(desktopWidth, desktopHeight));
    setContentPane(desktop);
    addMenu();
    createDisplayWindow();
    desktop.add(displayWindow);
    Dimension displaySize = displayWindow.getSize();
    displayWindow.setSize(desktopWidth, displaySize.height);
    protected void createDisplayWindow()
    JButton b1 = new JButton("Show Image");
    b1.setActionCommand(SHOW);
    b1.addActionListener(this);
    display1 = new JTextArea(3,30);
    display1.setEditable(false);
    JScrollPane textScroller = new JScrollPane(display1);
    textScroller.setPreferredSize(new Dimension(200,75));
    textScroller.setMinimumSize(new Dimension(10,10));
    displayWindow = new JInternalFrame("Header Graph",true,false,true,true);
    JPanel contentPane = new JPanel();
    contentPane.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
    contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
    contentPane.add(Box.createRigidArea(new Dimension(0,5)));
    contentPane.add(textScroller);
    b1.setAlignmentX(CENTER_ALIGNMENT);
    contentPane.add(b1);
    displayWindow.setContentPane(contentPane);
    displayWindow.pack();
    displayWindow.show();
    protected void createListenedToWindow()
    listenedToWindow = new JInternalFrame("Image",true,true,true,true);
    listenedToWindow.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    listenedToWindow.setSize(800,450);
    panel = new DrawingPanel();
    listenedToWindow.setContentPane(panel);
    public void internalFrameClosing(InternalFrameEvent e)
    public void internalFrameClosed(InternalFrameEvent e)
    listenedToWindow = null;
    public void internalFrameOpened(InternalFrameEvent e)
    public void internalFrameIconified(InternalFrameEvent e)
    public void internalFrameDeiconified(InternalFrameEvent e)
    public void internalFrameActivated(InternalFrameEvent e)
    public void internalFrameDeactivated(InternalFrameEvent e)
    public void actionPerformed(ActionEvent e)
    if (e.getActionCommand().equals(SHOW))
    if (listenedToWindow == null)
    createListenedToWindow();
    listenedToWindow.addInternalFrameListener(this);
    desktop.add(listenedToWindow);
    listenedToWindow.setLocation(desktopWidth/2 - listenedToWindow.getWidth()/2,
    desktopHeight - listenedToWindow.getHeight());
    listenedToWindow.show();
    else
    public static void main(String[] args)
    JFrame frame = new SuDisplayTool6("Su Display Tool");
    frame.addWindowListener(new WindowAdapter()
    public void windowClosing(WindowEvent e)
    System.exit(0);
    frame.pack();
    frame.setVisible(true);
    private void addMenu()
    JMenuBar menuBar;
    JMenu menu, submenu;
    JMenuItem menuItem;
    final JFileChooser fc = new JFileChooser();
    fc.addChoosableFileFilter(new ImageFilter());
    menuBar = new JMenuBar();
    setJMenuBar(menuBar);
    menu = new JMenu("File");
    menuBar.add(menu);
    menuItem = new JMenuItem("Open...");
    menu.add(menuItem).addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent e)
    int returnVal = fc.showOpenDialog(SuDisplayTool6.this);
    menuItem = new JMenuItem("Save");
    menu.add(menuItem);
    menuItem = new JMenuItem("Save As...");
    menu.add(menuItem).addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent e)
    int returnVal = fc.showSaveDialog(SuDisplayTool6.this);
    menuItem = new JMenuItem("Close");
    menu.add(menuItem);
    menu.addSeparator();
    menuItem = new JMenuItem("Exit");
    menu.add(menuItem).addActionListener(new WindowHandler());
    menu = new JMenu("Edit");
    menuBar.add(menu);
    menu = new JMenu("View");
    menuBar.add(menu);
    menuItem = new JMenuItem("Zoom In");
    menu.add(menuItem);
    menuItem = new JMenuItem("Zoom Out");
    menu.add(menuItem);
    menu.addSeparator();
    submenu = new JMenu("Header");
    menuItem = new JMenuItem("CDPX");
    submenu.add(menuItem);
    menuItem = new JMenuItem("SX");
    submenu.add(menuItem);
    menuItem = new JMenuItem("CX");
    submenu.add(menuItem);
    menu.add(submenu);
    menu = new JMenu("Help");
    menuBar.add(menu);
    menuItem = new JMenuItem("About");
    menu.add(menuItem).addActionListener(new WindowHandler());
    private class WindowHandler extends WindowAdapter implements ActionListener
    public void windowClosing(WindowEvent e)
    System.exit(0);
    public void actionPerformed(ActionEvent e)
    if(e.getActionCommand().equalsIgnoreCase("exit"))
    System.exit(0);
    else if(e.getActionCommand().equalsIgnoreCase("About"))
    JOptionPane.showMessageDialog(null,"This program is written by Nenny Ruthfalydia.","About",JOptionPane.PLAIN_MESSAGE);
    class DrawingPanel extends Panel
    final ImageIcon imageIcon = new ImageIcon("image8.jpg");
    Image image = imageIcon.getImage();
    public void paint (Graphics g)
    g.drawImage(image, 10, 10, this);

    so much wrong with this post...
    a) use the code tags to format the code. Now it is an unreadable mess
    b) scriptlets in your JSP. I don't even want to look at that mess. Learn how to combine servlets and JSPs to create clean, readable and maintainable code in which view logic and business logic are separated. The rule: no java code in your JSP, only tags and EL expressions (learn about JSTL).
    So you get a blank screen. When you do "view source" in your browser, do you see anything there? If nothing, check if you are behind a proxy server. The solution to a post of not too long ago was that the blank screen was being caused by faulty proxy server settings (the user figured it out himself, I don't know what was done to solve it).
    If all this fails you will have to do some debugging magic using your favorite IDE. It will probably be something stupid you are overlooking in the code. It is annoying, but debugging code that does not work is a big part of your job. Better get good at it.

  • How to  upload and display image using bsp application

    hi
    I  just wants to know that
    1- how to  upload image from BSP page with attachment into sap server .?
    2-how to display image in to BSP page(webpage).
    thanks

    Hello Gupta Prashant,
    Just to upload and display an image, import image in MIME repository. Not only still images but also flash files can also be uploaded in the MIME repository. Once you import the image in it, use normal html code for image call;
    <img src = "file.jpg/gif" width=  height=>
    Besides it, if your requirement is to store the image in the database and fetch it based on specified field-name, then you have to go for BLOBs i.e Binary Large Object, using this you can also store images, videos, pdfs, applications in the database.
    MBLOB - Medium BLOBs store videos and pdfs,
    LBLOB  - Large BLOBs store movie files and applications.
    You have got 2 ways to use it; some databases store BLOB objects into themselves and some store the path of the BLOB object maintained on the FTP server.
    You can also implement it in ABAP;
    read the following link and practice the tutorial;
    [ Use of MIME Types|http://help.sap.com/saphelp_45b/helpdata/en/f1/b4a6c4df3911d18e080000e8a48612/content.htm]
    also check this
    [TYPES - LOB HANDLE|http://help.sap.com/abapdocu/en/ABAPTYPES_LOB_HANDLE.htm]
    And looking at your question, in order to upload an image, you can make use of FILEUPLOAD tag provided by HTMLB.
    Step 1: FILEUPLOAD provides a browse button to choose desired image file.
    Step 2: Store that image in database using BLOBs.
    Step 3: Retrieve the image using normal select query and display it on the screen.
    Hope it helps you,
    Zahack

  • Having trouble displaying image in JPanel

    I want to display an image in jpanel making it to scale to the size of the panel.
    And later i should be able to draw on that image , i am really new to all this , but i have to finish it soon.
    This is the code i am compiling and getting error
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class LocaterClient extends JFrame
         JPanel panel;
         public LocaterClient()
              super("LocaterClient");
              panel = new JPanel();
              panel.setSize(374,378);
              panel.setOpaque(false);
              panel.setVisible(true);
         getContentPane().add(panel);
         /*JFrame f = new JFrame();
         f.setSize(374,378);
         f.getContentPane().add(panel);*/
         public void paintComponent(Graphics g)
              super.paintComponent(g);
              ImageIcon img = new ImageIcon("World_MER.jpg");
              ImageIcon fillImage = new ImageIcon(img.getImage().getScaledInstance
    (getWidth(), getHeight(),Image.SCALE_REPLICATE));
              g.drawImage(fillImage.getImage(), 0,0, this);
         public static void main(String args[])
              LocaterClient lc = new LocaterClient();
              lc.setDefaultCloseOperation( EXIT_ON_CLOSE );
              lc.pack();
              lc.setVisible(true);
    This is the error i am getting
    LocaterClient.java:24: cannot resolve symbol
    symbol : method paintComponent (java.awt.Graphics)
    location: class javax.swing.JFrame
    super.paintComponent(g);
    ^
    1 error
    If i remove super.paintComponent(g); line it compiles and runs but i get a tiny panel without the image.
    PLease help me , i am not evn sure is this is the procedure should i follow , because i should be able to draw on that image later on .
    Please provide me with some sample code.

    import javax.swing.*;
    import java.awt.*;
    public class ImagePainter extends JPanel{
      private Image img;
      public ImagePainter(){
        img = Toolkit.getDefaultToolkit().getImage("MyImage.gif");
      public void paintComponent(Graphics g){
        g.drawImage(img,0,0,getSize().width,getSize().height);
      public static void main(String[]args){
        JFrame frame = new JFrame();
        frame.getContentPane.add(new ImagePainter());
        frame.setSize(500,500);
        frame.show();

  • Need to display image on JPanel

    Hello
    I am trying to implement a graphical version of the Knights Tour. I am done with the algorithm part of the problem itself. I am having problem with displaying the chess board. Although seemingly straightforward the images will not display on the JPanel. Below is a sample of what I am trying to do. Can anyone explain why the code does not work even though it seems okay. Thanks and best regards.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.image.*;
    import java.awt.event.*;
    public class test extends JFrame { 
    public test(){ 
    panel pane = new panel();
    getContentPane().add(pane);
    public static void main(String[]args){   
    test tst = new test();
    tst.setSize(500,500);
    tst.show();
    public class panel extends JPanel{   // inner class
    private Image img;
    private ImageIcon icon;
    public panel(){
    icon = new ImageIcon("cross.gif");
    img = icon.getImage();
    public void paintComponent(Graphics g)
    super.paintComponent(g);
    Graphics2D g2d = (Graphics2D)g;
    System.out.println("I am here");
    g.drawImage(img,40,40,this);
    }

    package com.lc.util.swing ;
    import java.awt.Color ;
    import java.awt.Graphics ;
    import java.awt.Image;
    import java.awt.Insets;
    import java.awt.Dimension ;
    import java.awt.image.ImageObserver ;
    import javax.swing.JPanel;
    import javax.swing.border.Border;
    * Panel displaying an {@link Image}.
    * <ul>
    * <li>8 positions,</li>
    * <li>
    * can stretch image for filling the whole available area, or diminish
    * its size if too large in width or height,
    * </li>
    * <li>respects borders (as defined by
    * {@link javax.swing.JComponent#setBorder( javax.swing.border.Border ) JComponent.setBorder}
    * </li>
    * </ul>
    * @author Laurent Caillette
    * @version $Revision: 1.1.1.1 $ $Date: 2002/02/19 22:12:04 $
    public class JImagePanel extends JPanel {
    public JImagePanel() {
    imageObserver = this ;
    * Constructeur assignant une image.
    public JImagePanel( Image image ) {
    this() ;
    setImage( image ) ;
    private Image image ;
    private ImageObserver imageObserver ;
    public void setImage( Image image ) {
    this.image = image ;
    adjustPreferredSize();
    public void setBorder( Border newBorder ) {
    super.setBorder( newBorder ) ;
    adjustPreferredSize() ;
    private void adjustPreferredSize() {
    if( image != null ) {
    int w = image.getWidth( imageObserver ) ;
    int h = image.getHeight( imageObserver ) ;
    Border border = getBorder() ;
    if( border != null ) {
    Insets insets = border.getBorderInsets( this ) ;
    if( insets != null ) {
    w += ( insets.left + insets.right ) ;
    h += ( insets.top + insets.bottom ) ;
    Dimension dim = new Dimension( w, h ) ;
    this.setPreferredSize( dim ) ;
    private int placement = CENTER ;
    public int getPlacement() { return placement ; }
    public void setPlacement( int placement ) {
    if( ( placement < CENTER ) || ( placement > STRETCH ) ) {
    throw new IllegalArgumentException( "Unsupported placement value" ) ;
    this.placement = placement ;
    public void paint( Graphics gr ) {
    // x of Image to draw
    int x ;
    // y of Image to draw
    int y ;
    // width of Image to draw
    int iw ;
    // height of Image to draw
    int ih ;
    // thickness of left border
    int bl = 0 ;
    // thickness of upper border
    int bt = 0 ;
    // thickness of right border
    int br = 0 ;
    // thickness of lower border
    int bb = 0 ;
    // width of drawable area
    int pw = this.getWidth() ;
    // height of drawable area
    int ph = this.getHeight() ;
    // Handle borders
    Insets insets = null ;
    Border border = getBorder() ;
    if( border != null ) {
    insets = getBorder().getBorderInsets( this ) ;
    if( insets != null ) {
    bl = insets.left ;
    br = insets.right ;
    bb = insets.bottom ;
    bt = insets.top ;
    pw = pw - bl - br ;
    ph = ph - bt - bb ;
    // Always display background, for supporting transparency.
    super.paint( gr ) ;
    if( image != null ) {
    iw = image.getWidth( imageObserver ) ;
    ih = image.getHeight( imageObserver ) ;
    if( ( placement == STRETCH ) ||
    ( iw > pw ) ||
    ( ih > ph )
    gr.drawImage(image, bl, bt, pw, ph, imageObserver ) ;
    } else {
    iw = image.getWidth( imageObserver ) ;
    ih = image.getHeight( imageObserver ) ;
    switch( placement ) {
    case CENTER :
    x = ( pw - iw ) / 2 ;
    y = ( ph - ih ) / 2 ;
    break ;
    case NORTH :
    x = ( pw - iw ) / 2 ;
    y = 0 ;
    break ;
    case NORTHEAST :
    x = pw - iw ;
    y = 0 ;
    break ;
    case EAST :
    x = pw - iw ;
    y = (ph - ih ) / 2 ;
    break ;
    case SOUTHEAST :
    x = pw - iw ;
    y = ph - ih ;
    break ;
    case SOUTH :
    x = ( pw - iw ) / 2 ;
    y = ph - ih ;
    break ;
    case SOUTHWEST :
    x = 0 ;
    y = ph - ih ;
    break ;
    case WEST :
    x = 0 ;
    y = ( ph - ih ) / 2 ;
    break ;
    case NORTHWEST :
    x = 0 ;
    y = 0 ;
    break ;
    default :
    throw new IllegalArgumentException(
    "Unsupported placement value" ) ;
    // Add border offset
    x += bl ;
    y += bt ;
    gr.drawImage( image, x, y, this ) ;
    public final static int CENTER = 0 ;
    public final static int NORTH = 1 ;
    public final static int NORTHEAST = 2 ;
    public final static int EAST = 3 ;
    public final static int SOUTHEAST = 4 ;
    public final static int SOUTH = 5 ;
    public final static int SOUTHWEST = 6 ;
    public final static int WEST = 7 ;
    public final static int NORTHWEST = 8 ;
    public final static int STRETCH = 9 ;

  • Problem displaying image in jpanel

    Hi,I have posted this on the applet board, but I think its also a general programming problem, so apologies if it isn't relevant to this board, just say so and I'll remove it!
    I've got an applet that receives a variable from a PHP page as a parameter. The variable is "map1.png" the map this variable refers to sits in the same folder as the applet.
    I want to use this variable along with getDocumentBase() to create a URL which will then be used to display an image within a jPanel called mapPane.
    the code I currently have is:
    // get image url
    String mapURL = getParameter("mapURL");
    //set variable for image
    Image map_png;
    // set media tracker
    MediaTracker mt;
    //initialise media tracker     
    mt = new MediaTracker(this);
    map_png = getImage(getDocumentBase(),mapURL);
    // tell the MediaTracker to kep an eye on this image, and give it ID 1;
    mt.addImage(map_png,1);
    // now tell the mediaTracker to stop the applet execution
    // until the images are fully loaded.
    try
    mt.waitForAll();
    catch (InterruptedException e) {}
    // draw image onto mapPane
    mapPane.getGraphics().drawImage(map_png, 200, 200, null);
    Currently the Parameter is being passed into the applet (i've written it out within the applet) but the image is not being displayed. Does anyone have any suggestions about what I'm doing wrong?
    Cheers
    Steve

    hi,
    No, don't get any exceptions, the Java Console has a message:
    <terminated>JavaImageEditor[Java Applet]C:\Program Files\Java\jre1.6.0\bin\javaw.exe
    Cheers
    Steve

  • Two problems with displaying images in JPanel

    Hi,
    I need to display some small rectangular images inside a JPanel. These images also need to be componenents as they will have listeners associated with them. I have never had any experience with images, so I might totally be down the wrong path. I was thinking of just creating a class which extends JComponent, and using the graphics drawImage method. However, I don't want each image component to have to know exactly where to draw the image associated with itself. Rather, I want the JPanel which holds all of the images to know how to lay them out.
    Is there an easier way to use images?
    Which brings me to my second problem. I want these images to overlap each other, so that only a small portion of each is showing (this way I can fit more on the screen), then when the user clicks on one, I can show more of it.
    Unfortunately, I don't know of any layout managers which will allow me to overlap components. I could use the drawImage method mentioned above, but like I said, I would like to try to not have each image object try and figure out its location.
    any help is greatly appreciated. Thanks!

    Hi
    there is a better way ; it is called a JLabel ;-)
    JLabel myJLabel = new JLabel(new ImageIcon("img/myLogo.gif"));for your second problem, don't use any layout manager like in this code :
    myJPanel.setLayout(null);
    myJPanel.add(myJLabel);
    myJLabel.setBounds(new Rectangle(x, y, width, height);hope it helps
    Nico

  • Displaying images in JPanel

    Hi,
    I'm trying to work out the best method to display a set of thumbnail images in a JPanel (similar to a Thumbnail view in windows XP) - at the moment I'm using a Tree, but am wondering whether this is the best way to go about it? I'm using a tree in combination with a TreeModel but am having some problems as the cells don't expand to fit the picture size. Any ideas appreciated!!
    thanks
    Jonathan

    Why dont you use a JTable?

  • Problems displaying image in JPanel

    Hi, I've got an applet that receives a variable from a PHP page as a parameter. The variable is "map1.png" the map this variable refers to sits in the same folder as the applet.
    I want to use this variable along with getDocumentBase() to create a URL which will then be used to display an image within a jPanel called mapPane.
    the code I currently have is:
    // get image url
            String mapURL = getParameter("mapURL");
            //set variable for image
            Image map_png;
            // set media tracker
            MediaTracker mt;
            //initialise media tracker             
            mt = new MediaTracker(this);
            map_png = getImage(getDocumentBase(),mapURL);
            // tell the MediaTracker to kep an eye on this image, and give it ID 1;
            mt.addImage(map_png,1);
            // now tell the mediaTracker to stop the applet execution
            //  until the images are fully loaded.
            try
                 mt.waitForAll();
            catch (InterruptedException  e) {}
            // draw image onto mapPane
            mapPane.getGraphics().drawImage(map_png, 200, 200, null);Currently the Parameter is being passed into the applet (i've written it out within the applet) but the image is not being displayed. Does anyone have any suggestions about what I'm doing wrong?
    Cheers
    Steve

    Hello,
    after an update of the graphics card driver to the newest just released version the problem has vanished.
    Regards

  • Display Images using READ_IMAGE_FILE in 10g forms

    Hello all, i have a simple question that I'm trying to resolve really quick.
    I've created a field on a form in 10g forms that is of IMAGE type. I've given it a name and has given it a FILE_TYPE of GIF.
    I've put some code in a POST-QUERY trigger of a block that calls the READ_IMAGE_FILE command, where I enter the filename, file_type, and block.item name. When I leave the path off the image name, forms runtime acts like it cannot find it. I get an FRM message displayed at runtime that says it "Cannot read image file". However, if I put the full path (like something pointing to a hard-coded directory on my C drive where the image file resides), the image displays fine at runtime.
    I added the images to my JAR file where I have other images stored so they get opened at runtime under the ORACLE_HOME/forms/java directory. I was thinking that when I gave the filename, runtime would know to pull it out of there. But obviously, that's not what is happening.
    Has anyone got ideas on what I could do to get the READ_IMAGE_FILE to display the image without hard-coding a path in?
    Any help is appreciated!
    Regards,
    Chris

    Here are some things to check:
    1) Alll the images in the JAR file should have the same extension
    2) In formsweb.cfg, include the JAR file in the ARCHIVE parameter and set imageBase=codebase
    3) In registry.dat, leave iconpath blank and set iconextension=gif
    4) In your READ_IMAGE_FILE call, use URL as the file type and don't use the extension on the file name. So if the image in your JAR is my_picture.gif, it would be something like READ_IMAGE_FILE('my_picture','URL','myblock.my_image_item');
    If it still doesn't work, enable the Java console and when it comes up, enter the number 5 in the console to enable the highest level of logging. Then have a look at the console to see if the JAR is getting downloaded and where it's attempting to read the image from.

  • Displaying Image using JLabel in swings

    I am not understanding how to display a image in swing using JLabel Component.
    I am writing in the following manner:
    // importing necessary packages
    in init() method
    public void init()
    Container cp= getContentPane()
    JLabel jl=new JLabel("Image",new ImageIcon("<image>.gif"),JLabel.CENTER);
    cp.add(jl);
    applet is running and only label msg is displaying but not the image.
    Please help me so that i can solve this problem.where the image is to be placed??and how it has to be included?
    Please provide me the solution.

    cp.add(new JLabel("Image",new ImageIcon(new java.net.URL (getCodeBase(),"Test.gif")),JLabel.CENTER));

  • Displaying Image on JPanel

    Hello, I am having problems trying to display an image on a Panel which is attached to a Frame. I can display an Image on the Frame with no difficulty, however nothing appears when I try to draw on the Panel.
    Hope someone can help me with this.
    Here is the code
    import java.awt.*;
    import java.awt.event.*;
    class TestFrame extends Frame
         Panel panel;
         public TestFrame()
             setSize(400,400);
             panel = new Panel();
             add(panel);
         public class panel extends Panel
             Image img;
             public panel()
                 setSize(400,400);
              setVisible(true);
              img = Toolkit.getDefaultToolkit().getImage("C:\\red.gif");
             public void paint(Graphics g)
              g.drawImage(img,0,0,this);
         public static void main (String[] args)
             TestFrame f = new TestFrame();
             f.setVisible(true);
    }

    I took a look on your code and I find that 2 things might be wrong with it. See the comments below.
    import java.awt.*;
    import java.awt.event.*;
    class TestFrame extends Frame
         Panel panel;
         public TestFrame()
             setSize(400,400);
         panel = new Panel(); /****You created a Panel object from the the awt package and not an object from the panel class that you defined below. Try using panel= new panel(); or use a anonymous class for this purpose. The picture will never show because it is not using the class that you defined************/
         add(panel);
         public class panel extends Panel /*******Try giving the panel class that you defined another name so as to not confuse you with java.awt.Panel classs. ********/
         Image img;
         public panel()
         setSize(400,400);
              setVisible(true);
    img =
    =
    Toolkit.getDefaultToolkit().getImage("C:\\red.gif");
         public void paint(Graphics g)
              g.drawImage(img,0,0,this);
         public static void main (String[] args)
         TestFrame f = new TestFrame();
         f.setVisible(true);
    }Below is a panel class that i think can help. Just pass the appropriate parameters to it.
    //container class for the image panel
    public class ImagePanel extends Panel {
    Image image;
    public ImagePanel(Image image) {
    this.image = image;
    // display the image
    public void paint( Graphics g )
    // draw the original image
    g.drawImage( image, 1, 1, this );

  • How to display image using Carousel in ADF using BLOB column DB

    Hello everyone ,
    I tried creating a Carousel component in ADF do display an image , but it seems to be not working .
    This is what i tried .
    1 ) Created an empty page .
    2) From data control drag and drop view object ( one of the column in DB is blob which saves the image ) as Carousel .
    3 ) Drag and drop the image over Carousel component ,
    Now what should be the source for the image ?? from expression builderi tried giving #{item.Image} images are not picking up .
    Could you please advice .
    --Keerthi                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    Keerthi,
    You cannot display a BLOB as image as it is. You need to convert them to display in your UI.
    Check out this blog on how to use a servlet to convert the blob into image and display in the page.
    http://tompeez.wordpress.com/2011/12/16/jdev11-1-2-1-0-handling-imagesfiles-in-adf-part-3/
    -Arun
    P.S : Always mention your JDev version and the technologies used.

  • Help with displaying image using OpenGL ES sample code - image size prb

    I am using some sample code that currently displays an image 256x256 pixels. The code states the image size must be a power of 2. I have tried an image 289x289 (17^2) and it displays a square the same size as the 256x256 with a white background. I want an image 320x320 displayed. Should be obvious for people familiar with OpenGL. Here is the code which displays the image and rotates:
    - (void)setupView
    // Sets up an array of values to use as the sprite vertices.
    const GLfloat spriteVertices[] = {
    -0.5f, -0.5f,
    0.5f, -0.5f,
    -0.5f, 0.5f,
    0.5f, 0.5f,
    // Sets up an array of values for the texture coordinates.
    const GLshort spriteTexcoords[] = {
    0, 0,
    1, 0,
    0, 1,
    1, 1,
    CGImageRef spriteImage;
    CGContextRef spriteContext;
    GLubyte *spriteData;
    size_t width, height;
    // Sets up matrices and transforms for OpenGL ES
    glViewport(0, 0, backingWidth, backingHeight);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrthof(-1.0f, 1.0f, -1.5f, 1.5f, -1.0f, 1.0f);
    glMatrixMode(GL_MODELVIEW);
    // Clears the view with black
    //glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
    glClearColor(255, 255, 255, 1.0f);
    // Sets up pointers and enables states needed for using vertex arrays and textures
    glVertexPointer(2, GL_FLOAT, 0, spriteVertices);
    glEnableClientState(GLVERTEXARRAY);
    glTexCoordPointer(2, GL_SHORT, 0, spriteTexcoords);
    glEnableClientState(GLTEXTURE_COORDARRAY);
    // Creates a Core Graphics image from an image file
    spriteImage = [UIImage imageNamed:@"bottle.png"].CGImage;
    // Get the width and height of the image
    width = CGImageGetWidth(spriteImage);
    height = CGImageGetHeight(spriteImage);
    // Texture dimensions must be a power of 2. If you write an application that allows users to supply an image,
    // you'll want to add code that checks the dimensions and takes appropriate action if they are not a power of 2.
    if(spriteImage) {
    // Allocated memory needed for the bitmap context
    spriteData = (GLubyte *) malloc(width * height * 4);
    // Uses the bitmatp creation function provided by the Core Graphics framework.
    spriteContext = CGBitmapContextCreate(spriteData, width, height, 8, width * 4, CGImageGetColorSpace(spriteImage), kCGImageAlphaPremultipliedLast);
    // After you create the context, you can draw the sprite image to the context.
    CGContextDrawImage(spriteContext, CGRectMake(0.0, 0.0, (CGFloat)width, (CGFloat)height), spriteImage);
    // You don't need the context at this point, so you need to release it to avoid memory leaks.
    CGContextRelease(spriteContext);
    // Use OpenGL ES to generate a name for the texture.
    glGenTextures(1, &spriteTexture);
    // Bind the texture name.
    glBindTexture(GLTEXTURE2D, spriteTexture);
    // Speidfy a 2D texture image, provideing the a pointer to the image data in memory
    glTexImage2D(GLTEXTURE2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GLUNSIGNEDBYTE, spriteData);
    // Release the image data
    free(spriteData);
    // Set the texture parameters to use a minifying filter and a linear filer (weighted average)
    glTexParameteri(GLTEXTURE2D, GLTEXTURE_MINFILTER, GL_LINEAR);
    // Enable use of the texture
    glEnable(GLTEXTURE2D);
    // Set a blending function to use
    glBlendFunc(GL_ONE, GLONE_MINUS_SRCALPHA);
    // Enable blending
    glEnable(GL_BLEND);
    // Updates the OpenGL view when the timer fires
    - (void)drawView
    // Make sure that you are drawing to the current context
    [EAGLContext setCurrentContext:context];
    glBindFramebufferOES(GLFRAMEBUFFEROES, viewFramebuffer);
    glRotatef(direction * 3.0f, 0.0f, 0.0f, 1.0f);
    glClear(GLCOLOR_BUFFERBIT);
    glDrawArrays(GLTRIANGLESTRIP, 0, 4);
    glBindRenderbufferOES(GLRENDERBUFFEROES, viewRenderbuffer);
    [context presentRenderbuffer:GLRENDERBUFFEROES];
    }

    +I am using some sample code that currently displays an image 256x256 pixels. The code states the image size must be a power of 2. I have tried an image 289x289 (17^2)+
    The phrase "a power of 2" refers to 2^x so your choices above 256 are 512, 1024 etc.
    The texture size has nothing to do with the displayed size - OGL will stretch or shrink your texture to fit the size of the polygon you're displaying it on. I recommend you scale your image to 256x256 and work on make the polygon the size you want and work on your image quality from there.
    You can work on the size or orientation of the poly surface to make it larger but OGL doesn't support setting a model to a screen image size or anything like that. That sounds more like a Quartz or CoreGraphics kind of thing if you want to set an exact screen size to the pixel.
    HTH,
    =Tod
    PS You can display your code correctly by using { code } (without the spaces) on either side of your code block.

Maybe you are looking for