我是新手,下面只是想显示如图界面,但显示不出来,各位麻烦看一下
我是新手,下面只是想显示如图界面,但显示不出来,各位麻烦看一下:
public class AddStudentFrame extends javax.swing.JFrame {
/** Creates new form AddStudentFrame */
public AddStudentFrame() {
initComponents();
}
// @SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabelStudentID = new javax.swing.JLabel();
jLabelGender = new javax.swing.JLabel();
jLabelGrade = new javax.swing.JLabel();
jLabelPhoneNum = new javax.swing.JLabel();
jLabelStudentName = new javax.swing.JLabel();
jTextFieldName = new javax.swing.JTextField();
jTextFieldStudentID = new javax.swing.JTextField();
jTextFieldGrade = new javax.swing.JTextField();
jTextFieldPhoneNum = new javax.swing.JTextField();
jRadioButton1 = new javax.swing.JRadioButton();
jRadioButton2 = new javax.swing.JRadioButton();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabelStudentID.setText("学号:");
jLabelGender.setText("性别:");
jLabelGrade.setText("班级:");
jLabelPhoneNum.setText("联系电话:");
jLabelStudentName.setText("姓名:");
jRadioButton1.setSelected(true);
jRadioButton1.setText("男");
jRadioButton2.setText("女");
jButton1.setText("确定");
jButton2.setText("取消");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(48, 48, 48)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabelStudentName)
.addComponent(jLabelStudentID)
.addComponent(jLabelGender)
.addComponent(jLabelGrade)
.addComponent(jLabelPhoneNum)
.addComponent(jButton1))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(42, 42, 42)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jTextFieldGrade)
.addComponent(jTextFieldStudentID)
.addComponent(jTextFieldPhoneNum)
.addComponent(jTextFieldName, javax.swing.GroupLayout.DEFAULT_SIZE, 71, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addComponent(jRadioButton1)
.addGap(18, 18, 18)
.addComponent(jRadioButton2)))
.addContainerGap(158, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton2)
.addGap(99, 99, 99))))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(52, 52, 52)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabelStudentName)
.addComponent(jTextFieldName, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabelStudentID)
.addComponent(jTextFieldStudentID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabelGender)
.addComponent(jRadioButton1)
.addComponent(jRadioButton2))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabelGrade)
.addComponent(jTextFieldGrade, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabelPhoneNum)
.addComponent(jTextFieldPhoneNum, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 27, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton1)
.addComponent(jButton2))
.addGap(19, 19, 19))
);
pack();
}// </editor-fold>
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new AddStudentFrame().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JLabel jLabelGender;
private javax.swing.JLabel jLabelGrade;
private javax.swing.JLabel jLabelPhoneNum;
private javax.swing.JLabel jLabelStudentID;
private javax.swing.JLabel jLabelStudentName;
private javax.swing.JRadioButton jRadioButton1;
private javax.swing.JRadioButton jRadioButton2;
private javax.swing.JTextField jTextFieldGrade;
private javax.swing.JTextField jTextFieldName;
private javax.swing.JTextField jTextFieldPhoneNum;
private javax.swing.JTextField jTextFieldStudentID;
// End of variables declaration
}
lz,我运行的结果。