Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / June 2005

Tip: Looking for answers? Try searching our database.

Porting Win32 GUI to Java 2D

Thread view: 
Beatrice Rutger - 04 Jun 2005 00:46 GMT
Hi,

I'm new to Java 2D (but have lots of C/C++ experience with Win32). I
have a legacy C Windows application with a "small" GUI (couple of
hundred lines of code) that I want to convert to Java.

Can anyone please point me to a URL that shows the mapping (if any)
between the function calls. Also, if anyone has done this before and
knows of any genral guidelines and "pitfalls" to avoid, I would be very
grateful in hearing from them.

Thanks

B.
Martijn Mulder - 04 Jun 2005 01:11 GMT
"Beatrice Rutger"
> I'm new to Java 2D (but have lots of C/C++ experience with Win32). I
> have a legacy C Windows application with a "small" GUI (couple of
[quoted text clipped - 4 lines]
> knows of any genral guidelines and "pitfalls" to avoid, I would be very
> grateful in hearing from them.

Hi Beatrice,

I'm just doing that, porting from C++/Win32 to Java2D, but I have some
previous experience with Java. My advice is to start Top-Down, ie start
with a JFrame that holds the views. Place a JMenuBar on it. Define the
keystrokes, the mousemovements. I don't have to design them this time,
I did that when programming in C++.

After I implemented the 'look' of the implementation, I started reworking
the model. You'll have to say goodbye to all your artfully crafted overloaded
operators. Do a search-and-destroy on 'const'. Replace al '*' and '&' with ' '
and
add some 'new's here and there. The implementation is not hard to change.
Changing
the GUI means changing your mindset.

Perhaps you're working with an IDE. That will make your efforts more effective,
but if you have to know what's going on before you dare use it, you'll be in for
some surprises. Java lost the simplicity it had a few years ago and that might
be a
gain, but it carries now 2 GUI toolkits it seems, AWT from the olden days and
the
more recent Swing package. They partly overlap and Swing partly relies on AWT.
To be honest, it's a nightmare. The language is top-heavy and might not survive
(private opinion).
Beatrice Rutger - 05 Jun 2005 22:01 GMT
Hi Martijn,

Thanks for your response. The problem is not so much with porting C/C++
to Java, it is finding Java 2D functions that are equivalent to the
Windows GDI functions like:

GetClipBox
CreateRectRgn
SelectClipRgn
CreatePen
CreateSolidBrush

Whic Java functions are you using as equivalent (or approximately
equivalent) to the Windows GDI functions like the ones listed above?.
Have you worked out a mapping between the Java 2D and Windows GDI
functions yet? - if yes, I would be very grateful to see what you have
done so far - I look forward to your response.

B.

> "Beatrice Rutger"
>
[quoted text clipped - 32 lines]
> To be honest, it's a nightmare. The language is top-heavy and might not survive
> (private opinion).
Thomas Weidenfeller - 06 Jun 2005 07:54 GMT
> GetClipBox
> CreateRectRgn
[quoted text clipped - 4 lines]
> Whic Java functions are you using as equivalent (or approximately
> equivalent) to the Windows GDI functions like the ones listed above?.

Non. It is a bad idea to try to map the different architectures to each
other. I would suggest you study the Java 2D architecture (see 10.9 of
the FAQ for pointers). You will find  replacements, but on different
levels. Most of what you seem to be after is part of the graphics context.

/Thomas

Signature

The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq

Thomas Fritsch - 06 Jun 2005 12:32 GMT
>> GetClipBox
>> CreateRectRgn
[quoted text clipped - 11 lines]
>
> /Thomas

Hi Beatrice,

as Thomas W. already pointed out there are no exact 1:1 correspondencies
between Win32/GDI and Java/AWT. But there are some coarse similarities,
which might help at the beginning:

GDI                         package java.awt
---------------------------------------------
HDC                         class Graphics
HRGN                        class Shape
GetClipRgn(HDC, ...)        getClip() in class Graphics
CreateRectRgn(...)          new Rectangle(...)
SelectClipRgn(HDC, HRGN)    setClip(Shape) in class Graphics
HWND                        class Component

Signature

"Thomas:Fritsch$ops:de".replace(':','.').replace('$','@')

Beatrice Rutger - 07 Jun 2005 23:59 GMT
I have actually hopped over the fence to "the dark side". I am giving up
SWING to go to DotNet. This really breaks my heart - as I had vowed
never to go back to Windoze - plus it means having to maintain two code
branches - but if the truth be told. SWING is not really ready for prime
time. The LAF is a joke and it sucks big time on Windows (maybe it tries
to be too many things to too many people). It just looks silly on
Windoze, and can be spotted a mile off by an amateur. Sure you can get
it to sing and dance on Windoze, but its just not worth the effort. The
amount of time it takes to design one decent SWING GUI screen, one could
easily have designed 15/20 similar sheets (with blistering performance)
using Visual C++. I'm afraid theres no real comparison.

I may merge my code back (port from C++ to Java) in a couple of years
time, when hopefuy, swing has moved from the university lab to the real
world - until then, it just dosen't make sense to spend that amount of
time with such an unproductive library/set of tools.

So long ...

>>> GetClipBox
>>> CreateRectRgn
[quoted text clipped - 27 lines]
> SelectClipRgn(HDC, HRGN)    setClip(Shape) in class Graphics
> HWND                        class Component
Martijn Mulder - 08 Jun 2005 01:38 GMT
"Beatrice Rutger"
> I have actually hopped over the fence to "the dark side". I am giving up
> SWING to go to DotNet.

<snip>

Bye! You make me itch :-)
znôrt - 08 Jun 2005 07:09 GMT
> I have actually hopped over the fence to "the dark side".

Hi Beatrice

It's early in the morning, seems like we will have another splendid day,
today, but I just felt a little perturbation in the force while reading you. It's
not like I can't live happy without paying attention to every single
everyday's usenet knick-knack, but I have to confess I was a bit intrigued
about what kind of beast it was that could express such nonsense I was
reading, it somehow didn't fit with what one would expect from a serious
developer, not even from  a beginner, whatever his preferences could be.
Particularly, it's not at all obvious how someone can pose a question
about Java2D migration (a fairly specific topic) one day, and dismiss the
whole issue on the next with a rant on Swing (a fairly generic one)
speckled with personal preferences.

So I decided to grant myself the pleasure, and did a little search on
google, just to find out how far you can push it. Your painful technology
worries would have make me sorrow, if they weren't so hilarous, so I had
between 5 and 10 splendid minutes enjoying the story about you jumping
from code obfuscation to proxy selection, then a little bashing, then
fighting with server architectures, my heart filled with pity realizing how this
cruel world had ruthlessly forced you to mantain two full branches of your
app, a "couple hundred of lines of code" beast, and then I was almost
blowed away reading about your heroic last stand as you were being
literally assaulted by packs of Java Guys and DotNet Warriors to join their
respective teams, then a little more bashing ... wow, Beatrice, you are
indeed a funny person, I wish I could read from you everyday.

But then you completely surpassed yourself with this unique pearl I
stumbled across in microsoft.public.dotnet.general, which blew my mind
away :

"
... but a novice VB programmer on his
first day at work will be far much more productive than a Java
programmer with several years SWING experience. I could go on and on.
"

Oh my, oh my, Beatrice. Remember little great Yoda : "Don't feel like
doing it. Do it". Phew! Now sun is pouring already through my window,
time to get some job done. Don't take this too serious, anyway, I'm just
having a good time here and practicing my poor english. At least one of us
is *learning* something :-)

kind regards, looking forward to read more from you in near future,
znôrt
Thomas Weidenfeller - 09 Jun 2005 09:05 GMT
> It's early in the morning, seems like we will have another splendid day,
> today, but I just felt a little perturbation in the force while reading you. It's
[quoted text clipped - 7 lines]
> whole issue on the next with a rant on Swing (a fairly generic one)
> speckled with personal preferences.

So you also did notice that "Beatrice" was the anonymous person who
posted the "So long SUCKERS !!!" message. It was indeed a little bit to
obvious. (Message-ID: <d86lbl$a0n$1@nwrdmz02.dmz.ncs.ea.ibs-infra.bt.com>)

I think we have the case of a kid who wanted to do some trolling but
badly failed, because it couldn't ramp up the pressure and pity needed
to make an impact. It was also some rather bad timing, as you did
mention, too.

"Beatrice", you still have a long way to go to even reach the level of
low profile trolls and kooks like that X*h L** over there in
comp.lang.java.programmer. Please try harder - somewhere else.

> fighting with server architectures, my heart filled with pity realizing how this
> cruel world had ruthlessly forced you to mantain two full branches of your
> app, a "couple hundred of lines of code" beast,

Oh, I missed that one. A couple hundred of lines of code? Wow, life is
hard :-)

/Thomas
Signature

The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.