Home arrow static arrow Java Programming [Archive] - This is tough man...
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - This is tough man...
10 Duke Stars available
This topic has 15 replies on 2 pages.    1 | 2 | Next »

Posts:17
Registered: 7/8/04
This is tough man...  
Jul 29, 2004 4:52 AM



 
Hi,
I have get a map and display on the screen using java.
But i have a problem in getting the coordination on the display.
What can i do on using java codes to make coordination on the map?

Thank you very much
 

Posts:21,719
Registered: 98-02-20
Re: This is tough man...  
Jul 29, 2004 5:43 AM (reply 1 of 15)



 
"Coordination"? What's that?

Do you mean "coordinates"?

%
 

Posts:24,036
Registered: 2/3/03
Re: This is tough man...  
Jul 29, 2004 5:55 AM (reply 2 of 15)



 
http://java.sun.com/docs/books/tutorial/uiswing/events/mouselistener.html
 

Posts:24,036
Registered: 2/3/03
Re: This is tough man...  
Jul 29, 2004 6:05 AM (reply 3 of 15)



 
Some example code:
import java.awt.*;import java.awt.event.*;import javax.swing.*;    class MouseTrackerDemo {        private JLabel status;    private MouseTracker tracker;        public static void main(String[] args) {        new MouseTrackerDemo().go();    }        void go() {        JFrame frame = new JFrame("Mouse events demo");        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);                status = new JLabel();        frame.getContentPane().add(status, BorderLayout.SOUTH);                tracker = new MouseTracker();        frame.addMouseListener(tracker);        frame.addMouseMotionListener(tracker);                frame.setSize(275, 100);        frame.setLocationRelativeTo(null);        frame.setVisible(true);    }        class MouseTracker implements MouseListener, MouseMotionListener {        public void mouseClicked(MouseEvent event) {            status.setText("Clicked at " + coords(event));        }                public void mousePressed(MouseEvent event) {            status.setText("Pressed at " + coords(event));        }                public void mouseReleased(MouseEvent event) {            status.setText("Released at " + coords(event));        }                public void mouseEntered(MouseEvent event) {            status.setText("Entered at " + coords(event));        }                public void mouseExited(MouseEvent event) {            status.setText("Exited at " + coords(event));        }                public void mouseDragged(MouseEvent event) {            status.setText("Dragged at " + coords(event));        }                        public void mouseMoved(MouseEvent event) {            status.setText("Moved at " + coords(event));        }                              private String coords(MouseEvent event) {            return "[" + event.getX() + ", " + event.getY() + "]";        }    }        }
 

Posts:24,036
Registered: 2/3/03
Re: This is tough man...  
Jul 29, 2004 6:07 AM (reply 4 of 15)



 
Hey, duffy, what's the potential this is another 10-Duke noob? ;o)
 

Posts:21,719
Registered: 98-02-20
Re: This is tough man...  
Jul 29, 2004 6:11 AM (reply 5 of 15)



 
I'd bet your house on it, Steve.

%
 

Posts:21,719
Registered: 98-02-20
Re: This is tough man...  
Jul 29, 2004 6:12 AM (reply 6 of 15)



 
Do you want screen coordinates (pixels from origin at upper left of screen) or map coordinates (longitude, latitude)? They're two different things, of course.

%
 

Posts:5,119
Registered: 16.08.01
Re: This is tough man...  
Jul 29, 2004 6:14 AM (reply 7 of 15)



 
I have get a map and display on the screen using java.
But i have a problem in getting the coordination on
the display.

Glue the map onto the screen.

 

Posts:24,036
Registered: 2/3/03
Re: This is tough man...  
Jul 29, 2004 6:15 AM (reply 8 of 15)



 
Do you want screen coordinates (pixels from origin at
upper left of screen) or map coordinates (longitude,
latitude)? They're two different things, of course.

%

Definitely; however, the code example still applies in principle - you'll need a mechanism to determine the mouse cursor's location. Once you get that, you're golden. :o)
 

Posts:24,036
Registered: 2/3/03
Re: This is tough man...  
Jul 29, 2004 6:16 AM (reply 9 of 15)



 
Assuming, of course, the OP is trying to get coordinates. If he's truly looking for coordination, I recommend ballet or tai chi.
 

Posts:21,719
Registered: 98-02-20
Re: This is tough man...  
Jul 29, 2004 6:19 AM (reply 10 of 15)



 
Assuming, of course, the OP is trying to get
coordinates. If he's truly looking for coordination, I
recommend ballet or tai chi.

EX-cellent.

Is that tai chi or chai tea that you're recommending? I get those confused. I thought I was doing tai chi in my car the other day and I got a 3rd degree spill burn instead. Silly me! Next time I'll know!

%
 

Posts:5,627
Registered: 3/22/04
Re: This is tough man...  
Jul 29, 2004 6:27 AM (reply 11 of 15)



 
Assuming, of course, the OP is trying to get
coordinates. If he's truly looking for coordination,
I
recommend ballet or tai chi.

EX-cellent.

Is that tai chi or chai tea that you're recommending?
I get those confused. I thought I was doing tai chi
in my car the other day ..

maybe you should have used feng shui to arrange your chai tea to be in perfect harmony with your rear-view mirror.
 

Posts:21,719
Registered: 98-02-20
Re: This is tough man...  
Jul 29, 2004 6:28 AM (reply 12 of 15)



 
THAT'S what I was missing!

%
 

Posts:196
Registered: 6/24/97
Re: This is tough man...  
Jul 29, 2004 8:35 AM (reply 13 of 15)



 
This is really tough.

Maybe its a problem with your monitor.

Have you noticed, even your question is not very co-ordinated ?

doh!
 

Posts:17
Registered: 7/8/04
Re: This is tough man...  
Jul 29, 2004 4:38 PM (reply 14 of 15)



 
i saw the sample codes there. Does the codes apply for map coordinates in longitude and latitude? I want the map to appear on the screen with x and y..
 
This topic has 15 replies on 2 pages.    1 | 2 | Next »