[java] Component Images

Started by
13 comments, last by joeG 24 years, 1 month ago
very doable under 1.1. Just make a class
MyGlassPane extends Component { ....paint (Graphics g) {g.setColor(Color.OPAQUE);g.drawRect(dimensions, of , entire, MyGlassPane);g.setColor(Color.black);g.drawRect(dimensions, sent, from ,dragEvent);}} 

Now, you might have to do something fancy with the event listeners, like onmousedown, set the glasspane's visibility to true, then give the glass pane a listener for mouse drags. See I don't know if the mouse drags will still get passed to the underlying component on wich the mouse was originally clicked or not. Just include printlns in your event listener to print out the event's source.

Edited by - Jim_Ross on 2/23/00 1:36:32 PM
Advertisement
quote:Original post by joeG

Jim, Have any idea on how to do that in JDK 1.1?

Javanerd, that''s what I eventually want to end up with, a selection rectangle over an image (but not for editing though ), but I don''t see any code to undo the last rectangle drawn, so I''m thinking that there wouldn''t be any change between what you see in the pic above.


Ah, but there you are wrong my friend...

The XOR painting mode takes care of the painting AND the removing. The idea is that if you paint a rectangle first time using XOR mode it''ll alter the colors so that the rectangle is allways visible no matter what the background color is. Then when you paint the rectangle the second time using XOR mode it''ll erase whatever was painted the last time (assuming of course that you draw the exact same rectangle).

Try it!

-Pasi Keranen
But, when will the rectangle ever be drawn twice over itself? As you can see in the above pic, there are rectangles all over. Trying XOR, I would get the same lines, but with weird colors. Do you have tha old app(let) with you still. I'd like to see the source to see what your talking about.

Thanks though

JoeG

And one thing more, these rectangles are not solid rectangles

Edited by - joeG on 2/25/00 8:25:54 AM
joeG
quote: Original post by javanerd

Original post by joeG

Jim, Have any idea on how to do that in JDK 1.1?

Javanerd, that's what I eventually want to end up with, a selection rectangle over an image (but not for editing though ), but I don't see any code to undo the last rectangle drawn, so I'm thinking that there wouldn't be any change between what you see in the pic above.


Ah, but there you are wrong my friend…

The XOR painting mode takes care of the painting AND the removing. The idea is that if you paint a rectangle first time using XOR mode it'll alter the colors so that the rectangle is allways visible no matter what the background color is. Then when you paint the rectangle the second time using XOR mode it'll erase whatever was painted the last time (assuming of course that you draw the exact same rectangle).

Try it!



Will that work even with the color black? I guess i don't fully understand the internals of a XOR color mode (model?)


Edited by - Jim_Ross on 2/25/00 1:00:23 PM
I imagine Java, if working in palette mode, would ''dereference'' both color''s indices and then peform the bitwise XOR. False (XOR) Anything = ThatAnything. Translation: 000 000 000 (XOR) 111 000 000 (red for example) = 111 000 000. I think it looks pretty cool. But it doesn''t solve my problem either
joeG

This topic is closed to new replies.

Advertisement