I have a JFrame
for a project, I have been asked to pass the window that had to be a secondary window, that is, open from another window that would be the main one.
Here is the code of the secondary window (Which should be able to open from the main window). It is in the same project and the same package.
package neuronaia;
import javax.swing.*;
public class Aprendizaje extends JFrame {
JFrame Ap = new JFrame();
Ap.setLayout(null);
Ap.setSize(350,350);
Ap.setTitle("Aprendizaje");
Ap.setDefaultCloseOperation(Ap.EXIT_ON_CLOSE);
Ap.setVisible(true);
Ap.setLocationRelativeTo(null);
//Instanciando Cuadros de Texto
JLabel lx1 = new JLabel("X1");
Ap.add(lx1);
lx1.setBounds(25, 15, 25, 20);
JTextField textx1 = new JTextField();
Ap.add(textx1);
textx1.setBounds(25, 35, 35, 30);
JLabel lx2 = new JLabel("X2");
Ap.add(lx2);
lx2.setBounds(125, 15, 25, 20);
JTextField textx2 = new JTextField();
Ap.add(textx2);
textx2.setBounds(125, 35, 35, 30);
JLabel ly1 = new JLabel("Y1");
Ap.add(ly1);
ly1.setBounds(250, 10, 25, 30);
JTextField texty1 = new JTextField();
Ap.add(texty1);
texty1.setBounds(250, 35, 35, 30);
JTextField textx1a = new JTextField();
Ap.add(textx1a);
textx1a.setBounds(25, 90, 35, 30);
JTextField textx2a = new JTextField();
Ap.add(textx2a);
textx2a.setBounds(125, 90, 35, 30);
JTextField texty1a = new JTextField();
Ap.add(texty1a);
texty1a.setBounds(250, 90, 35, 30);
JTextField textx1b = new JTextField();
Ap.add(textx1b);
textx1b.setBounds(25, 145, 35, 30);
JTextField textx2b = new JTextField();
Ap.add(textx2b);
textx2b.setBounds(125, 145, 35, 30);
JTextField texty1b = new JTextField();
Ap.add(texty1b);
texty1b.setBounds(250, 145, 35, 30);
JTextField textx1c = new JTextField();
Ap.add(textx1c);
textx1c.setBounds(25, 195, 35, 30);
JTextField textx2c = new JTextField();
Ap.add(textx2c);
textx2c.setBounds(125, 195, 35, 30);
JTextField texty1c = new JTextField();
Ap.add(texty1c);
texty1c.setBounds(250, 195, 35, 30);
//Fin cuadros de texto
//Botones
JButton button1 = new JButton("Aceptar");
Ap.add(button1);
button1.setBounds(75, 300, 100, 20);
This is the code of my main window. I want a button that opens the window of the Learning Class.
package neuronaia;
import javax.swing.*;
public class MainWindow extends JFrame {
public static void main(String[] args) {
// TODO Auto-generated method stub
JFrame Mw = new JFrame();
Mw.setLayout(null);
Mw.setSize(350,350);
Mw.setDefaultCloseOperation(Mw.EXIT_ON_CLOSE);
Mw.setVisible(true);
Mw.setLocationRelativeTo(null);
JButton Apr = new JButton("Aprendizaje");
Mw.add(Apr);
Apr.setBounds(50, 50, 150, 30);
}
}