Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: problem with applet

  1. #1
    Junior Member
    Join Date
    Mar 2013
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default problem with applet

    I have problem with this applet. the browser gives page.I don't know wether its not loading or if its extremely slow.Also I am confused on the html part.Should I use tag object or applet and for entering class name data,classid or name.

    import java.lang.reflect.InvocationTargetException;
    public class NewJApplet extends javax.swing.JApplet {
        @Override
        public void init() {
            this.add(fesText);
            this.add(jButton1);
            this.add(jLabel1);
            this.add(jLabel2);
            this.add(jPanel1);
            this.add(jPanel2);
            this.add(msgText);
            this.add(jScrollPane1);
            try {
                java.awt.EventQueue.invokeAndWait(new Runnable() {
                    @Override
                    public void run() {
                        initComponents();
                    }
                });
            } catch (InterruptedException | InvocationTargetException ex) {
            }
        }
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
            switch(fesText.getText().toLowerCase()){
                case "christmas":
                    msgText.setText("HAPPY CHRISTMAS");
                    break;
                case "diwali":
                    msgText.setText("HAPPY DIWALI");
                    break;
                default:
                    msgText.setText("ENTER VALID FESTIVAL");
                    break;
            }
        private javax.swing.JTextField fesText;
        private javax.swing.JButton jButton1;
        private javax.swing.JLabel jLabel1;
        private javax.swing.JLabel jLabel2;
        private javax.swing.JPanel jPanel1;
        private javax.swing.JPanel jPanel2;
        private javax.swing.JScrollPane jScrollPane1;
        private javax.swing.JTextArea msgText;
    html tag:-
    <!DOCTYPE html>
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    </head>
    <body>
    <div><object data="JApplet.class" height="170" width="150"></object></div>
    </body>
    </html>

    --- Update ---

    Sorry missed a word the browser gives a blank page
    Last edited by Norm; September 30th, 2014 at 08:03 AM. Reason: Added missing ] on code tag


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: problem with applet

    Your classname is NewJApplet.

    See the tutorial: http://docs.oracle.com/javase/tutori...plet/html.html
    If you don't understand my answer, don't ignore it, ask a question.

  3. The Following User Says Thank You to Norm For This Useful Post:

    GregBrannon (September 30th, 2014)

  4. #3
    Junior Member
    Join Date
    Mar 2013
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: problem with applet

    Hey I corrected the name.is that what the tutorial is for,please specify.Anyways the program still opens in Mozilla to give a blank page are there any other problems.Also,where should I place the document,there are four folders,build,dist,src and nbproject

  5. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: problem with applet

    Are there any error messages in the browser's Java Console.

    where should I place the document
    Copy the html file and the class file(s) to a folder of your choice.
    If you don't understand my answer, don't ignore it, ask a question.

  6. #5
    Junior Member
    Join Date
    Mar 2013
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: problem with applet

    no there are no errors shown I dont know why this isnt working this is my first applet.Anyways java plugins cause the problem i have the plugin enabled in the browser.

  7. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: problem with applet

    what the tutorial is for,
    It's to help you understand how to write and execute an applet.

    If there are no error messages, it's hard to know what is wrong.

    Try opening the html file in the AppletViewer tool that comes with the JDK. See if it gives some messages.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Tell me the Problem in that java Applet
    By maz3r in forum Java Applets
    Replies: 5
    Last Post: August 20th, 2012, 11:23 AM
  2. Applet loop problem
    By bluecora in forum Loops & Control Statements
    Replies: 6
    Last Post: June 14th, 2012, 12:54 PM
  3. Problem Applet Error
    By mohsendeveloper in forum Java SE APIs
    Replies: 24
    Last Post: January 19th, 2012, 04:00 PM
  4. Applet problem with MouseEvent
    By smashX in forum What's Wrong With My Code?
    Replies: 5
    Last Post: April 10th, 2011, 03:24 PM
  5. Problem with my animation applet
    By cBlue in forum Java Applets
    Replies: 1
    Last Post: December 9th, 2009, 07:49 PM