при импорте Jpanel в другую Jpanel, я хочу, чтобы размер Jpanel из класса Home был таким же, как у Jpanel из calss tstone
это когда я запускаю приложение, он показывает Jpanel из класса Home внутри Jpanel из основного класса "tstone", но не одного и того же размера, я хочу иметь оба одинаковых размера благодаря alote
это класс tstone:
import java.awt.GraphicsEnvironment;
import javax.swing.JFrame;
import project.Dashboard;
import project.Home;
public class tstone extends javax.swing.JFrame {
Home main_home = new Home();
public tstone() {
initComponents();
tstone.this.setExtendedState(JFrame.MAXIMIZED_BOTH);
GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
tstone.this.setMaximizedBounds(env.getMaximumWindowBounds());
this.setLocationRelativeTo(null);
pane3.add(main_home.Forme_Home);
pane3.setVisible(true);
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
pane1 = new javax.swing.JPanel();
pane2 = new javax.swing.JPanel();
pane3 = new javax.swing.JPanel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setUndecorated(true);
pane1.setBackground(new java.awt.Color(153, 255, 204));
pane2.setBackground(new java.awt.Color(102, 102, 102));
javax.swing.GroupLayout pane2Layout = new javax.swing.GroupLayout(pane2);
pane2.setLayout(pane2Layout);
pane2Layout.setHorizontalGroup(
pane2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 303, Short.MAX_VALUE)
);
pane2Layout.setVerticalGroup(
pane2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 0, Short.MAX_VALUE)
);
pane3.setBackground(new java.awt.Color(204, 0, 102));
javax.swing.GroupLayout pane3Layout = new javax.swing.GroupLayout(pane3);
pane3.setLayout(pane3Layout);
pane3Layout.setHorizontalGroup(
pane3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 810, Short.MAX_VALUE)
);
pane3Layout.setVerticalGroup(
pane3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 613, Short.MAX_VALUE)
);
javax.swing.GroupLayout pane1Layout = new javax.swing.GroupLayout(pane1);
pane1.setLayout(pane1Layout);
pane1Layout.setHorizontalGroup(
pane1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pane1Layout.createSequentialGroup()
.addComponent(pane2, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(pane3, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
);
pane1Layout.setVerticalGroup(
pane1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(pane2, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(pane1Layout.createSequentialGroup()
.addGap(37, 37, 37)
.addComponent(pane3, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(pane1, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(pane1, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
pack();
}// </editor-fold>
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(tstone.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(tstone.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(tstone.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(tstone.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new tstone().setVisible(true);
}
});
}
// Variables declaration - do not modify
public javax.swing.JPanel pane1;
public javax.swing.JPanel pane2;
public javax.swing.JPanel pane3;
// End of variables declaration
}
и этот класс Home:
import java.awt.Dimension;
import java.awt.GridLayout;
import javax.swing.JFrame;
public class Home extends javax.swing.JFrame {
public Home() {
initComponents();
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void close(){
this.setVisible(false);
this.dispose();
}
@SuppressWarnings("unchecked")
private void initComponents() {
Forme_Home = new javax.swing.JDesktopPane();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jButton1.setText("jButton1");
jButton2.setText("jButton2");
Forme_Home.setLayer(jButton1, javax.swing.JLayeredPane.DEFAULT_LAYER);
Forme_Home.setLayer(jButton2, javax.swing.JLayeredPane.DEFAULT_LAYER);
javax.swing.GroupLayout Forme_HomeLayout = new javax.swing.GroupLayout(Forme_Home);
Forme_Home.setLayout(Forme_HomeLayout);
Forme_HomeLayout.setHorizontalGroup(
Forme_HomeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(Forme_HomeLayout.createSequentialGroup()
.addGap(402, 402, 402)
.addComponent(jButton1)
.addContainerGap(450, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
Forme_HomeLayout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(jButton2))
);
Forme_HomeLayout.setVerticalGroup(
Forme_HomeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
Forme_HomeLayout.createSequentialGroup()
.addGap(251, 251, 251)
.addComponent(jButton2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 315,
Short.MAX_VALUE)
.addComponent(jButton1))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(Forme_Home)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(Forme_Home)
);
pack();
}// </editor-fold>
// Variables declaration - do not modify
public javax.swing.JDesktopPane Forme_Home;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
// End of variables declaration
enter code here
}