Results 1 to 3 of 3
  1. #1
    amycwhitfield is offline Member
    Join Date
    Sep 2010
    Posts
    2
    Rep Power
    0

    Default Applet intermittently not loading in browser

    Hi! I'm having an issue where an applet is intermittently not loading in a browser (happens in both IE and FF). On my PC, the applet loads properly about 99% of the time. However, the applet only loads properly about 50% of the time for an end-user of the web application. We are both running Java version 6 update 21.

    It seems in the instances where the applet fails to load, the following logged in the Java Console...
    --------------------------------------------------------------
    Exception in thread "AWT-EventQueue-5" java.lang.NullPointerException: component argument pData
    at sun.java2d.windows.GDIBlitLoops.nativeBlit(Native Method)
    at sun.java2d.windows.GDIBlitLoops.Blit(Unknown Source)
    at sun.java2d.pipe.DrawImage.blitSurfaceData(Unknown Source)
    at sun.java2d.pipe.DrawImage.renderImageCopy(Unknown Source)
    at sun.java2d.pipe.DrawImage.copyImage(Unknown Source)
    at sun.java2d.pipe.DrawImage.copyImage(Unknown Source)
    at sun.java2d.pipe.ValidatePipe.copyImage(Unknown Source)
    at sun.java2d.SunGraphics2D.drawImage(Unknown Source)
    at sun.java2d.SunGraphics2D.drawImage(Unknown Source)
    at javax.swing.RepaintManager$PaintManager.paintDoubl eBuffered(Unknown Source)
    at javax.swing.RepaintManager$PaintManager.paint(Unkn own Source)
    at javax.swing.BufferStrategyPaintManager.paint(Unkno wn Source)
    at javax.swing.RepaintManager.paint(Unknown Source)
    at javax.swing.JComponent._paintImmediately(Unknown Source)
    at javax.swing.JComponent.paintImmediately(Unknown Source)
    at javax.swing.RepaintManager.paintDirtyRegions(Unkno wn Source)
    at javax.swing.RepaintManager.paintDirtyRegions(Unkno wn Source)
    at javax.swing.RepaintManager.seqPaintDirtyRegions(Un known Source)
    at javax.swing.SystemEventQueueUtilities$ComponentWor kRequest.run(Unknown Source)
    at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilter s(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(U nknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarch y(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)
    --------------------------------------------------------------

    Most of the time if the browser is refreshed then the applet will load properly, sometimes it takes more than one refresh.

    Sometimes the applet loads but is greyed out as though disabled. Refreshing the browser will usually get the applet to load properly. Though I don't see any exceptions, etc noted in the Java Console when this happens.

    Btw, the applet is actually called 'nanogong' (a miniature version of the Gong Project) and is used for audio recording/playback.

    I can provide additional details as needed.

    Any thoughts, etc as to why this could be happening would be greatly appreciated!! Thanks!

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    I'm no expert at this, but love to express my opinion. :)

    That being said, whenever I see an intermittent problem with Swing/applet code, I worry about Swing code being called off of the EDT. Are you taking pains to be sure that the Swing code is being properly called?

    Good luck!

  3. #3
    amycwhitfield is offline Member
    Join Date
    Sep 2010
    Posts
    2
    Rep Power
    0

    Default

    Your opinion is much appreciated! Sounds like a good place to start. :)

    I'm actually new to the project I'm working on so I didn't write the code myself.

    Just for reference, here's the init() method...
    -------------------------------------------------------------
    Java Code:
        
    public void init() {
        	System.out.println("init()- start");
            try {
                java.awt.EventQueue.invokeAndWait(new Runnable() {
                    public void run() {
                        initComponents();
    
                        // Initialize the button UIs
                        btnPlay.setUI(new NanoButtonUI(NanoButtonUI.PLAY));
                        btnRecord.setUI(new NanoButtonUI(NanoButtonUI.RECORD));
                        btnStop.setUI(new NanoButtonUI(NanoButtonUI.STOP));
                        btnSave.setUI(new NanoButtonUI(NanoButtonUI.SAVE));
                        slrAmplitude.setUI(new NanoAmplitudeUI(slrAmplitude));
                        btnSlow.setUI(new NanoSpeedButtonUI(NanoSpeedButtonUI.SLOW));
                        btnFast.setUI(new NanoSpeedButtonUI(NanoSpeedButtonUI.FAST));
                        slrTime.setUI(new NanoTimeUI(slrTime, NanoGong.this));
                        panWait.setVisible(false);
    
                        // Create the JLabel for time display
                        lblTime = new javax.swing.JLabel();
                        lblTime.setText("");
                        lblTime.setBackground(new java.awt.Color(1.0f, 1.0f, 1.0f, 0.8f));
                        lblTime.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.WHITE));
                        lblTime.setBounds((getWidth() - 100) / 2, 20, 100, 12);
                        lblTime.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD, 10));
                        lblTime.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
                        lblTime.setOpaque(true);
                        lblTime.setPreferredSize(lblTime.getSize());
    
                        // Add the time label to the glass pane
                        panGlassPane = (javax.swing.JPanel) getGlassPane();
                        panGlassPane.setLayout(null);
                        panGlassPane.add(lblTime);
                    }
                });
            } catch (Exception ex) {
            	System.out.println("init()- Exception in EventQueue.invokeAndWait");
                ex.printStackTrace();
            }
            
            handler.addListener(this);
            
            // Preload the sound file from the parameter
            String url = getParameter("SoundFileURL");
            try {
                url = resolveURL(url);
                handler.setURL(url);
            } catch (MalformedURLException ex) {
                handler.setURL(null);
            }
            if (url != null) {
                try {
                    SwingUtilities.invokeAndWait(new Runnable() {
                        public void run() {
                            panPanel.setVisible(false);
                            lblMessage.setText(LOADING_MESSAGE);
                            panWait.setVisible(true);
                        }
                    });
                } catch (Exception ex) {
                	System.out.println("Exception in init() - SwingUtilities.invokeAndWait");
                    ex.printStackTrace();
                }
                
                new Thread() {
                    public void run() {
                        try {
                            handler.downloadData(null, true);
                        } catch (Exception ex) {
                        	System.out.println("Exception in init() - handler.downloadData()");
                        	ex.printStackTrace();
                            JOptionPane.showMessageDialog(NanoGong.this, ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
                            handler.setURL(null);
                        }
                        SwingUtilities.invokeLater(new Runnable() {
                            public void run() {
                                panPanel.setVisible(true);
                                panWait.setVisible(false);
                            }
                        });
                    }
                }.start();
            }
            
            String value;
            
            // Read various parameters from the applet
            value = getParameter("ShowAudioLevel");
            if (value != null && value.equalsIgnoreCase("false")) slrAmplitude.setVisible(false);
            value = getParameter("ShowRecordButton");
            if (value != null && value.equalsIgnoreCase("false")) btnRecord.setVisible(false);
            value = getParameter("ShowSpeedButton");
            if (value != null && value.equalsIgnoreCase("false")) panSpeed.setVisible(false);
            value = getParameter("ShowSaveButton");
            if (value != null && value.equalsIgnoreCase("false")) btnSave.setVisible(false);
            value = getParameter("ShowTime");
            if (value != null && value.equalsIgnoreCase("true")) showTime = true;
            value = getParameter("AudioFormat");
            if (value != null && value.equals(IMA_ADPCM)) audioFormat = IMA_ADPCM;
            value = getParameter("SamplingRate");
            if (value != null) {
                try {
                    int rate = Integer.parseInt(value);
                    if (audioFormat.equals(IMA_ADPCM)) {
                        if (rate == 8000 || rate == 11025 || rate == 22050 || rate == 44100) samplingRate = rate;
                    } else {
                        if (rate == 8000 || rate == 16000 || rate == 32000 || rate == 44100) samplingRate = rate;
                    }
                } catch (NumberFormatException nfe) {}
            }
            value = getParameter("SpeexQuality");
            if (value != null) {
                try {
                    int quality = Integer.parseInt(value);
                    if (quality >= 0 && quality <= 10) speexQuality = quality;
                } catch (NumberFormatException nfe) {}
            }
            value = getParameter("Color");
            if (value != null && value.length() > 1) {
                try {
                    java.awt.Color c = new java.awt.Color(Integer.parseInt(value.substring(1), 16));
                    
                    // Change the color of all components
                    panPanel.setBackground(c);
                    btnPlay.setBackground(c);
                    btnRecord.setBackground(c);
                    btnStop.setBackground(c);
                    slrAmplitude.setBackground(c);
                    panSpeed.setBackground(c);
                    btnSlow.setBackground(c);
                    btnFast.setBackground(c);
                    lblSpeed.setBackground(c);
                    btnSave.setBackground(c);
                    slrTime.setBackground(c);
                    panWait.setBackground(c);
                    lblMessage.setBackground(c);
                    pbrWait.setBackground(c);
                } catch (NumberFormatException nfe) {
                    speexQuality = 0;
                }
            }
            value = getParameter("MaxDuration");
            if (value != null) {
                try {
                    long duration = Long.parseLong(value);
                    if (duration > 0 && duration <= 1200) maxDuration = duration * 1000;
                } catch (NumberFormatException nfe) {}
            }
            System.out.println("init()- end");
        }

Similar Threads

  1. Replies: 0
    Last Post: 06-30-2010, 11:39 AM
  2. Loading Applet in a web browser
    By techbossmb in forum Java Applets
    Replies: 2
    Last Post: 09-30-2009, 01:57 AM
  3. Loading image in applet
    By syarizma in forum Advanced Java
    Replies: 0
    Last Post: 08-06-2009, 09:02 AM
  4. loading resources in an applet
    By Gatts79 in forum Java Applets
    Replies: 5
    Last Post: 03-06-2009, 02:19 PM
  5. Why is one applet loading but the other isnít?
    By spmchugh82 in forum Java Applets
    Replies: 1
    Last Post: 01-26-2009, 03:39 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •