473,703 Members | 2,815 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2717
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*********@bi gfoot.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*********@bi gfoot.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*********@bi gfoot.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*********@bi gfoot.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.prin tln("Hello,
world!"); in C# is System.Console. WriteLine("Hell o, 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
2797
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 1.4.1, JMF 2.1.1e and J323 5.0.0 Can somebody help me with well documented example link or maybe
13
1710
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 which one. if I do:
3
320
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 wizards is this true ??? Thanks!!!!
7
1580
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 I am confused with java where you say Test c = new Test; whre you can move this Test object around by saying "Test b" and then b = c;(so c and b points to the same object). while in c++ I think it has different meaning(like b would have different...
133
8540
by: Gaurav | last post by:
http://www.sys-con.com/story/print.cfm?storyid=45250 Any comments? Thanks Gaurav
458
21228
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 simply aren't smart enough to understand C++? This is not merely a whimsical hypothesis. Given my experience with Java programmers --- the code they write and the conversations they have --- Occam's Razor points to this explanation. For example,...
35
3038
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. In C#, there appears to be no analog. I have to compile all my .cs files into a single .dll. This has serious drawbacks in terms of compilation. With Eclipse, I change a file and only that file is re-compiled. With Visual Studio, I
1
2049
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 objects in the SQL relationnal databases's tables. For .NET, there is somthing similar in LINQ. There is also available a NHibernate. I am new in this things, can somebody advice me from where to
4
1169
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(); Class cls = ((ProgramChoice) choice; function = (Function) cls.newInstance(); The object "choice" shows that a Subtraction class (i.e. "sub") was selected,
0
8749
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8662
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9243
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9002
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6585
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5922
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4420
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4677
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2057
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.