hi
can someone tell me why my jframe is not showing. i have it as set visible but it is still not showing.
havent started doing any coding as yet except for the exit button
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | package AttendanceRecordSystem; import javax.swing.*; public class StudentRegistrationForm extends javax.swing.JFrame { public StudentRegistrationForm() { initComponents(); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings ( "unchecked" ) // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { jPanel1 = new javax.swing.JPanel(); jLabel2 = new javax.swing.JLabel(); stdIDlbl = new javax.swing.JLabel(); jtxtstdID = new javax.swing.JTextField(); lblfName = new javax.swing.JLabel(); jtxtfname = new javax.swing.JTextField(); lblLname = new javax.swing.JLabel(); jtxtlnname = new javax.swing.JTextField(); lblstdage = new javax.swing.JLabel(); jtxtage = new javax.swing.JTextField(); jbtncancel = new javax.swing.JButton(); jbtnsave = new javax.swing.JButton(); jbtnexit = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); getContentPane().setLayout( null ); jPanel1.setBackground( new java.awt.Color( 0 , 153 , 153 )); jPanel1.setLayout( null ); jLabel2.setIcon( new javax.swing.ImageIcon(getClass().getResource( "/AttendanceRecordSystem/costaatt.jpg" ))); // NOI18N jPanel1.add(jLabel2); jLabel2.setBounds( 10 , 10 , 170 , 170 ); stdIDlbl.setFont( new java.awt.Font( "Cambria" , 3 , 12 )); // NOI18N stdIDlbl.setText( "Student ID" ); jPanel1.add(stdIDlbl); stdIDlbl.setBounds( 210 , 30 , 100 , 15 ); jtxtstdID.setFont( new java.awt.Font( "Cambria" , 3 , 12 )); // NOI18N jPanel1.add(jtxtstdID); jtxtstdID.setBounds( 360 , 30 , 140 , 21 ); lblfName.setFont( new java.awt.Font( "Cambria" , 3 , 12 )); // NOI18N lblfName.setText( "First Name" ); jPanel1.add(lblfName); lblfName.setBounds( 210 , 70 , 70 , 15 ); jtxtfname.setFont( new java.awt.Font( "Cambria" , 3 , 12 )); // NOI18N jPanel1.add(jtxtfname); jtxtfname.setBounds( 360 , 70 , 140 , 21 ); lblLname.setFont( new java.awt.Font( "Cambria" , 3 , 12 )); // NOI18N lblLname.setText( "Last Name" ); jPanel1.add(lblLname); lblLname.setBounds( 210 , 110 , 80 , 15 ); jtxtlnname.setFont( new java.awt.Font( "Cambria" , 3 , 12 )); // NOI18N jPanel1.add(jtxtlnname); jtxtlnname.setBounds( 360 , 110 , 140 , 21 ); lblstdage.setFont( new java.awt.Font( "Cambria" , 3 , 12 )); // NOI18N lblstdage.setText( "Age" ); jPanel1.add(lblstdage); lblstdage.setBounds( 210 , 160 , 80 , 15 ); jtxtage.setFont( new java.awt.Font( "Cambria" , 3 , 12 )); // NOI18N jPanel1.add(jtxtage); jtxtage.setBounds( 360 , 160 , 140 , 21 ); jbtncancel.setFont( new java.awt.Font( "Cambria" , 3 , 12 )); // NOI18N jbtncancel.setText( "Cancel" ); jPanel1.add(jbtncancel); jbtncancel.setBounds( 110 , 403 , 120 , 40 ); jbtnsave.setFont( new java.awt.Font( "Cambria" , 3 , 12 )); // NOI18N jbtnsave.setText( "Save" ); jPanel1.add(jbtnsave); jbtnsave.setBounds( 250 , 403 , 110 , 40 ); jbtnexit.setFont( new java.awt.Font( "Cambria" , 3 , 12 )); // NOI18N jbtnexit.setText( "Exit" ); jbtnexit.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jbtnexitActionPerformed(evt); } }); jPanel1.add(jbtnexit); jbtnexit.setBounds( 390 , 400 , 110 , 40 ); getContentPane().add(jPanel1); jPanel1.setBounds( 0 , 0 , 540 , 460 ); pack(); } // </editor-fold> private JFrame frame; private void jbtnexitActionPerformed(java.awt.event.ActionEvent evt) { frame = new JFrame( "Exit" ); if (JOptionPane.showConfirmDialog(frame, "Confirm if you want to exit" , "Clear TextField System" , JOptionPane.YES_NO_OPTION)== JOptionPane.YES_NO_OPTION); System.exit( 0 ); } /** * @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(StudentRegistrationForm. class .getName()).log(java.util.logging.Level.SEVERE, null , ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(StudentRegistrationForm. class .getName()).log(java.util.logging.Level.SEVERE, null , ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(StudentRegistrationForm. class .getName()).log(java.util.logging.Level.SEVERE, null , ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(StudentRegistrationForm. class .getName()).log(java.util.logging.Level.SEVERE, null , ex); } //</editor-fold> //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater( new Runnable() { @Override public void run() { new StudentRegistrationForm().setVisible( true ); } }); } |