Jframe stuck to another Jframe

0

Good!

I have to first make a jFrame [the black] with a comboBox that will make, depending on the chosen option, a 2nd jFrame [the green], but I want that whenever the 2nd jframe is generated, it is' anchored 'so to the base of the 1st jframe, as well as the image.

The "easy" would be to say that my 1st frame always appears at a certain point, and based on that, the second one appears, but I want, apart, that when dragging the 1st or 2nd frame, both move. p>

I hope to explain. Thanks in advance.

    
asked by José Herrera Avila 28.07.2017 в 18:48
source

1 answer

0

What you should do is have a general frame, and inside two containers (JPanel) where you are placing your components: In the constructor of your class that extends JFrame:

........
setBounds(100, 100, 800, 600); 
getContentPane().setLayout(null);
JPanel contentPanel1 = new JPanel(); 
contentPanel1.setBounds(0, 0, 200, 300); 
getContentPane().add(contentPanel1); 
contentPanel1.setLayout(null);
JPanel contentPanel2 = new JPanel(); 
contentPanel2.setBounds(0, 300, 400, 300); 
getContentPane().add(contentPanel2); 
contentPanel2.setLayout(null);

Inside those containers you are placing the components you want. The position of each container is handled with the setBounds (x, y, width, height) method. Where x and and are the starting points, and the other two are the width and height of the container

    
answered by 28.07.2017 / 19:34
source