Skip to main content

The panel refuses to show

No replies
anzalaya
Offline
Joined: 2010-04-29
Points: 0

As a part of a bigger graphical interface, I need a 410x350 modal window with a green panel inside, for some reason the modal window appears fine but nothing seems to be on it. Could somebody have a look a tell me what I'm forgetting please, I'm losing my mind here.

public class Test2 extends javax.swing.JFrame {

public javax.swing.JDialog connect_dialog;
private javax.swing.JPanel connect_panel;

public Test2(){
connect_dialog=new javax.swing.JDialog();
connect_panel = new javax.swing.JPanel();
connect_dialog.setAlwaysOnTop(true);
connect_dialog.setBounds(new java.awt.Rectangle(50, 50, 410, 350));
connect_dialog.setMinimumSize(new java.awt.Dimension(410, 350));
connect_dialog.setMinimumSize(new java.awt.Dimension(410, 350));
connect_dialog.setPreferredSize(new java.awt.Dimension(410, 350));
connect_dialog.setModal(true);
connect_dialog.setResizable(false);
connect_dialog.setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);

connect_panel.setBackground(new java.awt.Color(39, 163, 101));
connect_panel.setLayout(null);

javax.swing.GroupLayout connect_dialogLayout = new javax.swing.GroupLayout(connect_dialog.getContentPane());

connect_dialog.getContentPane().setLayout(connect_dialogLayout);
connect_dialogLayout.setHorizontalGroup(
connect_dialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(connect_panel, javax.swing.GroupLayout.DEFAULT_SIZE, 410, Short.MAX_VALUE)
);
connect_dialogLayout.setVerticalGroup(
connect_dialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(connect_panel, javax.swing.GroupLayout.DEFAULT_SIZE, 350, Short.MAX_VALUE)
);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 410, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 350, Short.MAX_VALUE)
);
pack();
}

public static void main (String[] args){
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Test2().setVisible(true);
}
});
}
}