File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes understand the graphic Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "understand the graphic" Watch "understand the graphic" New topic
Author

understand the graphic

Luca Mezzolla
Greenhorn

Joined: Jun 02, 2014
Posts: 3
Hi, excuse my english...
I have 3 classes. The main, myarrow and myblock.
The blocks are connected by arrows, and each arrow has the mouselistener.
Myblock extends Jpanel.
MyArrow extends Jcomponent and implement mouselistner, the size of myarrow covers the frame.
So the click of the mouse only works on a component.

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38817
    
  23
Welcome to the Ranch

I am afraid I don't understand the problem. Maybe if you post your code, we can execute it and see what happens. You did not say what problem you are having.
Luca Mezzolla
Greenhorn

Joined: Jun 02, 2014
Posts: 3
Thank you!
I have simplified the code and now I have 2 classes: main and myarrow.



and MyArrow is:



The result on the console is:
You have clicked the arrow: arr1

I want to have the ability to click on both.
(google docet).

;)

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

As far as I can see, both of your MyArrow components have the same size as the entire frame. So one of them is on top of the other one. Naturally (if I'm right, anyway) you can only click on the one which is on top.

Perhaps restricting the size to the actual visible part of the component would help?
Luca Mezzolla
Greenhorn

Joined: Jun 02, 2014
Posts: 3
My original project is full of arrows.
Is there a way to click on each arrow?
To give the size and the location becomes more complicated...
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

As far as I know, only one component is supposed to respond to a mouse click. So if you want both arrows to respond if they are both under where the click took place, sorry, that isn't going to happen.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: understand the graphic