Calling functions of the inner class in .java code file

Hello,
I created a .java code file in Visual J#.Net and converted it into
the application by adding the "public static void main(String args[])"
function.
I have created the two classes one extends from Applet, and the other
extends from Frame. The class which I inherited from the Frame class becomes
the inner class of the class extended from the Applet. Now How do I
call the functions of the class extended from Frame class - MenuBarFrame
class. the outline code is
public class menu_show extends Applet
------init , paint action function---------
public class MenuBarFrame extends Frame
paint,action function for Menu
public static void main(String args[])
applet class instance is created
instance of frame is created
Menu , MenuBar, MenuItem instance is created
and all these objects added
I have Created MenuBarFrame class instance as
Object x= new menu_show().new MenuBarFrame
????? How to call the functions such as action of MenuBarFrame class - what
should be its parameters??????
}

Here's how I would do it:
interface Operation {
    public int op(int y);
class X {
    private int x;
    public X(int x) {
        this.x = x;
    private class Y implements Operation {
        public int op(int y) {
            return x+y;
    public Operation createOperation() {
        return new Y();
    public static void main(String[] args) {
        X app = new X(17);
        Operation f = app.createOperation();
        System.out.println(f.op(-11));
}Your code, however, has some serious "issues". You typically don't
instantiate an applet class -- that's the job of the applet viewer or Java plugin
your browser is using. If you instantiate the applet directly, you're going
to have to supply it an AppletStub. Do you really want to go that way?
Again, use an applet viewer or browser, or better yet, why write applets at all?

Similar Messages

  • How  to include the inner classes in a jar file in netbeans ide

    Dear java friends
    how to say to netbeans ide that it has to include the
    inner classes in the jar file.
    (i have one single applet class
    with two inner classes that show up
    in the build/classes file but not in the jar).
    The applet works in the viewer but not
    in the browser (I believe because the
    xxx$yyy etc should be in the jar)
    willemjav

    First, please stop posting the same question multiple times:
    Duplicate of http://forum.java.sun.com/thread.jspa?threadID=5269782&messageID=10127496#10127496
    with an answer.
    Second, If your problem is that you can't do this in NetBeans, you need to post to somewhere that provides NetBeans support - like the NetBeans website's mailing list. These forums do not support NetBeans (or any other IDE) - they are Java language forums.

  • Can I use the inner class of one containing class by the other class

    Can I use the inner class of one containing class by the other class in the same package as the containing class
    eg I have a class BST which has inner class Enumerator. Can I use the inner class from the other class in the same pacckage as BST?

    Inner classes do not share the namespace of the package of the containing class. Also they are never visible to other classes in the same package.Believe what you want, then, if you're going to make up your own rules about how Java works. For people interested in how Java actually works, here is an example that shows why that assertion is false:
    package com.yawmark.jdc;
    public class Outer {
         public class Inner {
    }And...
    package com.yawmark.demo;
    import com.yawmark.jdc.*;
    public class Demo {
         public static void main(String[] args) {
              assert new Outer().new Inner() != null;
    }~

  • Why do we go for inner classes in java?

    why cant we inherit the classes instead of having inner classes.
    what is the exact difference between the inner class and subclass.
    can anyone please explain me with some examples

    An inner class doesn't have any relationship with the outer class per se,
    except for one thing: an instantiation of the inner class can refer to the
    members of the instantiation of the outer class. One instantiation of the
    outer class can have many instantiations of the inner class 'circling
    around' it. Try to implement the following example using inheritance:public class Star {
         private String name;
         public Star(String name) { this.name= name; }
         public Planet addPlanet(String name) { return new Planet(name); }
         public class Planet {
              private String name;
              private Planet(String name) { this.name= name; }
              public Moon addMoon(String name) { return new Moon(name); }
              public class Moon {
                   private String name;
                   private Moon(String name) { this.name= name; }
                   public String toString() { return name+" (circling around "+Planet.this+")"; }
              public String toString() { return name+" (circling around "+Star.this+")"; }
         public String toString() { return name; }
         public static void main(String[] args) {
              System.out.println(new Star("sun").addPlanet("earth").addMoon("moon"));
    }kind regards,
    Jos

  • How to access the int variable in the inner class

    hi all,
    i can't access the int variable in the inner class. can any one help me
    int count = 0;
    MouseMoveListener mouseMove = new MouseMoveListener() {
         public void mouseMove(MouseEvent e) {
              count1++;
              System.out.println(count);
    };how to access count variable
    thanks

    for this how can i access the countIf the count variable is a local variable you can't access it from within the
    inner class. Make it a member variable of the outer class instead:public class Outer {
       private int count;
       MouseMoveListener mouseMove= new MouseMoveListener() {
          public void mouseMove(MouseEvent me) {
             count++;
             System.out.println(count);
    }Alternatively, if you don't need that count variable anywhere else, you
    could simply make it a member variable of the inner class itself:public class Outer {
       MouseMoveListener mouseMove= new MouseMoveListener() {
          private int count;
          public void mouseMove(MouseEvent me) {
             count++;
             System.out.println(count);
    }kind regards,
    Jos

  • When Should I use the Inner Classes ?

    When Should I use the Inner Classes ?
    What is the advantage(s) and the disadvantage(s) ?

    When I use innerclasses?
    1) Allmost allways when I need simple owner child behavior.
    2) When I need a behaviour, that is quite small, and used only once, I make it anonymous inner class. For example specialised streams and threads.
    3) Enumerations

  • How to add scroll function in  the applet launched by  Java Web Start?

    I have Java Web Start installed in order for the applet to launch.The applet size: width:700 height:1000
    my compuer resolution:800*600
    the applet launched by Java Web Start can only be seen partly,especially height.How to add scroll function in the applet launched by Java Web Start?
    Thanks for help.
    email:[email protected]

    You can very easily add a JScrollPane manually between the Applet and your content. Perhaps it would be beter if javaws did this automatically. In the browser, an applet can be any size. In Java Web Start an applet is directly contained within a JFrame, so it cannot be smaller than the minimum size of a JFrame, or Larger than the max.

  • Accessing the inner class written inside the method

    Hi all,
    Can any of you tell me how to access the inner class's method which is written inisde the outer class's method. THe code fragment is
    class Outer
    private static final int ID = 3;
    public String name;
    public void methodA( int nn )
    final int serialN = 11;
    class inner
    void showResult()
    System.out.println( "Rslt= "+ID );
    } // end class inner
    // new inner().showResult();
    } // end methodA
    class Sample
    public static void main(String a[])
    //access the showResult of Inner class??
    Thanks in advance.
    aah

    class Outer {
      private static final int ID = 3;
      public String name;
      public void methodA( int nn ) {
        final int serialN = 11;
        class inner {
          void showResult() {
            System.out.println( "Rslt= "+ID );
        } // end class inner
        new inner().showResult();
      } // end methodA
    class Sample {
      public static void main(String a[]) {
        new Outer().methodA(5);
    }

  • Update the result to client (JAVA code) aftere completing the user task

    Hi All,
    I have a simple workflow activity with in my BPEL process .
    FLOW is like this:
    1)----->Initiate/Process
    2)----->Workflow user task
    3)Approve/Reject /Others
    4)If APPROVE a call to web-service method
    5)reply
    If i got the out put as approve the next step is a call to web-service which should give the output to client(JAVA code).
    Is the above senario possible through BPEL.
    Thanks,
    Kalyan.

    HI ALL
    I fixed this problem. Problem was because of classpath. After setting the path of class file in classpath, issue was fixed.
    Regards
    Arun

  • How to isolate the Sql Statement from Java Code

    Hi
    I Need to know that can we segregate the Sql Statements and convert them to Stored Procedures so as to isolate the Sql statements from Java Code.
    So i have one static web page which uses four select Statements so what i want is to create a stored procedure encapsulating these queries. So that the Java Web Developer will simply call the Stored Procedure instead of using four different SQL Statements.
    Suppose the developer has these four Statements
    Select ename,empno,sal,job from emp;
    select empno,ename,mgr from emp;
    select deptno,dname from dept;
    select emp.ename,emp.empno,emp.deptno,dept,dname fromemp,dept;
    So can i encapsulate these four Sql Statements in one Procedure and the Web developer can call the Store procedure and dont need to write the Sql Statements in his code.
    Can Anybody guide me how to write this Stored type of Store procedure.
    Thanks

    http://www.google.com/search?q=java+windows+registry
    Next time, search yourself. It might be beyond your belief, but you're really, really not the first person to wonder about this.

  • Can I change the Jar contents trough Java code ?

    It may seems a little bit wierd, but it could solve a lot of acessibility problms....
    Can I change/set the jar contents using java code ?
    My real problem: I'm creating a EDI Client and using a XML file as configuration file. It's running well but this XML is much exposed to unauthorized users....
    Can I set a value in this XML file if it is inside a jar file ??

    you can look at class JarOutputStream . You could also use class RunTime to just create a new jar with the proper files via the normal jar command.

  • Call ODBC Data Source Administrator dialog from java code

    Hai all
    Is it possible to call "ODBC Data Source Administrator dialog " using java code.
    Tell me whether it is possible or not?
    If yes then kindly give the code please.

    try{
    Runtime.getRuntime().exec("odbcad32.exe");
    } catch(Exception e){
    e.printStackTrace();
    }or
    try{
    ProcessBuilder pb = new ProcessBuilder("odbcad32.exe");
    pb.start();
    }catch(IOException e){
      ioe.printStackTrace();
    }make sure path variable has %SystemRoot%\system32; value.
    guess both have to work... :)
    NOTE: It is OS Dependent (specially for MS WINDOWS based OS's) & the second method would work for Jdk versions of 5.0 & above..
    Hop this would be of some help :)
    REGARDS,
    RaHuL

  • How to find the  System Dbtype in java code

    How to find the System Dbtype in java code
    I need various Db connection my project (oracle, sq l,sybase,db2),So How to find the System Dbtype in java code

    Welcome to the Forums.
    Please go through the FAQ of the Forum.
    You has posted your query in the wrong Forum, this one is dedicated to Oracle Forms.
    Please try {forum:id=1050}.
    Regards,

  • Call function defined in other class

    Hi..
    I am new to Java programing .
    I want to know how to call a function defined in second class from first class.
    Please help me.

    Hi..
    If both the classes are in same package, and the function is not private, u can call the function by using an object of the second class. If they r in separate packages, u have to import the package in which the second class is. In any case, public methods are allowed and private methods are not allowed to be invoked.
    Hope this info may help u..

  • The connect function in the socket class has problems

    when i call this function connect(SocketAddress endpoint, int timeout)
    the timeout variable doesnt wait for the specific time that i tell it
    example
    connect(endpoint, 10000);
    this call should wait for this amount of time but it doesnt wait that amount
    any body has a answer ???

    yes that is exactly what I am saying
    I specify 10 sec, as 10000 milli sec's in the connect function but I get an exception almost imediately when i run my java program...
    run this code
    import java.net.*;
    public class Test
    public static void main(String [] args)
    { Socket s = null;
    int port = 2000;
    try
    s = new Socket();
    InetSocketAddress i = new InetSocketAddress("localhost",port);
    //this next line should wait 10 sec's then throw and exception
    //but it throws and exception upon running the this code
    s.connect(i,10000);
    catch(Exception e){ System.out.println(e.toString()); }
    }//main
    }//Test
    I have also tried setting the setSoTimeout(10000) in the Socket class but
    still with no success...
    I dont know why this doesnt wait 10 sec's then through an exception on it
    and when i try it with a java server it connects instantly...
    any help anyone???

Maybe you are looking for

  • Open KM Document in Portal Content Area

    Hi All, I have created a KM Document iview. I did upload 1 document in KM Repository (test.doc) and have given this path in the document iview. Now when I preview the iview......then i get a dialog box Open, Save, Cancel. On pressing Open, the doc ge

  • Exporting HD footage turns into low res pixel mess

    I have the following problem. I imported Video files into a HD 720p60 FCP timeline. Sequence settings are: HD 960x720 (16:9) compressor is HD720p60. fps accidentally is 23.98 but no sound so sync is not an issue. Now every time I try to change the se

  • Connecting iPod "What if...?" Curiosity

    Hi, I was asked by a friend today if he could leave his iPod video with me for a while so that I could plug it into my iBook and charge it up for him until he came back to get it. I was very hesitant on doing so because: a) The settings for my own pe

  • Bridge slow to open - why?

    Opening Bridge - shift/cmd/o - takes a very long time, 1min. 15secs. Before I installed Epson software it was instant. I've removed as much Epson dreck I can; is there anything else I can do?

  • Boot Camp Assistant does not work

    I just installed leopard (clean install). When I start the boot camp assistant, I just get the error message that I need to upgrade the operating system..... anybody?