Java JFrame表单源文件错误
我正在使用MVC模型在NetBeans 8.0.1中开发一个登录表单,代码中没有错误,但是JFRAME源文件中自动生成的代码,JFRAME类中有错误。错误显示为:Java JFrame表单源文件错误,java,swing,jframe,Java,Swing,Jframe,我正在使用MVC模型在NetBeans 8.0.1中开发一个登录表单,代码中没有错误,但是JFRAME源文件中自动生成的代码,JFRAME类中有错误。错误显示为:重复类:com.innovatraasolutions.eev.ui.loginform? 在整个项目中不存在该类 /* * To change this license header, choose License Headers in Project Properties. * To change this template f
重复类:com.innovatraasolutions.eev.ui.loginform
?
在整个项目中不存在该类
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.innovatraasolutions.eev.ui;
import com.innovatraasolutions.eev.controller.Controller;
import com.innovatraasolutions.eev.constants.Constants;
/**
*
* @author SpiderMan
*/
**public class LoginForm extends javax.swing.JFrame//**there's an error**** {
/**
* 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() {
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
unameTxt = new javax.swing.JTextField();
jLabel3 = new javax.swing.JLabel();
pwdTxt = new javax.swing.JPasswordField();
loginBtn = new javax.swing.JButton();
errorMsgLbl = new javax.swing.JLabel();
jSeparator1 = new javax.swing.JSeparator();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowOpened(java.awt.event.WindowEvent evt) {
formWindowOpened(evt);
}
});
jLabel1.setText(" Effective Electronic Vote");
jLabel2.setText("UserName:");
jLabel3.setText("Password:");
loginBtn.setText("Login");
loginBtn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
loginBtnActionPerformed(evt);
}
});
errorMsgLbl.setForeground(new java.awt.Color(255, 0, 0));
errorMsgLbl.setText("Invalid Username or password");
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.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 263, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(153, 153, 153)
.addComponent(loginBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 138, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(107, 107, 107)
.addComponent(errorMsgLbl, javax.swing.GroupLayout.PREFERRED_SIZE, 308, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jSeparator1)
.addComponent(pwdTxt, javax.swing.GroupLayout.DEFAULT_SIZE, 228, Short.MAX_VALUE)))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addGap(84, 84, 84)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(unameTxt, javax.swing.GroupLayout.PREFERRED_SIZE, 228, javax.swing.GroupLayout.PREFERRED_SIZE)))))
.addContainerGap(206, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(23, 23, 23)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(32, 32, 32)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(unameTxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(1, 1, 1)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(pwdTxt, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(45, 45, 45)
.addComponent(loginBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(28, 28, 28)
.addComponent(errorMsgLbl, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(134, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void loginBtnActionPerformed(java.awt.event.ActionEvent evt) {
Controller controller = new Controller();
Object[] parameters = new Object[2]; //Generic Parameters to catch the username and password from the Text box and Password feild
Object returnobj = null;
parameters[0] = unameTxt.getText();
parameters[1] = pwdTxt.getPassword();
returnobj = controller.processRequest(Constants.LoginAction , parameters);
if(returnobj== null)
{
errorMsgLbl.setVisible(true);
//show the error Message here because the returnobj is null
}
else //Verfication Done
{
//Create new form hide this form and show the new form
}
}
private void formWindowOpened(java.awt.event.WindowEvent evt) {
errorMsgLbl.setVisible(false);
}
/**
* @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(LoginForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(LoginForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(LoginForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(LoginForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new LoginForm().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JLabel errorMsgLbl;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JSeparator jSeparator1;
private javax.swing.JButton loginBtn;
private javax.swing.JPasswordField pwdTxt;
private javax.swing.JTextField unameTxt;
// End of variables declaration
}
/*
*要更改此许可证标题,请在“项目属性”中选择“许可证标题”。
*要更改此模板文件,请选择工具|模板
*然后在编辑器中打开模板。
*/
包com.innovatorasolutions.eev.ui;
导入com.innovatraasolutions.eev.controller.controller;
导入com.innovatraasolutions.eev.constants.constants;
/**
*
*@作者蜘蛛侠
*/
**公共类LoginForm扩展了javax.swing.JFrame/**出现错误****{
/**
*创建新表单LoginForm
*/
公共登录表单(){
初始化组件();
}
/**
*从构造函数中调用此方法来初始化表单。
*警告:不要修改此代码。此方法的内容始终为
*由表单编辑器重新生成。
*/
@抑制警告(“未选中”)
//
私有组件(){
jLabel1=newjavax.swing.JLabel();
jLabel2=newjavax.swing.JLabel();
unameTxt=newjavax.swing.JTextField();
jLabel3=newjavax.swing.JLabel();
pwdTxt=newjavax.swing.JPasswordField();
loginBtn=newjavax.swing.JButton();
errorMsgLbl=newjavax.swing.JLabel();
jSeparator1=newjavax.swing.jsepator();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
addWindowListener(新java.awt.event.WindowAdapter(){
已打开公共无效窗口(java.awt.event.WindowEvent evt){
窗体窗口打开(evt);
}
});
jLabel1.setText(“有效电子投票”);
jLabel2.setText(“用户名:”);
jLabel3.setText(“密码:”);
loginBtn.setText(“登录”);
loginBtn.addActionListener(新的java.awt.event.ActionListener(){
public void actionPerformed(java.awt.event.ActionEvent evt){
执行登录操作(evt);
}
});
errorMsgLbl.set前台(新java.awt.Color(255,0,0));
errorMsgLbl.setText(“无效的用户名或密码”);
javax.swing.GroupLayout=newjavax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(布局);
layout.setHorizontalGroup(
createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.training)
.addComponent(jLabel1,javax.swing.GroupLayout.PREFERRED\u SIZE,263,javax.swing.GroupLayout.PREFERRED\u SIZE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(153153153)
.addComponent(loginBtn,javax.swing.GroupLayout.PREFERRED_SIZE,138,javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(107、107、107)
.addComponent(errorMsgLbl,javax.swing.GroupLayout.PREFERRED\u SIZE,308,javax.swing.GroupLayout.PREFERRED\u SIZE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.training)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel3,javax.swing.GroupLayout.PREFERRED\u SIZE,75,javax.swing.GroupLayout.PREFERRED\u SIZE)
.addGap(18,18,18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,false)
.addComponent(jSeparator1)
.addComponent(pwdTxt,javax.swing.GroupLayout.DEFAULT_SIZE,228,Short.MAX_VALUE)))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING,layout.createSequentialGroup()
.addGap(84,84,84)
.addComponent(jLabel2,javax.swing.GroupLayout.PREFERRED\u SIZE,75,javax.swing.GroupLayout.PREFERRED\u SIZE)
.addGap(18,18,18)
.addComponent(unameTxt,javax.swing.GroupLayout.PREFERRED_SIZE,228,javax.swing.GroupLayout.PREFERRED_SIZEщщ)
.addContainerGap(206,简称最大值))
);
layout.setVerticalGroup(
createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(23,23,23)
.addComponent(jLabel1,javax.swing.GroupLayout.PREFERRED_SIZE,55,javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(32,32,32)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2,javax.swing.GroupLayout.PREFERRED\u SIZE,24,javax.swing.GroupLayout.PREFERRED\u SIZE)
.addComponent(unameTxt,javax.swing.GroupLayout.PREFERRED\u SIZE,javax.swing.GroupLayout.DEFAULT\u SIZE,javax.swing.GroupLayout.PREFERRED\u SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jSeparator1,javax.swing.GroupLayout.PREFERRED\u SIZE,17,javax.swing.GroupLayout.PREFERRED\u SIZE)
.addGap(1,1,1)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLa