473,322 Members | 1,241 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

C# analog's of Java classes

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?

Dec 16 '06 #1
9 2698
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?

Dec 17 '06 #2
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?
Dec 17 '06 #3
"TomC" <to*********@bigfoot.comwrote:
>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
Dec 17 '06 #4

Lucian Wischik wrote:
"TomC" <to*********@bigfoot.comwrote:
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#.

Dec 17 '06 #5
"TomC" <to*********@bigfoot.comwrote:
>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
Dec 17 '06 #6
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?
>
>

Dec 17 '06 #7
Lucian Wischik wrote:
"TomC" <to*********@bigfoot.comwrote:
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.

Dec 18 '06 #8
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?
Dec 18 '06 #9
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
Dec 24 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: dado | last post by:
Hi, I have ISDN (Fritz) card (PCI) in my PC. I like to write a standalone java application with ability to making outgoing calls and receive incoming calls. On my PC I have installed J2SDK...
13
by: Jean-François Doyon | last post by:
Hello, I'm using MetaClasses to create classes. How do I make these new classes "globally" available? I probably just have to assign them to something magic, but I can't seem to figure out...
3
by: sickky | last post by:
HI please could anyone give me any links/URL's that i could visit for good tutorials / examples on what .net uses as an altenative to java beans ? as far as i can find out it uses "com" and...
7
by: Snake | last post by:
Hi guys, I have question about classes. when u create class called Test. and you define variable Test c; so does this act like( a variable c of type Test pointing to an abject )? The thing that...
133
by: Gaurav | last post by:
http://www.sys-con.com/story/print.cfm?storyid=45250 Any comments? Thanks Gaurav
458
by: wellstone9912 | last post by:
Java programmers seem to always be whining about how confusing and overly complex C++ appears to them. I would like to introduce an explanation for this. Is it possible that Java programmers...
35
by: mwelsh1118 | last post by:
Why doesn't C# allow incremental compilation like Java? Specifically, in Java I can compile single .java files in isolation. The resulting individual .class files can be grouped into .jar files....
1
by: Sergiu DUDNIC | last post by:
Hello, I would like to know, if there are a analog for the Hibernate 's Java approach in the .NET Framework. As I understand Java's hibernate allows to conserve, and use the programmed...
4
by: =?Utf-8?B?Q2hhcmxlcw==?= | last post by:
Hello all, I'm trying to convert a Java Genetic Programming program to C#. I don't know how to convert the following Java code: Object choice = functionSet.getSelectedItem(choice)).value();...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.