Results 1 to 1 of 1
Thread: APPLET dosen't works in HTML
- 12-20-2009, 06:14 PM #1
Member
- Join Date
- Dec 2009
- Posts
- 1
- Rep Power
- 0
APPLET dosen't works in HTML
1.The same code when used on Eclipse plays Audio but it dosen't in NetBeans and HTMLJava Code:public class Soft_Alphabets extends javax.swing.JApplet implements ActionListener { /** Initializes the applet Soft_Alphabets */ SoftButton chars[] = new SoftButton[26]; @Override public void init() { try { java.awt.EventQueue.invokeAndWait(new Runnable() { public void run() { initComponents(); usr_initComponents(); } }); } catch (Exception ex) { ex.printStackTrace(); } } private void usr_initComponents() { char c='A'; String ch; Image img; AudioClip aud,askd; int i=0; ch=String.valueOf(c); int loc=0,loc1=0; while(c!='[') { ch=String.valueOf(c); img=getImage(getDocumentBase(),ch+".jpg"); aud=getAudioClip(getDocumentBase(),ch+".wav") ; askd=getAudioClip(getDocumentBase(),ch+"ask.wav"); chars[i]=new SoftButton(ch,img,aud,askd); getContentPane().add(chars[i]); chars[i].addActionListener(this); chars[i].setActionCommand(ch); if(c<='M') { chars[i++].setBounds(loc,0,60,60); loc=loc+60; } else { chars[i++].setBounds(loc1,60,60,60); loc1=loc1+60; } c=(char)(c + 1); } jLabel1.setForeground(Color.RED); } public void setimage(SoftButton butt) { jLabel1.setIcon(new javax.swing.ImageIcon(butt.img)); } /** This method is called from within the init() method to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); getContentPane().setLayout(null); jLabel1.setText("Lebel1"); getContentPane().add(jLabel1); jLabel1.setBounds(140, 120, 210, 160); jLabel2.setText("HELLO AND WELCOME TO SOFT ALPHABETS"); getContentPane().add(jLabel2); jLabel2.setBounds(40, 280, 300, 20); jLabel2.getAccessibleContext().setAccessibleName("JLabel2"); }// </editor-fold>//GEN-END:initComponents // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; // End of variables declaration//GEN-END:variables public void actionPerformed(ActionEvent e) { int i; for(i=0;i<26;i++) { if(chars[i].ch.equals(e.getActionCommand())) break; } ImageIcon icon=new ImageIcon(chars[i].ch+".JPEG"); //ImageIcon icon=new ImageIcon(getCodeBase()+"Data/"+chars[i].ch+".JPEG"); //ImageIcon icon=new ImageIcon((getCodeBase()+ chars[i].ch+".jpg").substring(5)); //setimage(chars[i]); jLabel1.setIcon(icon); jLabel2.setText("You Pressed "+chars[i].ch); //jLabel1.setIcon(new javax.swing.ImageIcon((getCodeBase()+ chars[i].ch+".jpg").substring(5))); repaint(); //chars[i].audio.play(); } }
2.Also when I embed it in HTML No action is performed on click of a button which works well in NetBeans
3.Also I want to know How can I update images in JLabel if possible can somebody provide me with snippet
Similar Threads
-
Two Form Applet in html
By barusk in forum Java AppletsReplies: 0Last Post: 03-16-2009, 05:36 PM -
Applet works on Windows, Ubuntu and Mac, but not on Redhat and Fedora
By bhaskar_e in forum AWT / SwingReplies: 6Last Post: 10-22-2008, 05:05 PM -
Signed applet works only with jre 1.6u10 beta...
By smartizzz in forum Java AppletsReplies: 0Last Post: 08-07-2008, 07:54 AM -
Java Applet HTML
By ownlol in forum Java AppletsReplies: 4Last Post: 07-21-2008, 02:59 AM -
Chat Applet in HTML
By Flynazn in forum Java AppletsReplies: 3Last Post: 05-27-2008, 09:26 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks