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 / First Aid / March 2006

Tip: Looking for answers? Try searching our database.

[beginner] Help - deprecated code (mouse events)

Thread view: 
Michele - 03 Mar 2006 12:52 GMT
Hi all,

I would like to adapt an old code. I use Sun Studio Creator 2. I
succeeded in part of the deprecated code but I got stuck about the
mouse events

The original code was:

--------------
           public boolean mousedown(Event event, int i, int j) {
/* 147*/        ix0 = i / sw;
/* 148*/        iy0 = j / sh;
/* 150*/        xoff = -i % sw;
/* 151*/        yoff = -j % sh;
/* 152*/        mx = i;
/* 153*/        my = j;
/* 154*/        activeindex = indexes[ix0 + iy0 * cols];
/* 155*/        drag = true;
/* 156*/        repaint();
/* 157*/        return true;
           }
---------
I found out that mouse_pressed should be used instead of mousedown but
I don't know the correct use of it and couldn't find any help on the
web.

What would be the correct code? Thanks a lot.

Signature

Michele
http://brunocremer.com/

Thomas Weidenfeller - 03 Mar 2006 13:31 GMT
> I would like to adapt an old code. I use Sun Studio Creator 2. I
> succeeded in part of the deprecated code but I got stuck about the mouse
[quoted text clipped - 4 lines]
> --------------
>            public boolean mousedown(Event event, int i, int j) {

There is no mousedown() method in the whole of Java SE. If you mean
mouseDown(), java.awt.Component has one (you could at least have had the
courtesy to post real code and mention which class you are talking about).

> I found out that mouse_pressed should be used instead of mousedown

If you talk about Component.mouseDown(), the API documentation will tell
you it has been replaced by Component.processMouseEvent(MouseEvent).

There is no mouse_pressed method or constant in Java. There is an int
constant MOUSE_PRESSED in MouseEvent. You are supposed to check the
event ID against that constant to figure out which type of event you got.

However, you apparently use the old 1.0 event model. That one has been
replaced in Java 1.1 - almost ten years ago. You should consider
rewriting that stuff to use the "new" 1.1 event model.

And you should recognize that Java is a language where case matters.

/Thomas
Signature

The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/

Michele - 03 Mar 2006 14:04 GMT
Thomas Weidenfeller a utilisé son clavier pour écrire :
>> I would like to adapt an old code. I use Sun Studio Creator 2. I succeeded
>> in part of the deprecated code but I got stuck about the mouse events
[quoted text clipped - 7 lines]
> mouseDown(), java.awt.Component has one (you could at least have had the
> courtesy to post real code and mention which class you are talking about).

I told in my title that I am a beginner and I mean a begginer, I didn't
know that case matters in java.
I thought that using a simple sample could help.
It's not a matter of courtesy as you say, I wrote what I thought was
important.

>> I found out that mouse_pressed should be used instead of mousedown
>
> If you talk about Component.mouseDown(), the API documentation will tell you
> it has been replaced by Component.processMouseEvent(MouseEvent).

This I saw but there are not a lot of info about how to use this
component, no complete sample and it's what I need.

> However, you apparently use the old 1.0 event model. That one has been
> replaced in Java 1.1 - almost ten years ago. You should consider rewriting
> that stuff to use the "new" 1.1 event model.

The java file is dated of 2001, I didn't thought it was 10 years old.
Sorry

> And you should recognize that Java is a language where case matters.
>
> /Thomas

Thanks anyway for answering but please treat begginers as beginners and
not as if they wrote mistakes on purpose.

Signature

Michele
http://brunocremer.com/

Paul Hamaker - 03 Mar 2006 13:36 GMT
http://javalessons.com/cgi-bin/fun/java-tutorials-main.cgi?ses=ao789&code=clk&sub=fun
http://javalessons.com/cgi-bin/fun/java-tutorials-main.cgi?ses=ao789&code=mev&sub=fun
http://javalessons.com/cgi-bin/fun/java-tutorials-main.cgi?ses=ao789&code=rcl&sub=gui
will show you how.
--------------------
Paul Hamaker, SEMM, teaching ICT since 1987
http://javalessons.com
Michele - 03 Mar 2006 14:05 GMT
Paul Hamaker avait énoncé :
> http://javalessons.com/cgi-bin/fun/java-tutorials-main.cgi?ses=ao789&code=clk&sub=fun
> http://javalessons.com/cgi-bin/fun/java-tutorials-main.cgi?ses=ao789&code=mev&sub=fun
[quoted text clipped - 3 lines]
> Paul Hamaker, SEMM, teaching ICT since 1987
> http://javalessons.com

Thanks, this is a useful site I didn't know

Signature

Michele
http://brunocremer.com/

bobH - 03 Mar 2006 13:41 GMT
Hi Michele,

An internet search for "Deprecated API " shows options from Sun

a starting point might be

http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/javadoc.html

and there are various Deprecated API  lists  depending on the platform
that you have.

B
Robert Waters - 03 Mar 2006 14:47 GMT
Michele,

The Sun tutorial is a good place to look at examples, also.

The Swing (user interface) part of the tutorial is at:
http://java.sun.com/docs/books/tutorial/uiswing/index.html

The specific part you want is on writing listeners:
http://java.sun.com/docs/books/tutorial/uiswing/events/index.html

And within that look at MouseListener (for the press, release and click
events) and MouseMotionListener if you need to drag or track movement of the
mouse rather than discrete presses.

As a beginner porting an old application to Swing, you will need to
understand first how GUI's are programmed in general (the generic idea of
handling events rather than a procedural mindset of: first I do this, then I
do this...)  From there you can pick up the Swing event model where your GUI
generates events (button presses, mouse clicks, etc) and you write event
handlers for those events (what should I do if the user clicks the mouse?).
In Swing they just happen to call those handlers "listeners".

It will be a little bit of a leap, since as a beginner, you will need to
figure out how to write classes, implement interfaces and write the code
that actually handles the functionality.  The Sun tutorial has a lot of good
examples of all this stuff and it is free!

Hope this helps a little...

Bob

> Hi all,
>
[quoted text clipped - 23 lines]
>
> What would be the correct code? Thanks a lot.
Roedy Green - 03 Mar 2006 15:10 GMT
On Fri, 03 Mar 2006 13:52:44 +0100, "Michele"
<icimimi$$$$$$$$$$$$$$$$$@wanadoo.fr> wrote, quoted or indirectly
quoted someone who said :

>I would like to adapt an old code. I use Sun Studio Creator 2. I
>succeeded in part of the deprecated code but I got stuck about the
>mouse events

see http://mindprod.com/jgloss/event10.htm to learn how they used to
work. and http://mindprod.com/jgloss/event11.html to learn how they
work now.  

I converted the Unicode app over from 1.0 to 1.1 events a few months
back. It is pretty mechanical once you do one handler.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.



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.