Find Error in This OOP Code :- package sample; import javax.swing.JOptionPane; public class Elestion extends javax.swing.JFrame { public Elestion() { initComponents(); } @SuppressWarnings("unchecked") private void initComponents() { jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); jTextField1 = new javax.swing.JTextField(); jTextField2 = new javax.swing.JTextField(); jComboBox1 = new javax.swing.JComboBox<>(); jComboBox2 = new javax.swing.JComboBox<>(); jComboBox3 = new javax.swing.JComboBox<>(); jButton1 = new javax.swing.JButton(); jPanel1 = new javax.swing.JPanel(); jPanel2 = new javax.swing.JPanel(); jPanel3 = new javax.swing.JPanel(); jLabel6 = new javax.swing.JLabel(); jLabel7 = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("Online_Election_System"); setBackground(new java.awt.Color(51, 51, 255)); getContentPane().setLayout(new org.eclips.lib.awtextra.AbsoluteLayout()); jLabel1.setText("Name "); getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 60, -1, -1)); jLabel2.setText("NNIC"); getContentPane().add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 110, -1, -1)); jLabel3.setText("Party"); getContentPane().add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 160, -1, -1)); jLabel4.setText("Provision"); getContentPane().add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 220, -1, -1)); jLabel5.setText("District"); getContentPane().add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 290, -1, -1)); getContentPane().add(jTextField1, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 60, 90, -1)); getContentPane().add(jTextField2, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 110, 90, -1)); jComboBox1.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "[Select party which you vote]", "Tehreek-e-Labbaik Pakistan", "Pakistan Tehreek-e-Insaf (PTI)", "Pakistan Muslim League (N) (PMLN)", "Pakistan People's Party (PPP)", "Jamaat-e-Islami Pakistan (JI)", "Pak Sarzameen Party (PSP)", "Awami National Party (ANP)", " ", " " })); getContentPane().add(jComboBox1, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 160, 90, -1)); jComboBox2.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "[Select ]", " ", " ", "Balochistan\tبلوچستان\tQuetta", "Khyber Pakhtunkhwa\tخیبرپختونخوا\tPeshawar", "Punjab\tپنجاب\tLahore", "Sindh\tسندھ\tKarachi" })); getContentPane().add(jComboBox2, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 220, 90, -1)); jComboBox3.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "[Select District]", " ", "Contents", "1\tBahawalpur Division", "1.1\tBahawalnagar District", "1.2\tBahawalpur District", "1.3\tRahim Yar Khan District", "2\tDera Ghazi Khan Division", "2.1\tDera Ghazi Khan District", "2.2\tLayyah District", "2.3\tMuzaffargarh District", "2.4\tRajanpur District", "3\tFaisalabad Division", "3.1\tChiniot District", "3.2\tFaisalabad District", "3.3\tJhang District", "3.4\tToba Tek Singh District", "4\tGujranwala Division", "4.1\tGujranwala District", "4.2\tGujrat District", "4.3\tHafizabad District", "4.4\tMandi Bahauddin District", "4.5\tNarowal District", "4.6\tSialkot District", "5\tLahore Division", "5.1\tKasur District", "5.2\tLahore District", "5.3\tNankana Sahib District", "5.4\tSheikhupura District", "6\tMultan Division", "6.1\tKhanewal District", "6.2\tLodhran District", "6.3\tMultan District", "6.4\tVehari District", "7\tRawalpindi Division", "7.1\tAttock District", "7.2\tChakwal District", "7.3\tJhelum District", "7.4\tRawalpindi District", "8\tSahiwal Division", "8.1\tOkara District", "9.4\tSargodha District" })); getContentPane().add(jComboBox3, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 280, 90, -1)); jButton1.setText("Submit"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); getContentPane().add(jButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 350, -1, -1)); jPanel3.setBackground(new java.awt.Color(255, 51, 51)); jLabel6.setBackground(new java.awt.Color(255, 255, 255)); jLabel6.setText("Online Election System"); jLabel7.setBackground(new java.awt.Color(51, 255, 0)); jLabel7.setText("Atif Zaib"); javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); jPanel3.setLayout(jPanel3Layout); jPanel3Layout.setHorizontalGroup( jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup() .addGap(133, 133, 133) .addComponent(jLabel6) .addContainerGap(176, Short.MAX_VALUE)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel7) .addGap(100, 100, 100)) ); }}
Find Error in This OOP Code :-
package sample;
import javax.swing.JOptionPane;
public class Elestion extends javax.swing.JFrame {
public Elestion() {
initComponents();
}
@SuppressWarnings("unchecked")
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jTextField1 = new javax.swing.JTextField();
jTextField2 = new javax.swing.JTextField();
jComboBox1 = new javax.swing.JComboBox<>();
jComboBox2 = new javax.swing.JComboBox<>();
jComboBox3 = new javax.swing.JComboBox<>();
jButton1 = new javax.swing.JButton();
jPanel1 = new javax.swing.JPanel();
jPanel2 = new javax.swing.JPanel();
jPanel3 = new javax.swing.JPanel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Online_Election_System");
setBackground(new java.awt.Color(51, 51, 255));
getContentPane().setLayout(new org.eclips.lib.awtextra.AbsoluteLayout());
jLabel1.setText("Name ");
getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 60, -1, -1));
jLabel2.setText("NNIC");
getContentPane().add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 110, -1, -1));
jLabel3.setText("Party");
getContentPane().add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 160, -1, -1));
jLabel4.setText("Provision");
getContentPane().add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 220, -1, -1));
jLabel5.setText("District");
getContentPane().add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 290, -1, -1));
getContentPane().add(jTextField1, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 60, 90, -1));
getContentPane().add(jTextField2, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 110, 90, -1));
jComboBox1.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "[Select party which you vote]", "Tehreek-e-Labbaik Pakistan", "Pakistan Tehreek-e-Insaf (PTI)", "Pakistan Muslim League (N) (PMLN)", "Pakistan People's Party (PPP)", "Jamaat-e-Islami Pakistan (JI)", "Pak Sarzameen Party (PSP)", "Awami National Party (ANP)", " ", " " }));
getContentPane().add(jComboBox1, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 160, 90, -1));
jComboBox2.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "[Select ]", " ", " ", "Balochistan\tبلوچستان\tQuetta", "Khyber Pakhtunkhwa\tخیبرپختونخوا\tPeshawar", "Punjab\tپنجاب\tLahore", "Sindh\tسندھ\tKarachi" }));
getContentPane().add(jComboBox2, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 220, 90, -1));
jComboBox3.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "[Select District]", " ", "Contents", "1\tBahawalpur Division", "1.1\tBahawalnagar District", "1.2\tBahawalpur District", "1.3\tRahim Yar Khan District", "2\tDera Ghazi Khan Division", "2.1\tDera Ghazi Khan District", "2.2\tLayyah District", "2.3\tMuzaffargarh District", "2.4\tRajanpur District", "3\tFaisalabad Division", "3.1\tChiniot District", "3.2\tFaisalabad District", "3.3\tJhang District", "3.4\tToba Tek Singh District", "4\tGujranwala Division", "4.1\tGujranwala District", "4.2\tGujrat District", "4.3\tHafizabad District", "4.4\tMandi Bahauddin District", "4.5\tNarowal District", "4.6\tSialkot District", "5\tLahore Division", "5.1\tKasur District", "5.2\tLahore District", "5.3\tNankana Sahib District", "5.4\tSheikhupura District", "6\tMultan Division", "6.1\tKhanewal District", "6.2\tLodhran District", "6.3\tMultan District", "6.4\tVehari District", "7\tRawalpindi Division", "7.1\tAttock District", "7.2\tChakwal District", "7.3\tJhelum District", "7.4\tRawalpindi District", "8\tSahiwal Division", "8.1\tOkara District", "9.4\tSargodha District" }));
getContentPane().add(jComboBox3, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 280, 90, -1));
jButton1.setText("Submit");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
getContentPane().add(jButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 350, -1, -1));
jPanel3.setBackground(new java.awt.Color(255, 51, 51));
jLabel6.setBackground(new java.awt.Color(255, 255, 255));
jLabel6.setText("Online Election System");
jLabel7.setBackground(new java.awt.Color(51, 255, 0));
jLabel7.setText("Atif Zaib");
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addGap(133, 133, 133)
.addComponent(jLabel6)
.addContainerGap(176, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel7)
.addGap(100, 100, 100))
);
}}
Step by step
Solved in 2 steps