Click here to Skip to main content
16,005,120 members
Home / Discussions / Java
   

Java

 
GeneralRe: Java Tutorials??? Pin
Nagy Vilmos6-Oct-09 6:18
professionalNagy Vilmos6-Oct-09 6:18 
Questionhelp regarding J2EE books. Pin
madhu91244-Oct-09 7:16
madhu91244-Oct-09 7:16 
AnswerRe: help regarding J2EE books. Pin
42774804-Oct-09 9:38
42774804-Oct-09 9:38 
Questionplz help me Pin
arifihsan3-Oct-09 7:06
arifihsan3-Oct-09 7:06 
AnswerRe: plz help me Pin
42774803-Oct-09 8:50
42774803-Oct-09 8:50 
QuestionImplementing a Dictionary Pin
pinkett2-Oct-09 23:40
pinkett2-Oct-09 23:40 
AnswerRe: Implementing a Dictionary Pin
42774803-Oct-09 0:34
42774803-Oct-09 0:34 
QuestionJAVA Swing Tooltips Pin
simondopickup2-Oct-09 6:23
simondopickup2-Oct-09 6:23 
Hi there,
I am trying to get my swing panel to show a tooltip with the x,y coordinates of the point of the mouse location - whenever the mouse is sat at the location for 1 second or more.

Obviously this means that the tooltip invokation needs to respond to a mouse event of some sort.


THE CODE BENEATH IS THE PART OF MY PANEL CONSTRUCTOR:
//Register for mouse events on panel.
ScreenMouseListener myListener = new ScreenMouseListener();
addMouseListener(myListener);
addMouseMotionListener(myListener);

//THIS IS MY MOUSELISTENER CLASS...AND I NEED TO INVOKE THE TOOLTIP FROM HERE?
private class ScreenMouseListener extends MouseInputAdapter {

public void mousePressed(MouseEvent e) {
printOutput("Mouse Pressed", e);
isNearBlip(e);
}

private void isNearBlip(MouseEvent e) {
for (Point p1 : CurrentDisplayedAircraft) {

double x1 = p1.getX();
double y1 = p1.getY();
double x_dif=Math.abs(e.getX()-x1);
double y_dif=Math.abs(e.getY()-y1);
x_dif=Math.pow(x_dif, 2);
y_dif=Math.pow(y_dif, 2);
double sep=Math.sqrt(x_dif+y_dif);

//DISPLAY A TOOL TIP IF CLOSE TO THE POINT
if(sep<15){
//NEED TO CREATE A TOOLTIP SHOWING PROPERTIES
//OF P1 HERE...

}


}// end of for (ScreenTrajectory S : DisplayPositions) {


}

public void mouseReleased(MouseEvent e) {
printOutput("Mouse Released", e);
}

public void mouseMoved(MouseEvent e) {
printOutput("Mouse moved", e);
}

public void mouseDragged(MouseEvent e) {
printOutput("Mouse dragged", e);
}

public void mouseClicked(MouseEvent e) {
printOutput("Mouse Clicked", e);
}

void printOutput(String eventDescription, MouseEvent e) {
System.out.println(eventDescription
+ " (" + e.getX() + "," + e.getY() + ")"
+ " detected on "
+ e.getComponent().getClass().getName()
+ NL);
}

}
AnswerRe: JAVA Swing Tooltips Pin
42774802-Oct-09 22:07
42774802-Oct-09 22:07 
AnswerRe: JAVA Swing Tooltips Pin
simondopickup3-Oct-09 5:19
simondopickup3-Oct-09 5:19 
GeneralRe: JAVA Swing Tooltips Pin
42774803-Oct-09 8:52
42774803-Oct-09 8:52 
QuestionProblem : Reading and Writing of Byte[] Array Messages to Serial Comm (Serial Port RS232) Pin
pohcb_sonic1-Oct-09 19:17
pohcb_sonic1-Oct-09 19:17 
AnswerRe: Problem : Reading and Writing of Byte[] Array Messages to Serial Comm (Serial Port RS232) Pin
David Skelly1-Oct-09 22:20
David Skelly1-Oct-09 22:20 
AnswerRe: Problem : Reading and Writing of Byte[] Array Messages to Serial Comm (Serial Port RS232) Pin
42774802-Oct-09 22:12
42774802-Oct-09 22:12 
GeneralRe: Problem : Reading and Writing of Byte[] Array Messages to Serial Comm (Serial Port RS232) Pin
pohcb_sonic3-Oct-09 4:44
pohcb_sonic3-Oct-09 4:44 
GeneralRe: Problem : Reading and Writing of Byte[] Array Messages to Serial Comm (Serial Port RS232) Pin
pohcb_sonic3-Oct-09 4:44
pohcb_sonic3-Oct-09 4:44 
GeneralRe: Problem : Reading and Writing of Byte[] Array Messages to Serial Comm (Serial Port RS232) Pin
Richard MacCutchan3-Oct-09 5:39
mveRichard MacCutchan3-Oct-09 5:39 
GeneralRe: Problem : Reading and Writing of Byte[] Array Messages to Serial Comm (Serial Port RS232) Pin
42774803-Oct-09 8:53
42774803-Oct-09 8:53 
GeneralRe: Problem : Reading and Writing of Byte[] Array Messages to Serial Comm (Serial Port RS232) Pin
Richard MacCutchan3-Oct-09 21:38
mveRichard MacCutchan3-Oct-09 21:38 
GeneralRe: Problem : Reading and Writing of Byte[] Array Messages to Serial Comm (Serial Port RS232) Pin
42774804-Oct-09 0:10
42774804-Oct-09 0:10 
GeneralRe: Problem : Reading and Writing of Byte[] Array Messages to Serial Comm (Serial Port RS232) Pin
Richard MacCutchan4-Oct-09 1:15
mveRichard MacCutchan4-Oct-09 1:15 
GeneralRe: Problem : Reading and Writing of Byte[] Array Messages to Serial Comm (Serial Port RS232) Pin
42774804-Oct-09 2:40
42774804-Oct-09 2:40 
GeneralRe: Problem : Reading and Writing of Byte[] Array Messages to Serial Comm (Serial Port RS232) Pin
Richard MacCutchan4-Oct-09 4:01
mveRichard MacCutchan4-Oct-09 4:01 
GeneralRe: Problem : Reading and Writing of Byte[] Array Messages to Serial Comm (Serial Port RS232) [modified] Pin
pohcb_sonic4-Oct-09 17:21
pohcb_sonic4-Oct-09 17:21 
AnswerRe: Problem : Reading and Writing of Byte[] Array Messages to Serial Comm (Serial Port RS232) Pin
42774804-Oct-09 22:15
42774804-Oct-09 22:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.