Groups | Blog | Home
all groups > vj# > july 2005 >

vj# : how to instantiate the inner class.



anoop
7/16/2005 10:36:05 AM
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
instantiate the class extended from Frame 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

MenuBarframe Instance ? - How to create here? - : An explicit enclosing
instance of class 'menu_show' is needed to instantiate inner class
'MenuBarFrame'

Menu , MenuBar, MenuItem instance is created

}


David Anton
7/16/2005 2:48:02 PM
Replace "new Inner(..)" with "new Outer().new Inner(..) "
Weird syntax, but this works.

--
David Anton
www.tangiblesoftwaresolutions.com
Home of:
Instant C#: VB.NET to C# Converter
Instant VB: C# to VB.NET Converter
Instant J#: VB.NET to J# Converter


[quoted text, click to view]
David Anton
7/16/2005 8:03:37 PM

Replace "new Inner(..)" with "new Outer().new Inner(..) "
Weird syntax, but this works.



--
David Anton
------------------------------------------------------------------------
Posted via http://www.codecomments.com
------------------------------------------------------------------------


anoop
7/17/2005 1:16:02 AM
Thanks for this syntax, it works, but again there is a problem, of calling
the function "public boolean action" of the inner class. How do I call this
function.
Thanks in
advance



[quoted text, click to view]
David Anton
7/17/2005 8:07:02 AM
Once you have your new object (using the weird syntax...), just call the
method via the object.
e.g.,
InnerClassObject x = new Outer().new Inner();
x.Action();
etc.

--
David Anton
www.tangiblesoftwaresolutions.com
Home of:
Instant C#: VB.NET to C# Converter
Instant VB: C# to VB.NET Converter
Instant J#: VB.NET to J# Converter


[quoted text, click to view]
anoop
7/17/2005 8:12:01 AM
i tried it, but what should be the parameters inside the action method.

Thank you

[quoted text, click to view]
AddThis Social Bookmark Button