Skip to main content

Is There A BalloonTip Component In Java?

80 replies [Last post]

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
swpalmer
Offline
Joined: 2003-06-10

I got to this thread through a link on the java.net home page. Great to see stuff happening in this area.

But, how do I see those linked images without getting:

"Your account does not have the "Project Forum - View" permission needed for you to access the page you requested in the jdk-collaboration project (view your permissions). Either ask the project administrator for more permission, or log in using a different account."

I don't even know what "project" it's talking about :)

leouser
Offline
Joined: 2005-12-12

I tossed the images up over in the collaboration forum since I don't have a good way of just posting these images here. If someone has a better place for me to toss these things, Im all ears. :)

BH

leouser
Offline
Joined: 2005-12-12

Component shaping appears to be working as well:
https://www.dev.java.net/files/forums/2899/1463/1443/shapedAWTComponent.png

This is a Window with a Button in it. The Button has been shaped by the same Path2D.Float instance that I used to shape the last screen shot of the Window.

I believe Ive successfully removed any dependencies on non-public methods in the X11 classes. In cases where the functionality could not be called without using reflection to break the access controls Ive replicated the functionality that does the work. Usually it isn't too horrible since some of the methods are just wrappers around one line statements to an X call. The largest copy so far has been this handy piece of code that transforms a BufferedImage into a byte array that is in XBM format. I had to do some research into what the XBM format is to understand what was happening but it looks and behaves fine.

It will be interesting to see if the other platforms support some form of image based shaping. I think its very plausable that if the platform supports image shaping than it should be able to easily support Shape shaping. X only supports rectangles but the code paints the shape in a BuffereImage and then transforms it into XBM.

BH

leouser
Offline
Joined: 2005-12-12

Im going to guess that doing Shaped lightweights isn't just going to entail dealing with the drawing of the widgets. Its also going to have to deal with how MouseEvents are dispatched. Which means, I think, that the LightweightDispatcher will have to be enhanced to do deal with irregular shapes. Another question would be if utility methods like getDeepestComponentAt should be modified to take into account the non-rectangular?

BH

Joshua Marinacci

It's true that you need a full compositing window manager for
translucency of child windows (as OS X) but it's coming for Vista and
new versions of X. However, I don't this that transparent child
windows is the problem we are trying to solve here. Swing apps can
already make translucent and shaped internal frames and buttons/
labels/etc. The beauty of lightweight components is that we can
already do whatever we want with Java2D. It's the shaped frames, not
heavyweight internal components, that are the real concern right now
for most app developers. I'd rather build something that works but
doesn't cover every use case than wait for the perfect solution.

- J

On Oct 5, 2006, at 12:22 AM, Anthony Petrov wrote:

> Hi folks,
>
> Sounds great, excellent, cool... apart from one tiny thing: neither
> Windows nor X support translucency for child windows. These systems
> support this stuff for top-levels only (I'm not sure about MacOSX
> though).
> Now imagine one valuable point in JDK development - the support of
> mixing of HW and LW components (the feature is planned and will
> probably be available in JDK 7). LW components will paint
> themselves as expected - with fancy translucent effects and all
> that cool stuff. And what about HW components? What are your
> thoughts on supporting mixing for LW components with translucency
> enabled?
>
> On 10/05/2006 12:11 AM Joshua Marinacci wrote:
>> I discussed this with Chris Campbell at lunch today. We decided
>> that in the end you need both shape and image based apis, because
>> some platforms will support one and not the other. Plus some might
>> be faster than the other. You might also want to just set an
>> alpha value on the window as a whole. Thus you would need three
>> set methods plus three isSupported methods. It's not perfect but
>> it's the only way to cover everything and it gives the developer
>> the power to do what they want.
>> On transparency vs translucency. One thing to try is if the alpha
>> = 0 then the window really shouldn't be in that spot and it should
>> allow the mouse events to go thorough. If it's anything but 0,
>> even just 1 out of 255, then it should capture mouse events. As an
>> interesting side effect, since an alpha of 1 will visually look
>> the same as an alpha of 0, you could use to create a screen wide
>> glasspane to do cool things like a magnifying glass, drawing on
>> the whole screen, color selection on single click, etc.
>> - Josh
>> On Oct 3, 2006, at 6:44 PM, swing@javadesktop.org
>> wrote:
>>> Hmm, Ill focus on making it a JDIC(if I make it further) project
>>> and skip it as collab submission. If I get far enough Ill ping
>>> you Josh about collaborating with this Mac dude(ss). This is
>>> pretty interesting stuff, so its worth investigating just for its
>>> own sake. Im not sure how far back it can be taken, maybe Java 5
>>> is as deep as it could go on the X side. The reason I say this
>>> is that I believe the X classes Im currently working with sprung
>>> into existence in Java 5, maybe Im misguided about this. I have
>>> no idea what the API was before that.
>>>
>>> I hope XP has simple support for this. I took Windows Media
>>> Player today and made it assume this very odd shape. That is a
>>> positive sign.
>>>
>>> Im uncertain as to the best API for this. Maybe a static method
>>> that would take a Window and a GeneralPath:
>>> public static void shapeWindow(Window w, GeneralPath shape);
>>>
>>> probably would want to do an image based shape to if that was
>>> supported on all platforms:
>>> public static void shapeWindow(Window w, Image image);
>>>
>>> Im going to need to get a firm grasp on the Pixmap based shaping
>>> in X. I was doing some experimentation yesterday with it and the
>>> results were not quite what I was shooting for. Instead of a
>>> snowman shape I had 4-6 unconnected sharp triangles for a shape.
>>> If you clicked on one of the triangles it made the button click,
>>> if you clicked on the spaces between the triangles it did nothing
>>> but go to the entity behind it. That was semi-exciting stuff,
>>> but not what I was shooting for.
>>>
>>> I almost think you need to keep transparency and translucency in
>>> separate categories. The transparency Im experimenting with
>>> appears to be an all or nothing game. The window either exists
>>> in a place or it doesn't. Contrast this with the "Allow
>>> JComponents to be translucent" patch I did a little while back.
>>> You could make the component transparent but it did not stop it
>>> from eating MouseEvents and such. It was there regardless of the
>>> fact if you were aware of it or not.
>>>
>>> BH
>>> [Message sent by forum member 'leouser' (leouser)]
>>>
>>> http://forums.java.net/jive/thread.jspa?messageID=159527
>> - Blasting forth in three part harmony!
>
> --
> best regards,
> Anthony

- Blasting forth in three part harmony!

[att1.html]

oleg_sukhodolsky
Offline
Joined: 2006-02-06

But you will never be able to integrate native components (such as AxtiveX) into such Swing application :(just to remind you that everything has its own price ;)

Joshua Marinacci

Quite true, but I can't do that now either (at least not without a
commercial 3rd party library). I think it's a fair tradeoff for now.
Most apps which would like to use shaped windows don't need
heavyweight components. For the version that goes in Java 7 we would
need solve the problem completely, but this would let a lot of people
build cool looking apps right now. In fact, I suspect we will learn a
lot from this effort that can be applied to Java 7.

- Josh

On Oct 5, 2006, at 10:06 AM, swing@javadesktop.org wrote:

> But you will never be able to integrate native components (such as
> AxtiveX) into such Swing application :(just to remind you that
> everything has its own price ;)
> [Message sent by forum member 'oleg_sukhodolsky' (oleg_sukhodolsky)]
>
> http://forums.java.net/jive/thread.jspa?messageID=160326

- Blasting forth in three part harmony!

[att1.html]

rbair
Offline
Joined: 2003-07-08

I'm sorry, I missed it. Why can't you integrate ActiveX (or any other heavyweight components)? It seems like you can, with certain restrictions:
* Obviously, don't overlap a lightweight component on a heavyweight component
* Don't expect the heavyweight to be translucent
* Don't let the heavyweight extend beyond the visual bounds of the lightweight parent

There may be one or two more that I'm missing, but it seems like even with a half-way solution you could support shaped windows with embedded heavyweight components which don't extend beyond the bounds of the painted region.

I could be wrong, I only got 4 hours sleep last night :-)

Richard

> Quite true, but I can't do that now either (at least
> not without a
> commercial 3rd party library). I think it's a fair
> tradeoff for now.
> Most apps which would like to use shaped windows
> don't need
> heavyweight components. For the version that goes in
> Java 7 we would
> need solve the problem completely, but this would let
> a lot of people
> build cool looking apps right now. In fact, I suspect
> we will learn a
> lot from this effort that can be applied to Java 7.
>
> - Josh
>
>
> On Oct 5, 2006, at 10:06 AM, swing@javadesktop.org
> wrote:
>
> > But you will never be able to integrate native
> components (such as
> > AxtiveX) into such Swing application :(just to
> remind you that
> > everything has its own price ;)
> > [Message sent by forum member 'oleg_sukhodolsky'
> (oleg_sukhodolsky)]
> >
> >
> http://forums.java.net/jive/thread.jspa?messageID=1603
> 26
>
> - Blasting forth in three part harmony!
>
>
> [att1.html]

Joshua Marinacci

We certainly could, it just won't be foolproof. I don't think concerns
about heavyweight components should hold back this implementation,
however. That's all I'm saying. We should press ahead with shaped
windows even if it won't work in all cases. (provided we document those
cases very well! :)

- J

swing@javadesktop.org wrote:
> I'm sorry, I missed it. Why can't you integrate ActiveX (or any other heavyweight components)? It seems like you can, with certain restrictions:
> * Obviously, don't overlap a lightweight component on a heavyweight component
> * Don't expect the heavyweight to be translucent
> * Don't let the heavyweight extend beyond the visual bounds of the lightweight parent
>
> There may be one or two more that I'm missing, but it seems like even with a half-way solution you could support shaped windows with embedded heavyweight components which don't extend beyond the bounds of the painted region.
>
> I could be wrong, I only got 4 hours sleep last night :-)
>
> Richard
>
>
>
>>Quite true, but I can't do that now either (at least
>>not without a
>>commercial 3rd party library). I think it's a fair
>>tradeoff for now.
>>Most apps which would like to use shaped windows
>>don't need
>>heavyweight components. For the version that goes in
>>Java 7 we would
>>need solve the problem completely, but this would let
>>a lot of people
>>build cool looking apps right now. In fact, I suspect
>>we will learn a
>>lot from this effort that can be applied to Java 7.
>>
>>- Josh
>>
>>
>>On Oct 5, 2006, at 10:06 AM, swing@javadesktop.org
>>wrote:
>>
>>
>>>But you will never be able to integrate native
>>
>>components (such as
>>
>>>AxtiveX) into such Swing application :(just to
>>
>>remind you that
>>
>>>everything has its own price ;)
>>>[Message sent by forum member 'oleg_sukhodolsky'
>>
>>(oleg_sukhodolsky)]
>>
>>>
>>http://forums.java.net/jive/thread.jspa?messageID=1603
>>26
>>
>>- Blasting forth in three part harmony!
>>
>>
>>[att1.html]
>
> [Message sent by forum member 'rbair' (rbair)]
>
> http://forums.java.net/jive/thread.jspa?messageID=160345

Joshua Marinacci

It's true that you need a full compositing window manager for
translucency of child windows (as OS X) but it's coming for Vista and
new versions of X. However, I don't this that transparent child
windows is the problem we are trying to solve here. Swing apps can
already make translucent and shaped internal frames and buttons/
labels/etc. The beauty of lightweight components is that we can
already do whatever we want with Java2D. It's the shaped frames, not
heavyweight internal components, that are the real concern right now
for most app developers. I'd rather build something that works but
doesn't cover every use case than wait for the perfect solution.

- J

On Oct 5, 2006, at 12:22 AM, Anthony Petrov wrote:

> Hi folks,
>
> Sounds great, excellent, cool... apart from one tiny thing: neither
> Windows nor X support translucency for child windows. These systems
> support this stuff for top-levels only (I'm not sure about MacOSX
> though).
> Now imagine one valuable point in JDK development - the support of
> mixing of HW and LW components (the feature is planned and will
> probably be available in JDK 7). LW components will paint
> themselves as expected - with fancy translucent effects and all
> that cool stuff. And what about HW components? What are your
> thoughts on supporting mixing for LW components with translucency
> enabled?
>
> On 10/05/2006 12:11 AM Joshua Marinacci wrote:
>> I discussed this with Chris Campbell at lunch today. We decided
>> that in the end you need both shape and image based apis, because
>> some platforms will support one and not the other. Plus some might
>> be faster than the other. You might also want to just set an
>> alpha value on the window as a whole. Thus you would need three
>> set methods plus three isSupported methods. It's not perfect but
>> it's the only way to cover everything and it gives the developer
>> the power to do what they want.
>> On transparency vs translucency. One thing to try is if the alpha
>> = 0 then the window really shouldn't be in that spot and it should
>> allow the mouse events to go thorough. If it's anything but 0,
>> even just 1 out of 255, then it should capture mouse events. As an
>> interesting side effect, since an alpha of 1 will visually look
>> the same as an alpha of 0, you could use to create a screen wide
>> glasspane to do cool things like a magnifying glass, drawing on
>> the whole screen, color selection on single click, etc.
>> - Josh
>> On Oct 3, 2006, at 6:44 PM, swing@javadesktop.org
>> wrote:
>>> Hmm, Ill focus on making it a JDIC(if I make it further) project
>>> and skip it as collab submission. If I get far enough Ill ping
>>> you Josh about collaborating with this Mac dude(ss). This is
>>> pretty interesting stuff, so its worth investigating just for its
>>> own sake. Im not sure how far back it can be taken, maybe Java 5
>>> is as deep as it could go on the X side. The reason I say this
>>> is that I believe the X classes Im currently working with sprung
>>> into existence in Java 5, maybe Im misguided about this. I have
>>> no idea what the API was before that.
>>>
>>> I hope XP has simple support for this. I took Windows Media
>>> Player today and made it assume this very odd shape. That is a
>>> positive sign.
>>>
>>> Im uncertain as to the best API for this. Maybe a static method
>>> that would take a Window and a GeneralPath:
>>> public static void shapeWindow(Window w, GeneralPath shape);
>>>
>>> probably would want to do an image based shape to if that was
>>> supported on all platforms:
>>> public static void shapeWindow(Window w, Image image);
>>>
>>> Im going to need to get a firm grasp on the Pixmap based shaping
>>> in X. I was doing some experimentation yesterday with it and the
>>> results were not quite what I was shooting for. Instead of a
>>> snowman shape I had 4-6 unconnected sharp triangles for a shape.
>>> If you clicked on one of the triangles it made the button click,
>>> if you clicked on the spaces between the triangles it did nothing
>>> but go to the entity behind it. That was semi-exciting stuff,
>>> but not what I was shooting for.
>>>
>>> I almost think you need to keep transparency and translucency in
>>> separate categories. The transparency Im experimenting with
>>> appears to be an all or nothing game. The window either exists
>>> in a place or it doesn't. Contrast this with the "Allow
>>> JComponents to be translucent" patch I did a little while back.
>>> You could make the component transparent but it did not stop it
>>> from eating MouseEvents and such. It was there regardless of the
>>> fact if you were aware of it or not.
>>>
>>> BH
>>> [Message sent by forum member 'leouser' (leouser)]
>>>
>>> http://forums.java.net/jive/thread.jspa?messageID=159527
>> - Blasting forth in three part harmony!
>
> --
> best regards,
> Anthony

- Blasting forth in three part harmony!

[att1.html]

Joshua Marinacci

I discussed this with Chris Campbell at lunch today. We decided that
in the end you need both shape and image based apis, because some
platforms will support one and not the other. Plus some might be
faster than the other. You might also want to just set an alpha
value on the window as a whole. Thus you would need three set methods
plus three isSupported methods. It's not perfect but it's the only
way to cover everything and it gives the developer the power to do
what they want.

On transparency vs translucency. One thing to try is if the alpha = 0
then the window really shouldn't be in that spot and it should allow
the mouse events to go thorough. If it's anything but 0, even just 1
out of 255, then it should capture mouse events. As an interesting
side effect, since an alpha of 1 will visually look the same as an
alpha of 0, you could use to create a screen wide glasspane to do
cool things like a magnifying glass, drawing on the whole screen,
color selection on single click, etc.

- Josh

On Oct 3, 2006, at 6:44 PM, swing@javadesktop.org wrote:

> Hmm, Ill focus on making it a JDIC(if I make it further) project
> and skip it as collab submission. If I get far enough Ill ping you
> Josh about collaborating with this Mac dude(ss). This is pretty
> interesting stuff, so its worth investigating just for its own
> sake. Im not sure how far back it can be taken, maybe Java 5 is as
> deep as it could go on the X side. The reason I say this is that I
> believe the X classes Im currently working with sprung into
> existence in Java 5, maybe Im misguided about this. I have no idea
> what the API was before that.
>
> I hope XP has simple support for this. I took Windows Media Player
> today and made it assume this very odd shape. That is a positive
> sign.
>
> Im uncertain as to the best API for this. Maybe a static method
> that would take a Window and a GeneralPath:
> public static void shapeWindow(Window w, GeneralPath shape);
>
> probably would want to do an image based shape to if that was
> supported on all platforms:
> public static void shapeWindow(Window w, Image image);
>
> Im going to need to get a firm grasp on the Pixmap based shaping in
> X. I was doing some experimentation yesterday with it and the
> results were not quite what I was shooting for. Instead of a
> snowman shape I had 4-6 unconnected sharp triangles for a shape.
> If you clicked on one of the triangles it made the button click, if
> you clicked on the spaces between the triangles it did nothing but
> go to the entity behind it. That was semi-exciting stuff, but not
> what I was shooting for.
>
> I almost think you need to keep transparency and translucency in
> separate categories. The transparency Im experimenting with
> appears to be an all or nothing game. The window either exists in
> a place or it doesn't. Contrast this with the "Allow JComponents
> to be translucent" patch I did a little while back. You could make
> the component transparent but it did not stop it from eating
> MouseEvents and such. It was there regardless of the fact if you
> were aware of it or not.
>
> BH
> [Message sent by forum member 'leouser' (leouser)]
>
> http://forums.java.net/jive/thread.jspa?messageID=159527

- Blasting forth in three part harmony!

[att1.html]

Anthony Petrov

Hi folks,

Sounds great, excellent, cool... apart from one tiny thing: neither
Windows nor X support translucency for child windows. These systems
support this stuff for top-levels only (I'm not sure about MacOSX though).
Now imagine one valuable point in JDK development - the support of
mixing of HW and LW components (the feature is planned and will probably
be available in JDK 7). LW components will paint themselves as expected
- with fancy translucent effects and all that cool stuff. And what about
HW components? What are your thoughts on supporting mixing for LW
components with translucency enabled?

On 10/05/2006 12:11 AM Joshua Marinacci wrote:
> I discussed this with Chris Campbell at lunch today. We decided that in
> the end you need both shape and image based apis, because some platforms
> will support one and not the other. Plus some might be faster than the
> other. You might also want to just set an alpha value on the window as
> a whole. Thus you would need three set methods plus three isSupported
> methods. It's not perfect but it's the only way to cover everything and
> it gives the developer the power to do what they want.
>
> On transparency vs translucency. One thing to try is if the alpha = 0
> then the window really shouldn't be in that spot and it should allow the
> mouse events to go thorough. If it's anything but 0, even just 1 out of
> 255, then it should capture mouse events. As an interesting side effect,
> since an alpha of 1 will visually look the same as an alpha of 0, you
> could use to create a screen wide glasspane to do cool things like a
> magnifying glass, drawing on the whole screen, color selection on single
> click, etc.
>
> - Josh
>
> On Oct 3, 2006, at 6:44 PM, swing@javadesktop.org
> wrote:
>
>> Hmm, Ill focus on making it a JDIC(if I make it further) project and
>> skip it as collab submission. If I get far enough Ill ping you Josh
>> about collaborating with this Mac dude(ss). This is pretty
>> interesting stuff, so its worth investigating just for its own sake.
>> Im not sure how far back it can be taken, maybe Java 5 is as deep as
>> it could go on the X side. The reason I say this is that I believe
>> the X classes Im currently working with sprung into existence in Java
>> 5, maybe Im misguided about this. I have no idea what the API was
>> before that.
>>
>> I hope XP has simple support for this. I took Windows Media Player
>> today and made it assume this very odd shape. That is a positive sign.
>>
>> Im uncertain as to the best API for this. Maybe a static method that
>> would take a Window and a GeneralPath:
>> public static void shapeWindow(Window w, GeneralPath shape);
>>
>> probably would want to do an image based shape to if that was
>> supported on all platforms:
>> public static void shapeWindow(Window w, Image image);
>>
>> Im going to need to get a firm grasp on the Pixmap based shaping in
>> X. I was doing some experimentation yesterday with it and the results
>> were not quite what I was shooting for. Instead of a snowman shape I
>> had 4-6 unconnected sharp triangles for a shape. If you clicked on
>> one of the triangles it made the button click, if you clicked on the
>> spaces between the triangles it did nothing but go to the entity
>> behind it. That was semi-exciting stuff, but not what I was shooting for.
>>
>> I almost think you need to keep transparency and translucency in
>> separate categories. The transparency Im experimenting with appears
>> to be an all or nothing game. The window either exists in a place or
>> it doesn't. Contrast this with the "Allow JComponents to be
>> translucent" patch I did a little while back. You could make the
>> component transparent but it did not stop it from eating MouseEvents
>> and such. It was there regardless of the fact if you were aware of it
>> or not.
>>
>> BH
>> [Message sent by forum member 'leouser' (leouser)]
>>
>> http://forums.java.net/jive/thread.jspa?messageID=159527
>
> - Blasting forth in three part harmony!
>
>

--
best regards,
Anthony

leouser
Offline
Joined: 2005-12-12

When the Composite extension becomes a reality, this may no longer be true for X:
http://webcvs.freedesktop.org/xlibs/CompositeExt/protocol?view=markup

But again, this is probably going to be an option only for really new X implementations.

BH

Joshua Marinacci

True. That's why I'm thinking the api needs to have levels that the
developer can query at runtime.

if (TFrame.isAlphaChannelSupported()) {
TFrame.setAlphaChannel(bufferedImage);
} else if (TFrame.isShapeSupported()) {
TFrame.setShape(shape);
} else if (TFrame.isTransparencySupported()) {
TFrame.setTransparency(0.5f);
} else {
System.out.println("sorry dude!");
}

:)
- J

On Oct 5, 2006, at 7:27 AM, swing@javadesktop.org wrote:

> When the Composite extension becomes a reality, this may no longer
> be true for X:
> http://webcvs.freedesktop.org/xlibs/CompositeExt/protocol?view=markup
>
> But again, this is probably going to be an option only for really
> new X implementations.
>
> BH
> [Message sent by forum member 'leouser' (leouser)]
>
> http://forums.java.net/jive/thread.jspa?messageID=160213

- Blasting forth in three part harmony!

[att1.html]

leouser
Offline
Joined: 2005-12-12

Id guess that the non-rectangular windows feature would enable this kind of thing. I saw a picture of a X window with a nice circle cut out of the center of it. Don't know if that functionality will be part of the feature but it would be nice.

leouser

Joshua Marinacci

We are pushing for this in Java 7, but I don't know if it will make
it in. Code contributions are always welcome, of course. :)

- J

On Sep 30, 2006, at 10:31 AM, swing@javadesktop.org wrote:

> Id guess that the non-rectangular windows feature would enable this
> kind of thing. I saw a picture of a X window with a nice circle
> cut out of the center of it. Don't know if that functionality will
> be part of the feature but it would be nice.
>
> leouser
> [Message sent by forum member 'leouser' (leouser)]
>
> http://forums.java.net/jive/thread.jspa?messageID=158490

- Blasting forth in three part harmony!

[att1.html]

leouser
Offline
Joined: 2005-12-12

Hmm, maybe Ill play around with it this week on the X side. I see Ive got the shape.h file in the system, so hopefully I won't have to do any more system configuration. I am curious if the darn thing will just work if I make the backing XWindow a circle, will the AWT side of things be able to deal with it. I guess it would depend upon how X sends events to oddly shaped windows.

BH

Joshua Marinacci

If you get something working could you start a new subproject under
the JDIC project for it? That's the best place to put such things.

- J

On Sep 30, 2006, at 11:46 AM, swing@javadesktop.org wrote:

> Hmm, maybe Ill play around with it this week on the X side. I see
> Ive got the shape.h file in the system, so hopefully I won't have
> to do any more system configuration. I am curious if the darn
> thing will just work if I make the backing XWindow a circle, will
> the AWT side of things be able to deal with it. I guess it would
> depend upon how X sends events to oddly shaped windows.
>
> BH
> [Message sent by forum member 'leouser' (leouser)]
>
> http://forums.java.net/jive/thread.jspa?messageID=158495

- Blasting forth in three part harmony!

[att1.html]

leouser
Offline
Joined: 2005-12-12

Ill see what happens, I guess the dividing line will be if it is going to require modifications to something coreish or if it can stand by itself. If its coreish, Im not sure if we are at the point in liscensing yet where I can do a public fork of the JDK.

BH

leouser
Offline
Joined: 2005-12-12

cool, Ive made enough progress where I am able to make a Window or JFrame where it is transparent visually and in behavior. By behavior I mean if I have a JFrame, the portion that is transparent will act as if its not there. A Window below it will be brought to the fore. While the non-transparent part acts like it always has. In the example its a big JButton, so it clicks.

I wish these forums had an attachment so I could show you a simple picture. Maybe Ill post one in the collab forum.

Anyway, Ive been able to do most of this without altering the JDK src. The only thing Ive altered so far was adding a public modifier to a static method so I could grab the Display. So its fairly conceivable, given what Ive seen, that a simple API could be developed so that a user could make things non-rectangular. Even with the API I think there is going to be a need to check if the extension is supported, given that it appears optional. Though from the article Im reading it sounds as though its a very popular extension.

BH

Joshua Marinacci

This sounds great. Yes, definitely post a screenshot.

How are you doing this? Using JNI to call the native method and JAWT
to get a handle to the toplevel window/container handle? It would
definitely need an isTranslucencySupported() method of some kind. I
don't know if we should distinguish transparency and translucency at
the API level. I suppose it depends on what the native platform
supports. OSX and Vista should be no problem. I don't know about XP
or earlier. And it seems that X is a crapshoot, depending on what the
user has configured.

Is your code for Windows or X, btw?

- J

On Oct 2, 2006, at 12:28 PM, swing@javadesktop.org wrote:

> cool, Ive made enough progress where I am able to make a Window or
> JFrame where it is transparent visually and in behavior. By
> behavior I mean if I have a JFrame, the portion that is transparent
> will act as if its not there. A Window below it will be brought to
> the fore. While the non-transparent part acts like it always has.
> In the example its a big JButton, so it clicks.
>
> I wish these forums had an attachment so I could show you a
> simple picture. Maybe Ill post one in the collab forum.
>
> Anyway, Ive been able to do most of this without altering the JDK
> src. The only thing Ive altered so far was adding a public
> modifier to a static method so I could grab the Display. So its
> fairly conceivable, given what Ive seen, that a simple API could be
> developed so that a user could make things non-rectangular. Even
> with the API I think there is going to be a need to check if the
> extension is supported, given that it appears optional. Though
> from the article Im reading it sounds as though its a very popular
> extension.
>
> BH
> [Message sent by forum member 'leouser' (leouser)]
>
> http://forums.java.net/jive/thread.jspa?messageID=158918

- Blasting forth in three part harmony!

- Blasting forth in three part harmony!

[att1.html]

leouser
Offline
Joined: 2005-12-12

Its X at this juncture, Im crippled when it comes to Windows... no good C++ compiler to build things with.

Ive got a early picture posted here:
https://www.dev.java.net/files/forums/2899/1463/1432/NonRectWindow.png

Its not too exciting but it shows what you can do with Rectangles. The JButton should fill the entire frame.

Im going to be looking at how the Pixmap function looks next. This should make a cooler example. :)

BH

oleg_sukhodolsky
Offline
Joined: 2006-02-06

Hi Brian,

just to let you (and others) know. Transparent and shaped toplevels are in AWT wish-list for jdk 7 and, I hope, we will implement them. Also please note that we will implement shaped windows as part of another project thus I'd suggest you to postpone such project unless you want to have these cool features before 7.0, because any changes in this area may not be applicable for AWT :( And so we will not accept such submission.

Thanks, Oleg.

Joshua Marinacci

Brian, please do continue your work and make it available for earlier
versions of Java. The JDIC project would be the likely place for
this. We understand that things will change when moved or re-
implemented in core, but transparent windows is very useful right
now. I know of a Mac developer who may be interested in helping on
that side. It would be good to come up with a common API for this.

- Josh

On Oct 3, 2006, at 12:16 AM, swing@javadesktop.org wrote:

> Hi Brian,
>
> just to let you (and others) know. Transparent and shaped
> toplevels are in AWT wish-list for jdk 7 and, I hope, we will
> implement them. Also please note that we will implement shaped
> windows as part of another project thus I'd suggest you to postpone
> such project unless you want to have these cool features before
> 7.0, because any changes in this area may not be applicable for
> AWT :( And so we will not accept such submission.
>
> Thanks, Oleg.
> [Message sent by forum member 'oleg_sukhodolsky' (oleg_sukhodolsky)]
>
> http://forums.java.net/jive/thread.jspa?messageID=159070

- Blasting forth in three part harmony!

[att1.html]

leouser
Offline
Joined: 2005-12-12

Hmm, Ill focus on making it a JDIC(if I make it further) project and skip it as collab submission. If I get far enough Ill ping you Josh about collaborating with this Mac dude(ss). This is pretty interesting stuff, so its worth investigating just for its own sake. Im not sure how far back it can be taken, maybe Java 5 is as deep as it could go on the X side. The reason I say this is that I believe the X classes Im currently working with sprung into existence in Java 5, maybe Im misguided about this. I have no idea what the API was before that.

I hope XP has simple support for this. I took Windows Media Player today and made it assume this very odd shape. That is a positive sign.

Im uncertain as to the best API for this. Maybe a static method that would take a Window and a GeneralPath:
public static void shapeWindow(Window w, GeneralPath shape);

probably would want to do an image based shape to if that was supported on all platforms:
public static void shapeWindow(Window w, Image image);

Im going to need to get a firm grasp on the Pixmap based shaping in X. I was doing some experimentation yesterday with it and the results were not quite what I was shooting for. Instead of a snowman shape I had 4-6 unconnected sharp triangles for a shape. If you clicked on one of the triangles it made the button click, if you clicked on the spaces between the triangles it did nothing but go to the entity behind it. That was semi-exciting stuff, but not what I was shooting for.

I almost think you need to keep transparency and translucency in separate categories. The transparency Im experimenting with appears to be an all or nothing game. The window either exists in a place or it doesn't. Contrast this with the "Allow JComponents to be translucent" patch I did a little while back. You could make the component transparent but it did not stop it from eating MouseEvents and such. It was there regardless of the fact if you were aware of it or not.

BH

Vyacheslav Baranov

Hi Brian,

Windows support all the stuff you need, so feel free to move on.
I think it would be rather painful to build JDK with Cygwin g++,
but you can easily use it to build your own native libraries.

I think, we can participate in this project, at least with some
advice and code review.

Thanks,
Slava

PS I think it's better to use Shape as an argument instead of
GeneralPath.

PPS I would suggest thinking of setting shapes to Components
instead of Windows. It would not add work for heavyweight
components, and can be easily implemented for lightweights
by clipping Graphics2D while painting.

swing@javadesktop.org wrote:
> Hmm, Ill focus on making it a JDIC(if I make it further) project and skip it as collab submission. If I get far enough Ill ping you Josh about collaborating with this Mac dude(ss). This is pretty interesting stuff, so its worth investigating just for its own sake. Im not sure how far back it can be taken, maybe Java 5 is as deep as it could go on the X side. The reason I say this is that I believe the X classes Im currently working with sprung into existence in Java 5, maybe Im misguided about this. I have no idea what the API was before that.
>
> I hope XP has simple support for this. I took Windows Media Player today and made it assume this very odd shape. That is a positive sign.
>
> Im uncertain as to the best API for this. Maybe a static method that would take a Window and a GeneralPath:
> public static void shapeWindow(Window w, GeneralPath shape);
>
> probably would want to do an image based shape to if that was supported on all platforms:
> public static void shapeWindow(Window w, Image image);
>
> Im going to need to get a firm grasp on the Pixmap based shaping in X. I was doing some experimentation yesterday with it and the results were not quite what I was shooting for. Instead of a snowman shape I had 4-6 unconnected sharp triangles for a shape. If you clicked on one of the triangles it made the button click, if you clicked on the spaces between the triangles it did nothing but go to the entity behind it. That was semi-exciting stuff, but not what I was shooting for.
>
> I almost think you need to keep transparency and translucency in separate categories. The transparency Im experimenting with appears to be an all or nothing game. The window either exists in a place or it doesn't. Contrast this with the "Allow JComponents to be translucent" patch I did a little while back. You could make the component transparent but it did not stop it from eating MouseEvents and such. It was there regardless of the fact if you were aware of it or not.
>
> BH
> [Message sent by forum member 'leouser' (leouser)]
>
> http://forums.java.net/jive/thread.jspa?messageID=159527
>

leouser
Offline
Joined: 2005-12-12

yes, Shape sounds like a better idea. That would include the GeneralPath variants but many other things.

Doing at the Component level appears doable. If Im thinking right every component on X is an XWindow and the shape library works with XWindows, not just toplevels.

Yes, the idea of building Java with Cygwin and g++ scares me. :D

BH

jvaudry
Offline
Joined: 2006-05-05

Hi, I do not know of a ready-made balloon tip component. I've tried a couple approaches to create a balloon tip.

My first try was to develop a custom JPopupMenu. Using a lightweight popup you can walk up its component hierarchy and set everything to be non-opaque. That way you can show a rounded balloon shape (instead of seeing the usual rectangular window). I found that approach sometimes left a gray rectangle behind when it the popup was hidden. I couldn't figure out how to get rid of the grey rectangle so I used a second approach.

The second approach was to create a pojo object that knows how to draw the balloon (using g.drawString() to paint the text, and using constructive geometry to create the balloon (E.g., http://java.sun.com/docs/books/tutorial/2d/display/complexshapes.html)). Then I painted the balloon object on the glasspane of the main window (as opposed to painting it in a JPopupMenu). That approach worked much better.

Joshua Marinacci

There is an example of this in the Swing Hacks book. However, it only
works for lightweight popups, of course.

- Josh

On Sep 30, 2006, at 10:11 AM, swing@javadesktop.org wrote:

> Hi, I do not know of a ready-made baloon tip component. I've tried
> a couple approaches to create a baloon tip.
>
> My first try was to develop a custom JPopupMenu. Using a
> lightweight popup you can walk up it's component hierarchy and set
> everything to be non-opaque. That way you can show a rounded baloon
> shape (instead of seeing the usual rectangular window). I found
> that approach sometimes left a gray rectangle behind when it the
> popup was hidden. I couldn't figure out how to get rid of the grey
> rectangle so I used a second approach.
>
> The second approach was to create a pojo object that knows how to
> draw the baloon (using g.drawString() to paint the text). Then I
> painted the baloon object on the glasspane of the main window (as
> opposed to painting it in a JPopupMenu). That approach worked much
> better.
> [Message sent by forum member 'jvaudry' (jvaudry)]
>
> http://forums.java.net/jive/thread.jspa?messageID=158479

- Blasting forth in three part harmony!

[att1.html]

jvaudry
Offline
Joined: 2006-05-05

hi, I have the book. Good read, btw :)