Jbutton in applet not appearing when embedded in webpage(jre1.6.0_02)

Hi,
I am accessing a webcam from an applet embedded in a webpage using JMF 2.1. I am using JButtons using Image Icons. When i view the applet using applet viewer both the player and buttons appear fine. However when the applet is embedded in a jsp page the image JButtons don't appear at all. I am using jre1.6.0_02.
Following is the code( The capture and cancel JButtons dont appear when viewed in webpage):
import java.awt.*;
import java.io.*;
//import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.*;
import java.net.URL;
import java.net.URLConnection;
import javax.media.format.*;
import javax.media.control.*;
import javax.media.util.*;
import javax.media.*;
import javax.swing.ImageIcon;
import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import com.sun.image.codec.jpeg.JPEGCodec;
import com.sun.image.codec.jpeg.JPEGEncodeParam;
import com.sun.image.codec.jpeg.JPEGImageEncoder;
public class WebCamUnit extends JApplet implements ActionListener
     static final long serialVersionUID = -116069779446114664L;
     private static final String FILENAME_HEADER = "fileName";
     private static final String FILELASTMOD_HEADER = "fileLastMod";
     public static Player player = null;
     public CaptureDeviceInfo captureDeviceInfo = null;
     public MediaLocator ml = null;
     public JButton captureButton, cancelButton = null;
     public Buffer buf = null;
     public Image img = null;
     public VideoFormat vf = null;
     public BufferToImage btoi = null;
     public Component comp;
     public static boolean isTrue = true;
     public JPanel buttonPanel, playerPanel;
     public static String localDirectoryName = null;
     public static String serverDirectoryName = null;
     public static String servletURL = null;
     public static String localImageName = null;
     public static String serverImageName = null;
     String webCamDriverName = null;
     String middleButtonFilename = "TakePicture.JPG";
     String frontButtonFilename = "Cancel.JPG";
     public void init()
          localImageName = getParameter("LOCAL_IMAGE_NAME");
          serverImageName = getParameter("SERVER_IMAGE_NAME");
          localDirectoryName = getParameter("LOCAL_DIRECTORY_NAME");
          serverDirectoryName = getParameter("SERVER_DIRECTORY_NAME");
          servletURL = getParameter("SERVLET_URL");
          webCamDriverName = getParameter("WEBCAM_DRIVER_NAME");
          setLayout(new BorderLayout());
          setSize(320, 340);
          ImageIcon middleButtonIcon = new ImageIcon(middleButtonFilename);
          ImageIcon frontButtonIcon = new ImageIcon(frontButtonFilename);
          captureButton = new JButton(middleButtonIcon);
          cancelButton = new JButton(frontButtonIcon);
          captureButton.setBackground(Color.WHITE);
          captureButton.setContentAreaFilled(false);
          captureButton.setBorderPainted(false);
          captureButton.setFocusPainted(false);
          captureButton.addActionListener(this);
          captureButton.setEnabled(true);
          cancelButton.setBackground(Color.WHITE);
          cancelButton.setContentAreaFilled(false);
          cancelButton.setBorderPainted(false);
          cancelButton.setFocusPainted(false);
          cancelButton.addActionListener(this);
          cancelButton.setEnabled(true);
          buttonPanel = new JPanel();
          buttonPanel.add(captureButton);
          buttonPanel.add(cancelButton);
          buttonPanel.setBackground(Color.WHITE);
          getContentPane().add(buttonPanel, BorderLayout.CENTER);
          if(null==webCamDriverName)
               webCamDriverName = "vfw:Microsoft WDM Image Capture (Win32):2";
          captureDeviceInfo = CaptureDeviceManager.getDevice(webCamDriverName);
          ml = captureDeviceInfo.getLocator();
               try
                    player = Manager.createRealizedPlayer(ml);
               catch (Exception e)
               try
                    player.start();
               catch (Exception e)
     public void destroy()
          player.close();
     public void start()
          try
               if ((comp = player.getVisualComponent()) != null)
                    playerPanel = new JPanel();
                    comp.setBounds(0, 0, 320, 240);
                    playerPanel.add(comp);
                    getContentPane().add(playerPanel, BorderLayout.NORTH);
               player.start();
          catch (Exception e)
          setVisible(true);
          invalidate();
          repaint();
     public boolean action(Event e, Object o)
          return true;
     public void paint(Graphics g)
          super.paint(g);
     public static void playerclose()
          player.close();
          player.deallocate();
     public void actionPerformed(ActionEvent e)
          JComponent c = (JComponent) e.getSource();
          if (c == captureButton)
               player.stop();
               FrameGrabbingControl fgc = (FrameGrabbingControl) player
                         .getControl("javax.media.control.FrameGrabbingControl");
               buf = fgc.grabFrame();
               btoi = new BufferToImage((VideoFormat) buf.getFormat());
               img = btoi.createImage(buf);
               String newDir = localDirectoryName;
               boolean success = (new File(newDir)).mkdirs();
               String imageServername = localDirectoryName + localImageName;
               saveJPG(img, imageServername);
               isTrue = false;
          else
               if ((comp = player.getVisualComponent()) != null)
                    getContentPane().add(comp, BorderLayout.NORTH);
                    player.start();
               isTrue = true;
     public void stop()
          player.stop();
          player.deallocate();
          getContentPane().removeAll();
     public static void saveJPG(Image img, String s)
          img = img.getScaledInstance(160, 120, 1);
          BufferedImage bi = new BufferedImage(img.getWidth(null), img
                    .getHeight(null), BufferedImage.TYPE_INT_RGB);
          Graphics2D g2 = bi.createGraphics();
          g2.drawImage(img, 0, 0, null, null);
          FileOutputStream out = null;
          try
               out = new FileOutputStream(s);
          catch (java.io.FileNotFoundException io)
               String message = "File Not Found";
               JOptionPane pane = new JOptionPane(message);
               JDialog dialog = pane.createDialog(new JFrame(), "Dilaog");
               dialog.show();
          JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
          JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(bi);
          param.setQuality(0.50f, false);
          encoder.setJPEGEncodeParam(param);
          try
               encoder.encode(bi);
               out.close();
               try
               transferFile(localDirectoryName+localImageName,serverImageName,"",-1);
               catch (Exception e1)
                    String message = "Error occurred while transferring image to server!!";
                    JOptionPane pane = new JOptionPane(message);
                    JDialog dialog = pane.createDialog(new JFrame(), "Dilaog");
                    dialog.show();
               String message = "Image saved successfully!!";
               JOptionPane pane = new JOptionPane(message);
               JDialog dialog = pane.createDialog(new JFrame(), "Dilaog");
               dialog.show();
          catch (java.io.IOException io)
               String message = "Error occurred while saving image!!";
               JOptionPane pane = new JOptionPane(message);
               JDialog dialog = pane.createDialog(new JFrame(), "Dilaog");
               dialog.show();
          catch (Exception e)
        // this method transfers the prescribed file to the server.
        // if the destination directory is "", it transfers the file to      "d:\\".
        //11-21-02 Changes : This method now has a new parameter that references the item
        //that is being transferred in the import list.
        public static String transferFile(String srcFileName, String
     destFileName,
                                          String destDir, int itemID)
           if (destDir.equals(""))
              destDir = serverDirectoryName;
           // get the fully qualified filename and the mere filename.
           String fqfn = srcFileName;
           String fname = fqfn.substring(fqfn.lastIndexOf(File.separator)+1);
           try
              //importTable importer = jbInit.getImportTable();
              // create the file to be uploaded and a connection to      servlet.
              File fileToUpload = new File(fqfn);
              long fileSize = fileToUpload.length();
              // get last mod of this file.
              // The last mod is sent to the servlet as a header.
              long lastMod = fileToUpload.lastModified();
              String strLastMod = String.valueOf(lastMod);
              URL serverURL = new URL(servletURL);
              URLConnection serverCon = serverURL.openConnection();
              // a bunch of connection setup related things.
              serverCon.setDoInput(true);
              serverCon.setDoOutput(true);
              // Don't use a cached version of URL connection.
              serverCon.setUseCaches (false);
              serverCon.setDefaultUseCaches (false);
              // set headers and their values.
              serverCon.setRequestProperty("Content-Type",
                                           "application/octet-stream");
              serverCon.setRequestProperty("Content-Length",
              Long.toString(fileToUpload.length()));
              serverCon.setRequestProperty(FILENAME_HEADER, destDir + destFileName);
              serverCon.setRequestProperty(FILELASTMOD_HEADER, strLastMod);
             // if (webadminApplet.DEBUG) System.out.println("Connection with FTP server established");
              // create file stream and write stream to write file data.
              FileInputStream fis = new FileInputStream(fileToUpload);
              OutputStream os = serverCon.getOutputStream();
              try
                 // transfer the file in 4K chunks.
                 byte[] buffer = new byte[4096];
                 long byteCnt = 0;
                 //long percent = 0;
                 int newPercent = 0;
                 int oldPercent = 0;
                 while (true)
                    int bytes = fis.read(buffer);
                    byteCnt += bytes;
                    //11-21-02 :
                    //If itemID is greater than -1 this is an import file      transfer
                    //otherwise this is a header graphic file transfer.
                    if (bytes < 0) break;
                    os.write(buffer, 0, bytes);
                 os.flush();
                 //if (webadminApplet.DEBUG) System.out.println("No of bytes sent: " + byteCnt);
              finally
                 // close related streams.
                 os.close();
                 fis.close();
             // if (webadminApplet.DEBUG) System.out.println("File Transmission complete");
              // find out what the servlet has got to say in response.
              BufferedReader reader = new BufferedReader(
                             new
     InputStreamReader(serverCon.getInputStream()));
              try
                 String line;
                 while ((line = reader.readLine()) != null)
                   // if (webadminApplet.DEBUG) System.out.println(line);
              finally
                 // close the reader stream from servlet.
                 reader.close();
           } // end of the big try block.
           catch (Exception e)
              System.out.println("Exception during file transfer:\n" + e);
              e.printStackTrace();
              return("FTP failed. See Java Console for Errors.");
           }  // end of catch block.
           return("File: " + fname + " successfully transferred.");
        }  // end of method transferFile().
}

>
I am accessing a webcam from an applet embedded in a webpage using JMF 2.1. I am using JButtons using Image Icons. When i view the applet using applet viewer both the player and buttons appear fine. However when the applet is embedded in a jsp page the image JButtons don't appear at all. >That is probably because of security. Add 10 Dukes to the thread to indicate you are serious about resolving this, and I might expand on that answer.

Similar Messages

  • Some CGM graphics do not appear when FrameMaker files are converted to PDF

    CGM files are exported from ISO (Arbortext Isodraw 7.0 CadProcess) files. Then they are imported into Adobe FrameMaker 7.2, where all elements of the illustration are visible and can be printed. The FrameMaker FM file is converted to a PDF file using the Adobe PDF converter function of Frame. When the PDF file is opened by Adobe Acrobat 8,0 Professional, some, but not all of the illustrations in the file exhibit this problem (The callouts and other text may appear, but the lines, curves, etc. do not). The illustration prints the same way it appears on the screen. When exporting the ISO file as a CGM, the following selections are made.
    When importing file into Frame, "Import by Reference" is selected.
    When creating PDF in Frame, the following selections are made.
    Any Suggestions would be greatly appreciated. Thanks very much.

    Thanks, Michael.
    I will give it a try.
    Avox Systems Web Site: http://www.avoxsys.com
    AVOX SYSTEMS
    AIRCRAFT SYSTEMS
    Rick Barusic
    Senior Technical Writer
    225 Erie Street - Lancaster, NY 14086 - USA
    Tel: 716-686-1706
    [email protected]
    http://www.zodiacaerospace.com
    The information transmitted is intended only for the person or entity to
    which it is addressed and may contain confidential and/or privileged
    material. Any review, retransmission, dissemination, or other use of or
    taking any action in reliance upon this information by persons or entities
    other than the intended recipient is prohibited. If you received this in
    error, please contact the sender and delete the material from any
    computer.
    From:   MichaelKazlow <[email protected]>
    To:     rick barusic <[email protected]>
    Date:   11/24/2010 10:32 PM
    Subject:        Some CGM graphics do not appear when
    FrameMakerfiles are converted to PDF
    First you should update to the latest version of Acrobat 8, since you say
    you are running Acrobat 8, you should update to 8.2.5. Update your
    FrameMaker to 7.2p158. Those two steps might do the trick. If that fails
    try using a different settings file. Perhaps High Quality or Press
    Quality. I would never use Standard for anything where fidelity is
    important.

  • When I plug in iPhone (5.1.1) to computer, playlists show up on the iPhone (when plugged in), that do not appear when it is not plugged in. And I can't erase them. I have iTunes match, and deleted all my music on the iPhone, but that had no effect.

    When I plug in iPhone (5.1.1) to computer, playlists show up on the iPhone (when plugged in), that do not appear when it is not plugged in. And I can't erase them. I have iTunes match, and deleted all my music on the iPhone, but that had no effect on the phantom playlist that shows up on the PC when I plug in the iPhone to the PC. I cannot manually move songs or playlists from the PC to the iPhone
    Help greatly appreciated.

    Unplug your Iphone out of your computer and replug it back in. It took me several times before I could do this

  • Some of my contact names are not appearing when they text message me.  They are just showing up as their numbers. I have them saved in my phone so i am not really sure why their names aren't showing up when they message me?

    some of my contact names are not appearing when they text message me.  They are just showing up as their numbers. I have them saved in my phone so i am not really sure why their names aren't showing up when they message me?

    I have this identical problem.  For a while my group texts didnt show up on my ipad.  Then one day they did, maybe everyone in the group started using the same os version or something.  Ever since my first reply to the group there have been complaints of multiple threads.  I can not find a pattern for when my group text's decide they want to create a new thread. (it doesnt happen every time)  Everyone in the group has deleted the thread, we've all toggled imessage on/off etc.  There still hasn't been a solution.
    Any help would be appreciated.
    Thanks

  • Since my last firefox update, I have been unable to type an email - the text box does not appear when I press 'reply' , or press 'compose'. The email provider is '123-reg.co.uk. I have been using both firefox and the provider ['webfusion Ltd/webmail123] s

    Hello. Since my last firefox update, I have been unable to type an email - the box within which one would usually type does not appear when I press 'reply' to a received email, or press 'compose'. The email provider is '123-reg.co.uk. I have been using both firefox and the provider ['webfusion Ltd/webmail123] successfully for well over a year. The provider says it is a browser problem. I can still add an attachment to the email header, which successfully can be sent, but the recipient gets my standard email 'signature' with font messages and the attachment. Can anyone help? My email addresses are [email protected] [this is the one with the issue] and [email protected] in English
    == today

    My daughter has had her Razr for about 9 months now.  About two weeks ago she picked up her phone in the morning on her way to school when she noticed two cracks, both starting at the camera lens. One goes completely to the bottom and the other goes sharply to the side. She has never dropped it and me and my husband went over it with a fine tooth comb. We looked under a magnifying glass and could no find any reason for the glass to crack. Not one ding, scratch or bang. Our daughter really takes good care of her stuff, but we still wanted to make sure before we sent it in for repairs. Well we did and we got a reply from Motorola with a picture of the cracks saying this was customer abuse and that it is not covered under warranty. Even though they did not find any physical damage to back it up. Well I e-mailed them back and told them I did a little research and found pages of people having the same problems. Well I did not hear from them until I received a notice from Fed Ex that they were sending the phone back. NOT FIXED!!! I went to look up why and guess what there is no case open any more for the phone. It has been wiped clean. I put in the RMA # it comes back not found, I put in the ID #, the SN# and all comes back not found. Yet a day earlier all the info was there. I know there is a lot more people like me and all of you, but they just don't want to be bothered so they pay to have it fix, just to have it do it again. Unless they have found the problem and only fixing it on a customer pay only set up. I am furious and will not be recommending this phone to anyone. And to think I was considering this phone for my next up grade! NOT!!!!

  • My Songs in my Ipod Touch 4 is not appearing when I tried to Play it but when i insert to my PC and use Itunes, songs,playlist appears in I tunes.What do I need to do?Can someone help me?Many thanks

    My Songs in my Ipod Touch 4 is not appearing when I tried to Play it but when i insert to my PC and use Itunes, songs,playlist appears in I tunes.What do I need to do?Can someone help me?Many thanks

    Try:
    - Another cable
    - iOS: Not responding or does not turn on
    - Also try DFU mode after try recovery mode
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings
    - If not successful and you can't fully turn the iOS device fully off, let the battery fully drain. After charging for an least an hour try the above again.
    - Try on another computer          
    - If still not successful that usually indicates a hardware problem and an appointment at the Genius Bar of an Apple store is in order.
    Apple Retail Store - Genius Bar       

  • How do I know if private browsing is working? The purple mask does not appear when I click the mask icon. In my privacy settings "Never Remember" is selected.

    I'm trying to confirm private browsing is working. Right now I have no way of knowing if it is on or not. The purple mask ,referred to in help, does not appear when selected. I should say in my privacy settings, I have selected "Never Remember" for history.

    Do you mean you have checked the box: "Always use private browsing mode"? If so, it's intentional that the private browsing icon isn't displayed as we didn't want Firefox to be showing everyone within view that you're using private browsing mode IIRC.
    There are some easy things you can do to confirm that you are in private browsing mode such as visiting a new website and then confirming it doesn't appear in the history window.

  • For some artists in my Music app on my I-phone, the songs do not appear when I search by the artist.  However, if I search the album name, all the songs show.  How do I get the songs to show under songs?

    For some artists in my Music app on my I-phone, the songs do not appear when I search by the artist.  However, if I search the album name, all the songs show.  How do I get the songs to show under songs?

    Hi Spam_Valley,
    I understand that you are having issues with your music displaying correctly. This may be an issues with the metadata stored within that song, and iTunes interpretation of that info.
    We may need to repair this. See the following resources for information:
    iTunes 10 for Windows: If song titles don’t appear correctly
    http://support.apple.com/kb/PH1468
    Fixing Incorrect Song or Album Listings in iTunes
    http://support.apple.com/kb/TA24677
    Thanks,
    Matt M.

  • The navigation menu does not appear when published to folder and my 12 photos are not on the site either

    The navigation menu does not appear when published to a file.  My 12 photos are also absent as well, just as if they wernt added.
    I have tried rebuilding the site but the same problem appears.  Everything else seems perfect up to tha publidhed file.
    Has anyone had the same problem,
    John
    Message was edited by: BOURBAH

    Have you tried: Trouble installing iTunes or QuickTime for Windows or iTunes for Windows Vista or Windows 7: Troubleshooting ...

  • The navigation menu does not appear when published to folder and my 12 photos arenot on the site eitherr

    The navigation menu does not appear when published to a file.  My 12 photos are also absent as well, just as if they wernt added.
    I have tried rebuilding the site but the same problem appears.  Everything else seems perfect up to tha publidhed file.
    Has anyone had the same problem,
    John

    Have you tried: Trouble installing iTunes or QuickTime for Windows or iTunes for Windows Vista or Windows 7: Troubleshooting ...

  • I am unable to work on docs in adobe as the toolbar does not appear when I tap on the doc.

    how do I get my adobe to work? I open the doc in adobe but cant work on the doc. the toolbar does not appear when I tap in the middle. All contact us help leads to nowhere. the e mails from support cant be replied to. is there another app that one couls use to download doc and actually be able to work on them?

    What is your operating system?
    What is your Reader version?
    Are these local or online documents?  If online, in what browser?

  • Images on Facebook do not appear when using different web browsers

    Images on Facebook do not appear when using Safari on my Macbook Pro (I've tried Google Chrome too with the same result).  This makes me think it's a setting within OS Mavericks that I'm missing.  I have not seen this issue on any other computers.  This only occurs on my, and others' profile pictures on my profile page and on the news feed, not photos that are posted in albums or on walls.  and yes, i have images enabled in Safari.
    In safari the images don't appear, and in their place is a small blue "?" square >>.
    In Chrome it appears as a broken image link >>
    Has anyone encountered this?  Is there a fix?  It is very annoying.

    Please read this whole message before doing anything.
    This procedure is a diagnostic test. It’s unlikely to solve your problem. Don’t be disappointed when you find that nothing has changed after you complete it.
    The purpose of the test is to determine whether the problem is caused by third-party software that loads automatically at startup or login, by a peripheral device, or by corruption of certain system caches. 
    Disconnect all wired peripherals except those needed for the test, and remove all aftermarket expansion cards. Boot in safe mode and log in to the account with the problem. Note: If FileVault is enabled on some models, or if a firmware password is set, or if the boot volume is a software RAID, you can’t do this. Ask for further instructions.
    Safe mode is much slower to boot and run than normal, and some things won’t work at all, including sound output and  Wi-Fi on certain models. The next normal boot may also be somewhat slow.
    The login screen appears even if you usually log in automatically. You must know your login password in order to log in. If you’ve forgotten the password, you will need to reset it before you begin. Test while in safe mode. Same problem? After testing, reboot as usual (i.e., not in safe mode) and verify that you still have the problem. Post the results of the test.

  • Contact names do not appear when composing an email

    When I click to compose an email, names of my contacts do not appear when I start typing ...only email addresses...and they look shaded out.  I have gone into contacts and confirmed that names are all correct, and looked through other discussions, but usually this seems to happen with text messages.  I don't ahve a problem with the contact names appearing when I text...only when I try to compose a message.  Its very annoying because I don't always remember people's email - I'd like to just start typing their name and ahve the contact appear.  Iphone 5.

    Hi there basecampmason,
    I would recommend force closing all open apps and resetting the device as an initial troubleshooting step. Take a look at the articles below for more information.
    iOS: Force an app to close
    http://support.apple.com/kb/ht5137
    iPhone, iPad, iPod touch: Turning off and on (restarting) and resetting
    http://support.apple.com/kb/ht1430
    -Griff W.

  • Photos in 9.2 do not appear when viewed through screen sharing

    I recently upgraded my Mac Mini, which stores my master iPhoto library, to iPhoto 9.2.  Because this Mac Mini is also used as a media server for an AppleTV, I almost always operate the computer through screen sharing using a MacBook Pro, rather than connecting it to a television. Both computers are running OS 10.6.8.
    Since upgrading this setup to iPhoto 9.2, I can no longer view photos in my iPhoto library through screen sharing. Previously, I had noticed that I could not view certain other things through screen sharing (such as watching DVD's).  For example, I couldn't view individual photos in detail in iPhoto, but I could view them in grid view. Now I cannot even view them in grid view anymore.
    Is there a graphics library that is not compatible with screen sharing that is now being completely used by iPhoto?  Is there a setting that I can check?  Any help would be greatly appreciated.

    Thanks, Michael.
    I will give it a try.
    Avox Systems Web Site: http://www.avoxsys.com
    AVOX SYSTEMS
    AIRCRAFT SYSTEMS
    Rick Barusic
    Senior Technical Writer
    225 Erie Street - Lancaster, NY 14086 - USA
    Tel: 716-686-1706
    [email protected]
    http://www.zodiacaerospace.com
    The information transmitted is intended only for the person or entity to
    which it is addressed and may contain confidential and/or privileged
    material. Any review, retransmission, dissemination, or other use of or
    taking any action in reliance upon this information by persons or entities
    other than the intended recipient is prohibited. If you received this in
    error, please contact the sender and delete the material from any
    computer.
    From:   MichaelKazlow <[email protected]>
    To:     rick barusic <[email protected]>
    Date:   11/24/2010 10:32 PM
    Subject:        Some CGM graphics do not appear when
    FrameMakerfiles are converted to PDF
    First you should update to the latest version of Acrobat 8, since you say
    you are running Acrobat 8, you should update to 8.2.5. Update your
    FrameMaker to 7.2p158. Those two steps might do the trick. If that fails
    try using a different settings file. Perhaps High Quality or Press
    Quality. I would never use Standard for anything where fidelity is
    important.

  • The "info" button does not appear when trying to sync in iTunes.

    The "info" button does not appear when trying to sync in iTunes. It used to, but no longer does. Anybody?

    Sync Services (which iTunes uses for the Info button) was removed in Mavericks.
    Sync Contacts & Calendars via iCloud.
    -> http://support.apple.com/kb/PH12117?viewlocale=en_US&locale=en_US

Maybe you are looking for