Computer Science Canada

Setting JFrame relative to another Jframe

Author:  Benner [ Wed May 29, 2013 5:39 pm ]
Post subject:  Setting JFrame relative to another Jframe

Hi, i'm just going to paste this from my yahoo answers question... Very Happy


Hi. This is what my program looks like:

Posted Image, might have been reduced in size. Click Image to view fullscreen.

When I click a button, I want to setVisible two jframes on the sides of the main, center frame. How would I do that? I think I need to use the setLocationRelativeTo() method, but I don't know what to put as parameters. I didn't have any luck when I tried to find the answer on oracles guides.

Any help is appreciated, thank you

If you don't know what I mean, what I want to do is below:

Posted Image, might have been reduced in size. Click Image to view fullscreen.

Thanks[/img]

Author:  Benner [ Wed May 29, 2013 5:57 pm ]
Post subject:  Re: Setting JFrame relative to another Jframe

I know it's not good to have multiple Jframes at the same time, but the way I am doing my gui it would be the easiest thing to do. Right now my "gui" is just dozens of images and mouselisteners etc, where when the user clicks on a button, the image on the screen changes to the image where that button is selected. So really the only components I have at the moment is one Jframe and one JLabel.

I'm thinking a better thing to do would to just have one jframe, that covers the entire screen, and use a card layout to position four Jlabels as I have them arranged in the picture. I know I'm doing a lot of things the "wrong way" but I have a project due in about 14 hours and I'm trying to make a visually appealing gui with my limited skills in swing. So please to save your time don't suggest I re-do everything "the right way", because I do appreciate it but I just don't have time right now.


: