The Source for Java Technology Collaboration

Home » java.net Forums » Java Desktop Technologies » Swing & AWT

Thread: If Windows were allowed to be non-rectangular,should Components be as well?

Welcome, Guest Help
Login Login
Guest Settings Guest Settings
Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 13 - Last Post: Jan 6, 2008 6:58 PM by: daeone
leouser

Posts: 1,160
If Windows were allowed to be non-rectangular,should Components be as well?
Posted: Aug 17, 2006 9:14 AM
  Click to reply to this thread Reply

Hi,

Im not sure if awt/swing will ever have non-rectangular windows, but if it did I was wondering how far it should go? Should the toplevels be the only target for trianglur, circular, ovalish, etc... shapes? Or should it be taken further, and allow odd shapped Components?

I was reading about an X extension library a little while ago and it seemed to indicate that it allowd things like non-rectangular buttons and such. Which made me wonder how far can the non-rectangular go in Java?(and yes I understand you can create the appearance of non-rectangular components already but if it was baked in the cake it may just be easier).

thoughts folks?
leouser

alexfromsun

Posts: 404
Re: If Windows were allowed to be non-rectangular,should Components be as w
Posted: Aug 17, 2006 9:28 AM   in response to: leouser
  Click to reply to this thread Reply

Hello Brian

I know that AWT guys are investigating a way to support lightweight/heavyweight mixing

If this is implemented it would be very close to nonrectagular components

alexp

Joshua Marinacci
Re: If Windows were allowed to be non-rectangular,should Components be
as w

Posted: Aug 17, 2006 10:02 AM   in response to: alexfromsun
  Click to reply to this thread Reply

Are you saying that you want components in general or AWT components
to be shaped? AWT components would have to be fixed with the
lightweight/heavyweight mixing mechanism. I'm also hoping that such
things would let us embed arbitrary components from other apps inside
of a Swing app, say an Excel OLE control, or the webbrowser.

- Josh


On Aug 17, 2006, at 9:28 AM, swing@javadesktop.org wrote:

> Hello Brian
>
> I know that AWT guys are investigating a way to support lightweight/
> heavyweight mixing
>
> If this is implemented it would be very close to nonrectagular
> components
>
> alexp
> [Message sent by forum member 'alexfromsun' (alexfromsun)]
>
> http://forums.java.net/jive/thread.jspa?messageID=143965

- Blasting forth in three part harmony!


[att1.html]


leouser

Posts: 1,160
Re: If Windows were allowed to be non-rectangular,should Components be
as

Posted: Aug 17, 2006 10:18 AM   in response to: Joshua Marinacci
  Click to reply to this thread Reply

'Are you saying that you want components in general or AWT components
to be shaped?'

I think you are asking:
1. Anything that subclasses Component
or
2. Any Component in the AWT package.

In that case, the question was in case 1. I at this moment don't have a need for a snake shaped button by the way.

BH

Joshua Marinacci
Re: If Windows were allowed to be non-rectangular,should Components be
as

Posted: Aug 17, 2006 10:31 AM   in response to: leouser
  Click to reply to this thread Reply

The reason I ask is that you can make shaped JComponent classes. You
can override painting and the contains method to make your buttons be
shaped. This won't work for AWT components, of course, because that's
outside of Java's control right now.

- Josh


On Aug 17, 2006, at 10:18 AM, swing@javadesktop.org wrote:

> 'Are you saying that you want components in general or AWT components
> to be shaped?'
>
> I think you are asking:
> 1. Anything that subclasses Component
> or
> 2. Any Component in the AWT package.
>
> In that case, the question was in case 1. I at this moment don't
> have a need for a snake shaped button by the way.
>
> BH
> [Message sent by forum member 'leouser' (leouser)]
>
> http://forums.java.net/jive/thread.jspa?messageID=144005

- Blasting forth in three part harmony!


[att1.html]


alexfromsun

Posts: 404
Re: If Windows were allowed to be non-rectangular,should Components be
Posted: Aug 17, 2006 10:42 AM   in response to: Joshua Marinacci
  Click to reply to this thread Reply

Hello Josh

Overriding paint() and contains() work if you dont add children to a component, so it will work for JButtons,
but not for JPanels with arbitrary lightweight inside

So we support shaped JComponents in a limited way

alexp

leouser

Posts: 1,160
Re: If Windows were allowed to be non-rectangular,should Components be as w
Posted: Aug 17, 2006 10:22 AM   in response to: alexfromsun
  Click to reply to this thread Reply

'Hello Brian

I know that AWT guys are investigating a way to support lightweight/heavyweight mixing

If this is implemented it would be very close to nonrectagular components

alexp'

I bet that would help solve the JInternalFrame/Heavyweight mixing problem. I took a peek at how things are painted in AWT and it seems like there is some native painting going on that is clobering the Swing painting. It seemed like a buffer of the last time the widget was drawn was being stored in some unseen place and being redrawn when the widget was moved.

BH

ewin

Posts: 39
Re: If Windows were allowed to be non-rectangular,should Components be as w
Posted: Aug 20, 2006 1:29 AM   in response to: leouser
  Click to reply to this thread Reply

The irony is, Swing does support non-rectangular windows - if you use Java on a Mac. It is just that the Sun engineers are once more busy adding nonsense features to Swing, instead of finally geting things right in their JRE implementation and implementing APIs as defined.

On a Mac you get a non-rectangular Window by just using the API as described:

* Set the background of a top-level window to Color(0, 0, 0, 0). That is, set the background to transparent.

* Turn the normal window decoration off

* Use an image with an alpha-component to represent the non-rectangular window background. The image should be non-transparent where you want to have the window contents, and transparent where you want to see the desktop sine through.

* paint that image as the window background.

* place components on the window as normal. It probably pays off to use a custom layout manager which ensures you can't place components outside of the non-transparent part of the background window.

Of course the Sun engineers couldn't be bothered to implement transparency for top-level windows. It is just too hard for them. They are more busy writing yet another cool demo for some conference.

oleg_sukhodolsky

Posts: 87
Re: If Windows were allowed to be non-rectangular,should Components be as w
Posted: Aug 20, 2006 1:59 AM   in response to: ewin
  Click to reply to this thread Reply

I think the problem is that not all native systems provide
appropriate support for this feature :(

leouser

Posts: 1,160
Re: If Windows were allowed to be non-rectangular,should Components be as w
Posted: Aug 20, 2006 7:48 AM   in response to: ewin
  Click to reply to this thread Reply

Hmmm, interesting. It seems like on Mac you'd can make it look that way. But does it feel that way? If I click on the transparent part of the window and drag, does the Window still drag?

leouser

Joshua Marinacci
Re: If Windows were allowed to be non-rectangular,should Components be
as w

Posted: Aug 20, 2006 10:35 AM   in response to: leouser
  Click to reply to this thread Reply

The window will still drag if you click in the transparent area. It's
just a clever hack.

In response to the previous poster, it is very difficult to add
shaped and translucent window support if the OS does not support it
natively. XP supports shaped windows, but with limitations on the
mask. It also interferes with hardware acceleration. On X the support
depends on which extensions and video drivers you have. Doing a
quick version is easy. Doing it properly on all platforms is very
difficult.

It *is* on our list of things we would like to support for Java 7,
however.


- Josh

On Aug 20, 2006, at 7:48 AM, swing@javadesktop.org wrote:

> Hmmm, interesting. It seems like on Mac you'd can make it look
> that way. But does it feel that way? If I click on the
> transparent part of the window and drag, does the Window still drag?
>
> leouser
> [Message sent by forum member 'leouser' (leouser)]
>
> http://forums.java.net/jive/thread.jspa?messageID=144860

- Blasting forth in three part harmony!


[att1.html]


daeone

Posts: 3
Re: If Windows were allowed to be non-rectangular,should Components be
Posted: Dec 20, 2007 3:28 PM   in response to: Joshua Marinacci
  Click to reply to this thread Reply

we have a translucent, shaped window in a java application in mac os x. we are trying to implement sliders in the window. when we grab the slider to move, the entire window moves too. This applies also to scroll bars and any drag and drop component.

is there a way to disable the drag function from the java app, of an entire window in mac os x to allow us to use the sliders and scroll bars.

(this problem does not apply to Windows)

Joshua Marinacci
Re: If Windows were allowed to be non-rectangular,should Components be
Posted: Dec 20, 2007 4:57 PM   in response to: daeone
  Click to reply to this thread Reply

The window shouldn't be dragging itself when a component has focus.
Try adding a mouse pressed listener which will request the focus to
the slider when it is pressed.

- Josh
On Dec 20, 2007, at 6:28 PM, swing@javadesktop.org wrote:

> we have a translucent, shaped window in a java application in mac
> os x. we are trying to implement sliders in the window. when we
> grab the slider to move, the entire window moves too. This applies
> also to scroll bars and any drag and drop component.
>
> is there a way to disable the drag function from the java app, of
> an entire window in mac os x to allow us to use the sliders and
> scroll bars.
>
> (this problem does not apply to Windows)
> [Message sent by forum member 'daeone' (daeone)]
>
> http://forums.java.net/jive/thread.jspa?messageID=251052

Joshua Marinacci, Sun Engineer
http://weblogs.java.net/blog/joshy/
joshua.marinacci@sun.com


[att1.html]


daeone

Posts: 3
Re: If Windows were allowed to be non-rectangular,should Components be
Posted: Jan 6, 2008 6:58 PM   in response to: Joshua Marinacci
  Click to reply to this thread Reply

It does not work for me, I tried this code on MAC:

public static void main(String [] args) {
JFrame jFrame = new JFrame();
JTextArea jTextArea = new JTextArea("test");
jFrame.add(jTextArea);
jFrame.setBackground(new Color(0,0,0,150));
jFrame.setVisible(true);
}

If you try to select with your mouse by clicking and dragging from the end to the begin of the text ("test") in the text box, the window dragging, and It should not...? the text box got the focus!

I tried it on MAC OS X 10.4.11 with the JVM 1.5

Thanks!




 XML java.net RSS