Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / January 2008

Tip: Looking for answers? Try searching our database.

newbie JFileChooser question

Thread view: 
Larry.Martell@gmail.com - 03 Jan 2008 00:16 GMT
I want to display a JFileChooser that is centered over the parent
window.
When I pass in the parent to showOpenDialog the file chooser is
displayed
centered on where the parent window was initially displayed. That is,
if the
parent window was moved to a new location, then the file chooser is
NOT
centered on the new location. It's as if the initial location of the
parent window
is remembered and not updated if the window is moved. How can I get
the
file chooser dialog to come up centered on its parent's current
location?

TIA!
-larry
Brandon McCombs - 03 Jan 2008 01:28 GMT
> I want to display a JFileChooser that is centered over the parent
> window.
[quoted text clipped - 13 lines]
> TIA!
> -larry

In the code before you display the dialog, get the current location for
the parent window and pass those values as arguments into the
setLocation() method for the dialog itself. That should fix your problem.
Larry.Martell@gmail.com - 03 Jan 2008 15:57 GMT
> Larry.Mart...@gmail.com wrote:
> > I want to display a JFileChooser that is centered over the parent
[quoted text clipped - 18 lines]
> the parent window and pass those values as arguments into the
> setLocation() method for the dialog itself. That should fix your problem.

Thanks. This works when run on Mac and Windows, but it has no effect
when the program
is run on a Linux box and displayed back on a Windows box running
cygwin.

-larry
Lew - 03 Jan 2008 16:02 GMT
Brandon McCombs wrote:
>> In the code before you display the dialog, get the current location for
>> the parent window and pass those values as arguments into the
>> setLocation() method for the dialog itself. That should fix your problem.

> Thanks. This works when run on Mac and Windows, but it has no effect
> when the program
> is run on a Linux box and displayed back on a Windows box running
> cygwin.

Is that using the usual Cygwin 'xwin' with the 'multiwindow' option?

How are you connecting to the Linux box?  If with ssh, are you port-forwarding
the X session (-X or -Y option to ssh), or using a DISPLAY with the IP address
of the windows box?

If you log directly into the Linux box, does the technique work then?

Signature

Lew

Larry.Martell@gmail.com - 04 Jan 2008 21:16 GMT
> Brandon McCombs wrote:
> >> In the code before you display the dialog, get the current location for
[quoted text clipped - 7 lines]
>
> Is that using the usual Cygwin 'xwin' with the 'multiwindow' option?

Yes.

> How are you connecting to the Linux box?  If with ssh,

Yes.

> are you port-forwarding
> the X session (-X or -Y option to ssh), or using a DISPLAY with the IP address
> of the windows box?

I don't invoke ssh with the -X or -Y option, but I don't explicitly
set DISPLAY
either. I just ssh in, and it works. If I look at $DISPLAY it's set to
something
like "localhost:11.0"

> If you log directly into the Linux box, does the technique work then?

I don't know - my only access to the linux box is via ssh from my
Windows box.

-larry
Lew - 05 Jan 2008 00:35 GMT
Lew wrote:
>> are you port-forwarding
>> the X session (-X or -Y option to ssh), or using a DISPLAY with the IP address
>> of the windows box?

> I don't invoke ssh with the -X or -Y option,

It must be set in your ssh_config then.

> but I don't explicitly set DISPLAY either.
> I just ssh in, and it works. If I look at $DISPLAY it's set to
> something like "localhost:11.0"

This value shows us that it is a port-forwarded DISPLAY, so the X events are
traveling through the tunnel.  Non-port-forwarded would be a non-localhost
address.

>> If you log directly into the Linux box, does the technique work then?

> I don't know - my only access to the linux box is via ssh from my
> Windows box.

I can think of no reason why the technique should fail in your scenario.  Too
bad we can't see what happens natively on the Linux box.

Can you debug, e.g., run the program through your IDE, and see what values are
come in when you
>> get the current location for the parent window
in order to
>> pass those values as arguments into the setLocation() method for the dialog itself
(Brandon McCombs)?

This would narrow the behavior down to whether you're getting wrong
coordinates or failing to set correct ones.

Signature

Lew



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.