Results 1 to 9 of 9
  1. #1
    raffs03 is offline Member
    Join Date
    Sep 2012
    Posts
    41
    Rep Power
    0

    Default applet tag not working help!(netbeans)

    Java Code:
    import java.awt.*;
    import java.applet.*;
    /*
     <applet code= "ParamDemo" width=300 height=50>
     <param name= "fontName" value="Courier">
     <param name= fontSize value=14>
     <param name= leading value=2>
     <param name= accountEnabled value=true>
     </applet>
     */
    public class ParamDemo extends Applet {
        String fontName;
        int fontSize;
        float leading;
        boolean active;
        
        @Override
        public void start(){
          String param;
          fontName=getParameter("fontName");
          if(fontName == null)
              fontName = "Not Found";
          
          param = getParameter("fontSize");
          try{
              if(param != null)
                  fontSize = Integer.parseInt(param);
              else
                  fontSize = 0;
          }catch(NumberFormatException e){
              fontSize = -1;
          }
          
          param = getParameter("leading");
          try{
              if(param != null)
                  leading = Float.valueOf(param).floatValue();
              else
                  leading = 0;
          }catch(NumberFormatException e){
              leading = -1;
          }
          param = getParameter("accountEnabled");
                  if(param != null)
                      active = Boolean.valueOf(param).booleanValue();
        }
        
        @Override
        public void paint(Graphics g){
            g.drawString("Font name: "+ fontName,0,10);
            g.drawString("Font size: "+ fontSize,0,26);
            g.drawString("Leading: "+ leading,0,42);
            g.drawString("Account Active: "+ active,0,58);
        }
    }
    The output
    Java Code:
    Font name: Not Found
    Font Size: 0
    Leading: 0.0
    Account Active: false
    Looks like my applet tag doesnt recognize by netbeans
    can u help me how to resolve this? am i missing some configuration on netbeans
    or there is wrong with my code any suggestion would be appreciated

  2. #2
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,030
    Rep Power
    6

    Default Re: applet tag not working help!(netbeans)

    Sooo... you're executing this applet exactly as you posted it here? Or is that stuff you put in the comment in an actual HTML file which is being opened in a browser?

    You need to be more specific about what you're doing if you want any kind of help.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  3. #3
    raffs03 is offline Member
    Join Date
    Sep 2012
    Posts
    41
    Rep Power
    0

    Default Re: applet tag not working help!(netbeans)

    I run this code using the netbeans(run>shift+F6).I try to open my project directory and i found the generated html page but when i run it in browser it says operation block. All i want to happen is display all the parameter(param name)value that i right to my applet window.

  4. #4
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,030
    Rep Power
    6

    Default Re: applet tag not working help!(netbeans)

    In which browser? You may have to adjust your security settings, or perhaps install a more up to date version of Java. It may be that you Java plugin is outdated, browsers nowadays block that as a security threat.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  5. #5
    raffs03 is offline Member
    Join Date
    Sep 2012
    Posts
    41
    Rep Power
    0

    Default Re: applet tag not working help!(netbeans)

    I use google chrome and i update my java and still not working.. how my code will work in java dafault applet viewer i mean my code is working but the getparameter() method doesnt recognize the parameter name that i wrote in commented lines.

  6. #6
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,030
    Rep Power
    6

    Default Re: applet tag not working help!(netbeans)

    I don't know too much about applets but I can reason that if you use the applet viewer you will need to somehow configure which parameters are passed to the applet, since you have no <applet> tag in the HTML content to do that with. But perhaps it is as simple as the applet not having any getter and setter methods for those properties.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  7. #7
    raffs03 is offline Member
    Join Date
    Sep 2012
    Posts
    41
    Rep Power
    0

    Default Re: applet tag not working help!(netbeans)

    do you know how to configure the default applet viewer in netbeans? maybe i need to reconfigure the applet viewer so that the value of param name will be visible and my output will be correct but i cant find the configuration for applet viewer in netbeans T_T.

  8. #8
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,458
    Rep Power
    25

    Default Re: applet tag not working help!(netbeans)

    The code works for me with this commandline:
    D:\Java\jdk1.7.0.7\bin\Appletviewer.exe D:\JavaDevelopment\Testing\ForumQuestions9\ParamDe mo.java
    If you don't understand my response, don't ignore it, ask a question.

  9. #9
    raffs03 is offline Member
    Join Date
    Sep 2012
    Posts
    41
    Rep Power
    0

    Default Re: applet tag not working help!(netbeans)

    omg i didnt notice i have a command line XD. Thanks for the heads up norm and to gimbal2 its working now(on cmd only). I wonder why it is not working on netbeans compiler. i will do some of my applet experiment on command line for now :D

Similar Threads

  1. my netbeans has stopped working!
    By mukunzi.desire in forum NetBeans
    Replies: 3
    Last Post: 01-16-2014, 11:12 AM
  2. JMF not working from inside Netbeans
    By Stoyicker in forum NetBeans
    Replies: 2
    Last Post: 01-18-2012, 06:55 PM
  3. NetBeans IDE not working properly
    By farmer in forum NetBeans
    Replies: 2
    Last Post: 12-09-2011, 03:12 PM
  4. applet working in applet viewer, not browser
    By plasticfood in forum Java Applets
    Replies: 4
    Last Post: 06-24-2011, 06:47 PM
  5. Problem with .jar working with netbeans
    By chipimdp in forum NetBeans
    Replies: 1
    Last Post: 05-14-2010, 09:25 AM

Posting Permissions

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