PC Review


Reply
Thread Tools Rate Thread

C# analog's of Java classes

 
 
TomC
Guest
Posts: n/a
 
      16th Dec 2006
Is there any resource where someone who is familiar with Java might
find which .NET classes are similar to classes they are familiar with
in Java? For example, I have a project that I'd like to tackle as a
learning project. In Java, I'd subclass the Panel or JPanel class. Is
there someplace where a Java programmer who is learning C# could
quickly find out what the analog for those classes are?

 
Reply With Quote
 
 
 
 
=?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
Guest
Posts: n/a
 
      17th Dec 2006
Import your .java class files into Visual Studio, which will use the JLCA to
translate them to J#.
Now they are .NET classes.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com




"TomC" wrote:

> Is there any resource where someone who is familiar with Java might
> find which .NET classes are similar to classes they are familiar with
> in Java? For example, I have a project that I'd like to tackle as a
> learning project. In Java, I'd subclass the Panel or JPanel class. Is
> there someplace where a Java programmer who is learning C# could
> quickly find out what the analog for those classes are?
>
>

 
Reply With Quote
 
TomC
Guest
Posts: n/a
 
      17th Dec 2006
I'm not trying to convert an existing Java application. I'm trying to
learn C#, and I have an idea of something that I'd like to attempt as a
learning project.

I know what I would do if I was writing it in Java, but I don't want to
write it in Java first and then let some tool convert it to .NET. I
want to write it in C#. But to do that, I need some way to figure out
which library classes in .NET would be somewhat analogous to the
library classes that I'd use in Java.

Peter wrote:
> Import your .java class files into Visual Studio, which will use the JLCA to
> translate them to J#.
> Now they are .NET classes.
> Peter
>
> --
> Co-founder, Eggheadcafe.com developer portal:
> http://www.eggheadcafe.com
> UnBlog:
> http://petesbloggerama.blogspot.com
>
>
>
>
> "TomC" wrote:
>
> > Is there any resource where someone who is familiar with Java might
> > find which .NET classes are similar to classes they are familiar with
> > in Java? For example, I have a project that I'd like to tackle as a
> > learning project. In Java, I'd subclass the Panel or JPanel class. Is
> > there someplace where a Java programmer who is learning C# could
> > quickly find out what the analog for those classes are?
> >
> >


 
Reply With Quote
 
Lucian Wischik
Guest
Posts: n/a
 
      17th Dec 2006
"TomC" <(E-Mail Removed)> wrote:
>I know what I would do if I was writing it in Java, but I don't want to
>write it in Java first and then let some tool convert it to .NET. I
>want to write it in C#. But to do that, I need some way to figure out
>which library classes in .NET would be somewhat analogous to the
>library classes that I'd use in Java.


My impression is that Java likes to use inheritance a heck of a lot,
and .net tends to use it less. Quite commonly you never even inherit
any classes yourself -- you use events instead.

(although if you were writing a component yourself then you do end up
writing more inheritance yourself).

So, it's hard to answer in isolation what is the equivalent of a java
panel. Instead you should describe the problem you're trying to solve,
(and maybe describe how you architected it in java), and then see what
people answer for most typical way to do it in .net.

--
Lucian
 
Reply With Quote
 
TomC
Guest
Posts: n/a
 
      17th Dec 2006

Lucian Wischik wrote:
> "TomC" <(E-Mail Removed)> wrote:
> >I know what I would do if I was writing it in Java, but I don't want to
> >write it in Java first and then let some tool convert it to .NET. I
> >want to write it in C#. But to do that, I need some way to figure out
> >which library classes in .NET would be somewhat analogous to the
> >library classes that I'd use in Java.

>
> My impression is that Java likes to use inheritance a heck of a lot,
> and .net tends to use it less. Quite commonly you never even inherit
> any classes yourself -- you use events instead.
> (although if you were writing a component yourself then you do end up
> writing more inheritance yourself).


In this case, I don't see any way to get around using inheritance.
What I want to do is create a custom visual display, so I need to
customize some sort of object that can be displayed visually.

> So, it's hard to answer in isolation what is the equivalent of a java
> panel. Instead you should describe the problem you're trying to solve,
> (and maybe describe how you architected it in java), and then see what
> people answer for most typical way to do it in .net.


OK. Here is an idea that is similar to what I want to do, but more
familiar than my project would be.

Imagine that I was creating a virtual checkerboard class. What I'm
trying to do would be similar to creating a class that represents an
individual square on the checkerboard. It needs to have the the
ability to draw on itself, so I can program it to draw things that look
like checkers, chess pieces, and possibly other images within its
border. By tiling them together to create the image of a checkerboard
with the ability to render the correct game pieces.

The logic for the game would be elsewhere. My goal here is to create
the display. In Java, I'd subclass the Panel class, or possibly the
Component class to accomplish this. Now, surely, there is something
similar in C#.

 
Reply With Quote
 
Lucian Wischik
Guest
Posts: n/a
 
      17th Dec 2006
"TomC" <(E-Mail Removed)> wrote:
>In this case, I don't see any way to get around using inheritance.
>What I want to do is create a custom visual display, so I need to
>customize some sort of object that can be displayed visually.


Right, there are two types of customizations: (1) by the creator of
the application, who normally customizes by adding events instead of
by inheriting; (2) by the middleware/componentware author who creates
new components through inheritance.

Wearing your application-creator hat, you'd plonk down a PictureBox on
your form, one for each square. You'd probably just set its "Image"
property to the image (draughtspiece, chesspiece, blank...). Or you
could override its OnPaint event. That's to say, OnPaint is a list of
method+instance-pointers, and you will make it point to the
ChesspiecePaint method of your MyForm, and your MyForm will contain
the logic for painting it. Maybe you'd use its "tag" property to store
its coordinates or something like that.

Wearing your componentware-author's hate, you'd inherit from
PictureBox and add any properties that you see fit.


>It needs to have the the ability to draw on itself


So the .net/winforms philosophy is that often it's the
application/form that has the ability to draw the unusual controls it
uses, and which has the ability to respond to their clicks. Instead of
the java philosophy where it's normally the control itself that knows
how to paint itself.

--
Lucian
 
Reply With Quote
 
=?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
Guest
Posts: n/a
 
      17th Dec 2006
What I was proposing was that after you get your Java classes compiled as
..NET assemblies, it is easy to use tools like Roeder's Reflector to decompile
them into C# source code. This makes the task of comparing how one would
perform the analogous coding in .NET very easy.

Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com




"TomC" wrote:

> I'm not trying to convert an existing Java application. I'm trying to
> learn C#, and I have an idea of something that I'd like to attempt as a
> learning project.
>
> I know what I would do if I was writing it in Java, but I don't want to
> write it in Java first and then let some tool convert it to .NET. I
> want to write it in C#. But to do that, I need some way to figure out
> which library classes in .NET would be somewhat analogous to the
> library classes that I'd use in Java.
>
> Peter wrote:
> > Import your .java class files into Visual Studio, which will use the JLCA to
> > translate them to J#.
> > Now they are .NET classes.
> > Peter
> >
> > --
> > Co-founder, Eggheadcafe.com developer portal:
> > http://www.eggheadcafe.com
> > UnBlog:
> > http://petesbloggerama.blogspot.com
> >
> >
> >
> >
> > "TomC" wrote:
> >
> > > Is there any resource where someone who is familiar with Java might
> > > find which .NET classes are similar to classes they are familiar with
> > > in Java? For example, I have a project that I'd like to tackle as a
> > > learning project. In Java, I'd subclass the Panel or JPanel class. Is
> > > there someplace where a Java programmer who is learning C# could
> > > quickly find out what the analog for those classes are?
> > >
> > >

>
>

 
Reply With Quote
 
TomC
Guest
Posts: n/a
 
      17th Dec 2006
Lucian Wischik wrote:
> "TomC" <(E-Mail Removed)> wrote:
> >In this case, I don't see any way to get around using inheritance.
> >What I want to do is create a custom visual display, so I need to
> >customize some sort of object that can be displayed visually.

>
> Right, there are two types of customizations: (1) by the creator of
> the application, who normally customizes by adding events instead of
> by inheriting; (2) by the middleware/componentware author who creates
> new components through inheritance.
>
> Wearing your application-creator hat, you'd plonk down a PictureBox on
> your form, one for each square. You'd probably just set its "Image"
> property to the image (draughtspiece, chesspiece, blank...). Or you
> could override its OnPaint event. That's to say, OnPaint is a list of
> method+instance-pointers, and you will make it point to the
> ChesspiecePaint method of your MyForm, and your MyForm will contain
> the logic for painting it. Maybe you'd use its "tag" property to store
> its coordinates or something like that.
>
> Wearing your componentware-author's hate, you'd inherit from
> PictureBox and add any properties that you see fit.
>
>
> >It needs to have the the ability to draw on itself

>
> So the .net/winforms philosophy is that often it's the
> application/form that has the ability to draw the unusual controls it
> uses, and which has the ability to respond to their clicks. Instead of
> the java philosophy where it's normally the control itself that knows
> how to paint itself.
>
> --
> Lucian

Thank you!

This is the type of information that I need. What I am planning is
probably more in the middleware category. I want to create a class
that I can reuse in a variety of ways. In one application it might be
a square on a chessboard, in another it might be a square in a in a
Battleship clone, and in a third it might be drawing a giant
mathematical symbol.

The events would be added later.

I can start by looking at the documentation for the PictureBox class.
It is possible that I can even go further up the inheritance chain
since I would not be drawing .gif's or .bmp's but shapes like circles,
squares and other polygons. But at least now I know where to start
looking.

Now, if I could just find site that maps the various Java classes to
their analogous C# classes I could find this stuff myself.

 
Reply With Quote
 
TomC
Guest
Posts: n/a
 
      18th Dec 2006
Oh. I'm not familiar with Roeder's Reflector, but I can see where that
could help. Of course, that would mean writing the whole thing in Java
first, and then rewriting it in C#. I really do appreciate the reply,
but it still seems to be an inefficient use of time. Would it make
sense to create HelloWorld in Java, convert it .NET, and then decompile
it just to find out that the equivalent of System.out.println("Hello,
world!"); in C# is System.Console.WriteLine("Hello, world!");?

Again, I really DO appreciate that you've taken the time to reply.
Maybe I'm missing something.

Peter wrote:
> What I was proposing was that after you get your Java classes compiled as
> .NET assemblies, it is easy to use tools like Roeder's Reflector to decompile
> them into C# source code. This makes the task of comparing how one would
> perform the analogous coding in .NET very easy.
>
> Peter
> --
> Co-founder, Eggheadcafe.com developer portal:
> http://www.eggheadcafe.com
> UnBlog:
> http://petesbloggerama.blogspot.com
>
>
>
>
> "TomC" wrote:
>
> > I'm not trying to convert an existing Java application. I'm trying to
> > learn C#, and I have an idea of something that I'd like to attempt as a
> > learning project.
> >
> > I know what I would do if I was writing it in Java, but I don't want to
> > write it in Java first and then let some tool convert it to .NET. I
> > want to write it in C#. But to do that, I need some way to figure out
> > which library classes in .NET would be somewhat analogous to the
> > library classes that I'd use in Java.
> >
> > Peter wrote:
> > > Import your .java class files into Visual Studio, which will use the JLCA to
> > > translate them to J#.
> > > Now they are .NET classes.
> > > Peter
> > >
> > > --
> > > Co-founder, Eggheadcafe.com developer portal:
> > > http://www.eggheadcafe.com
> > > UnBlog:
> > > http://petesbloggerama.blogspot.com
> > >
> > >
> > >
> > >
> > > "TomC" wrote:
> > >
> > > > Is there any resource where someone who is familiar with Java might
> > > > find which .NET classes are similar to classes they are familiar with
> > > > in Java? For example, I have a project that I'd like to tackle as a
> > > > learning project. In Java, I'd subclass the Panel or JPanel class. Is
> > > > there someplace where a Java programmer who is learning C# could
> > > > quickly find out what the analog for those classes are?
> > > >
> > > >

> >
> >


 
Reply With Quote
 
=?ISO-8859-1?Q?Arne_Vajh=F8j?=
Guest
Posts: n/a
 
      24th Dec 2006
TomC wrote:
> Is there any resource where someone who is familiar with Java might
> find which .NET classes are similar to classes they are familiar with
> in Java? For example, I have a project that I'd like to tackle as a
> learning project. In Java, I'd subclass the Panel or JPanel class. Is
> there someplace where a Java programmer who is learning C# could
> quickly find out what the analog for those classes are?


I am not a GUI guy myself, but:

http://www.thescripts.com/forum/thread237279.html

Arne
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Listing of classes (similar to Java API) TomC Microsoft C# .NET 4 25th Jun 2006 05:05 AM
Using Java classes from VB.Net Eric Moreau Microsoft VB .NET 6 12th Oct 2005 11:07 AM
Inline::Java 0.49 Stable - A tool to write Perl classes in Java. Gordon Darling Freeware 0 8th Jul 2004 01:10 PM
Using java classes from c# =?Utf-8?B?RmF0aWggQk9Z?= Microsoft C# .NET 4 9th Mar 2004 09:15 PM
Java classes don't load public.microsoft.com Windows XP Internet Explorer 2 20th Jul 2003 07:04 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:49 PM.