JFrame(window) not displaying at all
import java.sql.*;
import java.awt.event.*;
public class NewJPanel extends javax.swing.JFrame implements ActionListener {
// Variables declaration - do not modify
private InventoryConn conn;
// End of variables declaration
Statement stmt;
/** Creates new form NewJPanel */
public NewJPanel() {
super("Our Application");
initComponents();
add.addActionListener(this);
conn = new InventoryConn();
}
/** 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() {
add = new javax.swing.JButton();
close = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
txtCategoryID = new javax.swing.JTextField();
txtCategoryName = new javax.swing.JTextField();
setName("Form"); // NOI18N
org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(i nventory.InventoryApp.class).getContext().getResou rceMap(NewJPanel.class);
add.setText(resourceMap.getString("add.text")); // NOI18N
add.setName("add"); // NOI18N
close.setText(resourceMap.getString("close.text")) ; // NOI18N
close.setName("close"); // NOI18N
jLabel1.setText(resourceMap.getString("jLabel1.tex t")); // NOI18N
jLabel1.setName("jLabel1"); // NOI18N
jLabel2.setText(resourceMap.getString("jLabel2.tex t")); // NOI18N
jLabel2.setName("jLabel2"); // NOI18N
txtCategoryID.setText(resourceMap.getString("txtCa tegoryID.text")); // NOI18N
txtCategoryID.setName("txtCategoryID"); // NOI18N
txtCategoryName.setText(resourceMap.getString("txt CategoryName.text")); // NOI18N
txtCategoryName.setName("txtCategoryName"); // NOI18N
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout .Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(95, 95, 95)
.addComponent(add)
.addGap(72, 72, 72)
.addComponent(close))
.addGroup(layout.createSequentialGroup()
.addGap(82, 82, 82)
.addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING)
.addComponent(jLabel1)
.addComponent(jLabel2))
.addGap(41, 41, 41)
.addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING, false)
.addComponent(txtCategoryName)
.addComponent(txtCategoryID, javax.swing.GroupLayout.DEFAULT_SIZE, 115, Short.MAX_VALUE))))
.addContainerGap(87, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout .Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILI NG, layout.createSequentialGroup()
.addGap(34, 34, 34)
.addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(txtCategoryID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(37, 37, 37)
.addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(txtCategoryName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.Component Placement.RELATED, 85, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.BASELINE)
.addComponent(add)
.addComponent(close))
.addGap(81, 81, 81))
);
}// </editor-fold>
// Variables declaration - do not modify
private javax.swing.JButton add;
private javax.swing.JButton close;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JTextField txtCategoryID;
private javax.swing.JTextField txtCategoryName;
// End of variables declaration
public static void main(String args[]) {
NewJPanel panel = new NewJPanel();
panel.initComponents();
}
public void actionPerformed(ActionEvent e) {
// throw new UnsupportedOperationException("Not supported yet.");
if (e.getSource() == add) {
try {
stmt = conn.con.createStatement();
stmt.executeUpdate("INSERT INTO category "
+ "VALUES (1001, 'Simpson')");
} catch (Exception ee) {
}
}
}
}