Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #2925 > unrolled thread

Setting z-index in Swing

Started by"Mohammad Javad Dousti" <mohammad.javad.dousti@THRWHITE.remove-dii-this>
First post2011-04-27 15:41 +0000
Last post2011-04-27 15:42 +0000
Articles 5 — 3 participants

Back to article view | Back to comp.lang.java.gui


Contents

  Setting z-index in Swing "Mohammad Javad Dousti" <mohammad.javad.dousti@THRWHITE.remove-dii-this> - 2011-04-27 15:41 +0000
    Re: Setting z-index in Sw "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:41 +0000
      Re: Setting z-index in Sw "Mohammad Javad Dousti" <mohammad.javad.dousti@THRWHITE.remove-dii-this> - 2011-04-27 15:41 +0000
        Re: Setting z-index in Sw "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:41 +0000
          Re: Setting z-index in Sw "Chase Preuninger" <chase.preuninger@THRWHITE.remove-dii-this> - 2011-04-27 15:42 +0000

#2925 — Setting z-index in Swing

From"Mohammad Javad Dousti" <mohammad.javad.dousti@THRWHITE.remove-dii-this>
Date2011-04-27 15:41 +0000
SubjectSetting z-index in Swing
Message-ID<6dd368ff-e469-4792-ae64-05bdc934d990@a35g2000prf.googlegroups.com>
  To: comp.lang.java.gui
Hi,
1-I'm using absolute layout in Java. I want to set the z-index of my
component after adding them. How can I do so?
2-How can I get the X and Y of an added component in absolut layout?

BTW: I'm using JDK 1.6u2 with NetBeans 6.0. The absolute layout
address is:
new org.netbeans.lib.awtextra.AbsoluteLayout()

Thanks for your help.

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [next] | [standalone]


#2930 — Re: Setting z-index in Sw

From"Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this>
Date2011-04-27 15:41 +0000
SubjectRe: Setting z-index in Sw
Message-ID<7d650bee364bb@uwe>
In reply to#2925
  To: comp.lang.java.gui
Mohammad Javad Dousti wrote:
..
>1-I'm using absolute layout ..

Why? *

> ..in Java. 

Using absolute layouts is a bad idea in an X-plat, 
X-plaf, multi-VM language.

>..I want to set the z-index of my
>component after adding them. 

* What is this GUI that requires absolutely positioned,
overlapping components?  Some types of GUIs might be
better suited to a CardLayout that shows any one GUI
element (usually a panel with many other panels and
widgets inside it) a JTabbedPane or a JDesktopPane.

>..How can I do so?

Why do you want to do so?

>2-How can I get the X and Y of an added component in absolut layout?

One way would be to remember where you absolutely 
placed it in the first place (I would guess).  But also, 
you might try these methods listed in the JavaDocs
java.awt.Component.getLocation(java.awt.Point)
(as well as getX(), and getY() ).

-- 
Andrew Thompson
http://www.physci.org/

Message posted via http://www.javakb.com

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#2932 — Re: Setting z-index in Sw

From"Mohammad Javad Dousti" <mohammad.javad.dousti@THRWHITE.remove-dii-this>
Date2011-04-27 15:41 +0000
SubjectRe: Setting z-index in Sw
Message-ID<e77478f3-abc6-4b99-b895-ca4dcebc3e45@d21g2000prf.googlegroups.com>
In reply to#2930
  To: comp.lang.java.gui
On Dec 29, 7:51 am, "Andrew Thompson" <u32984@uwe> wrote:
> Mohammad Javad Dousti wrote:
>
> ..
>
> >1-I'm using absolute layout ..
>
> Why? *
>
> > ..in Java.
>
> Using absolute layouts is a bad idea in an X-plat,
> X-plaf, multi-VM language.
>
> >..I want to set the z-index of my
> >component after adding them.
>
> * What is this GUI that requires absolutely positioned,
> overlapping components?  Some types of GUIs might be
> better suited to a CardLayout that shows any one GUI
> element (usually a panel with many other panels and
> widgets inside it) a JTabbedPane or a JDesktopPane.
>
> >..How can I do so?
>
> Why do you want to do so?
>
> >2-How can I get the X and Y of an added component in absolut layout?
>
> One way would be to remember where you absolutely
> placed it in the first place (I would guess).  But also,
> you might try these methods listed in the JavaDocs
> java.awt.Component.getLocation(java.awt.Point)
> (as well as getX(), and getY() ).
>
> --
> Andrew Thompsonhttp://www.physci.org/
>
> Message posted viahttp://www.javakb.com

Because no other layout can do my work. I want to design a board game:
put the places as JButton and the player as another JButton and put it
on the places. But the arrangement of places is very specific! (Take a
look at http://en.wikipedia.org/wiki/Monopoly_(game))
As I said, the component doesn't know its X and Y (So we can't use
getX and getY)

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#2936 — Re: Setting z-index in Sw

From"Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this>
Date2011-04-27 15:41 +0000
SubjectRe: Setting z-index in Sw
Message-ID<7d66a1baeb133@uwe>
In reply to#2932
  To: comp.lang.java.gui
Mohammad Javad Dousti wrote:
>> ..
>>
>[quoted text clipped - 32 lines]

Please learn how to post in-line with trimming.
..
(Why AbsoluteLayout?)

>Because no other layout can do my work. 

Rot.  Whatever cannot be done in any single layout is
pretty simple to achieve with nested layouts.

>..I want to design a board game:
>put the places as JButton ..

JButtons do not make sense for the game place squares 
themselves, though perhaps as a D'n'D (Drag'n'Drop, as 
opposed to Dungeons and Dragons) DropTarget - probably 
implemented on a (custom) BoardPlacePanel that has a 
custom background, and is itself contained in a larger 
layout.*

>..and the player as another JButton and put it
>on the places. But the arrangement of places is very specific! 

*All* Java Layouts are very specific, and are also
very adaptive to the size and shape of the underlying 
components.  Lock down the size of the underlying
components, and the overall layout and size can
also be locked.

>..(Take a
>look at http://en.wikipedia.org/wiki/Monopoly_(game))

Monopoly, ..yes I'm familiar with it.  Please enclose
URLs in <>, to help prevent line wrap and incorrect parsing.
.look at <http://en.wikipedia.org/wiki/Monopoly_(game)>)

* Use a GridLayout for each of the four sides, around the 
borders of a BorderLayout.  Drop a GridBagLayout in the 
CENTER for the game cards, dice etc. D'n'D should be 
able to handle the rest.

You might be able to do the entire GUI in a GBL, 
here is a Periodic Table implemented in a* GBL.
<http://physci.org/jnlp/PToE.jnlp>
* Though their are some other layouts, and HTML 
formatting, thrown in for good measure.

>As I said, the component doesn't know its X and Y (So we can't use
>getX and getY)

I find that hard to believe.  What results when you call ? ..
  System.out.println( myGamePieceJButton.getX() );

-- 
Andrew Thompson
http://www.physci.org/

Message posted via http://www.javakb.com

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#2946 — Re: Setting z-index in Sw

From"Chase Preuninger" <chase.preuninger@THRWHITE.remove-dii-this>
Date2011-04-27 15:42 +0000
SubjectRe: Setting z-index in Sw
Message-ID<78ae038f-774e-4c2a-a13a-3e01a75c542c@i72g2000hsd.googlegroups.com>
In reply to#2936
  To: comp.lang.java.gui
I think there is such thing as JLayerd pane or something that does
that.

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.gui


csiph-web