| Author |
applyComponentOrientation: am i misunderstanding or something else...?
|
Esmaeil Ashrafi
Ranch Hand
Joined: Feb 22, 2010
Posts: 73
|
|
Hi,
i think the SSCCE will explain better:
As you will see after running the program, i expect (based on documentations for method applyComponentOrientation in Container) that not only childes of frame's content pane, but also childes of its childes (here is the buttons contained in panel) to be oriented as ordered.
Any explanation to clear me will be much appreciated.
P.S: I know i can use setComponentOrientation for each container, but if applyComponentOrientation does just as it declares, will be very efficient...
|
I'm really tired of being engaged with stuff other than Java and programming
Wish to get back soon to my love...
|
 |
Mark E Hansen
Ranch Hand
Joined: Apr 01, 2009
Posts: 639
|
|
What is it that's not working for you? When I run it, I see the JPanel named panel on the right, and button1 on the left.
The RTL orientation was set on the content pane for the JFrame, so this seems correct.
What seems confusing about this code is the labels used on the two buttons placed in panel. They imply that the buttons will be positioned RTL within panel, but RTL orientation was not set on panel, so they seem to be laid out correctly to me.
|
 |
Esmaeil Ashrafi
Ranch Hand
Joined: Feb 22, 2010
Posts: 73
|
|
I see exactly what you see!
I know RTL for content pane childes applied, well, but i should say this for second time:
based on documentations for method applyComponentsOrientation, below:
So i expect the panel set to RTL automaticalyy because of using this method.
I labeled the buttons in panel to clarify the issue.
another matter of fact is if applyComponentOrientation just does same thing as setComponentOrientation, what's the difference ?!
|
 |
Mark E Hansen
Ranch Hand
Joined: Apr 01, 2009
Posts: 639
|
|
The documentation for Component.setComponentOrientation() says that it will apply to the component only, while the documentation for Component.applyComponentOrientation() says that it will apply to the component and all components contained within it.
I wonder if your panel is not affected because it is added to the container after making the applyComponentOrientation() call? Try making that call after adding everything to see what happens.
Otherwise, I'm not sure what is happening.
|
 |
Esmaeil Ashrafi
Ranch Hand
Joined: Feb 22, 2010
Posts: 73
|
|
Mark E Hansen wrote:...
I wonder if your panel is not affected because it is added to the container after making the applyComponentOrientation() call? Try making that call after adding everything to see what happens.
...
Excellent, twice excellent, more excellent to you
I wanted to prepare myself to say "No difference", but took your suggestion and that worked perfect !
(i just applied the orientation in line #27 of SSCCE)
This was really annoying me, because i had to type more extra codes and setComponentOrientation for each component seperately and ...to make GUI of my application RTL oriented.
And this was a while i wa thinking about that and today decided to write an example and ask the Ranch to help
Thank you very much Mark
|
 |
 |
|
|
subject: applyComponentOrientation: am i misunderstanding or something else...?
|
|
|