我有一个简单的登录表单,可以编译并且不显示任何编译或构建错误,但在我尝试运行它时不显示界面。我已经检查并设置了“setVisible(true)”,但仍然没有运气。我不完全确定问题是什么,但任何帮助将不胜感激。我正在使用 Netbeans IDE。这是源代码。
package client.system;
import java.awt.HeadlessException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.swing.JOptionPane;
public class LoginForm extends javax.swing.JPanel {
Connection con = null;
PreparedStatement pst = null;
ResultSet rs = null;
/**
* Creates new form LoginForm
*/
public LoginForm() {
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();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
username = new javax.swing.JTextField();
jLabel3 = new javax.swing.JLabel();
password = new javax.swing.JPasswordField();
login = new javax.swing.JButton();
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 20)); // NOI18N
jLabel1.setText("Log In");
jLabel2.setLabelFor(username);
jLabel2.setText("Username:");
username.setText("Username");
jLabel3.setLabelFor(password);
jLabel3.setText("Password:");
password.setText("Password");
login.setFont(new java.awt.Font("Tahoma", 0, 20)); // NOI18N
login.setText("Login");
login.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
loginActionPerformed(evt);
}
});
LEATH
相关分类