| | |
Help!!!! User Login page with java
![]() |
Check out this tutorial on swing in case you want to get your GUI up and running and then you might want do some validations on the username and password either in the database (then you might want to look here for jdbc) or want to use Files instead.
Last edited by stephen84s; Feb 6th, 2009 at 5:10 am.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."
"How to ask questions the smart way ?"
"How to ask questions the smart way ?"
Now the next logical step would be you want to validate the user.
What you could do is store a username and a password in either a File or a table in a database for ex: MS Access (or Apache Derby which ships with the JDK I assume.)
And whenever anyone clicks on say the "Login" or "Submit" button you would have to first validate whether the user has actually entered a value in the Password and UserName fields (if not you could show him an error message using the dialog boxes of JOptionPane) but if a proper value is found in both the fields you validate the user against the values (for username and password) present in the File or the database.
If the username and password combination specified in the form fields matches what you have in the File (or a the database table), you could display a success message (using JOptionPane once again) and stop there itself or take him a new form where you might want to do some more processing.
What you could do is store a username and a password in either a File or a table in a database for ex: MS Access (or Apache Derby which ships with the JDK I assume.)
And whenever anyone clicks on say the "Login" or "Submit" button you would have to first validate whether the user has actually entered a value in the Password and UserName fields (if not you could show him an error message using the dialog boxes of JOptionPane) but if a proper value is found in both the fields you validate the user against the values (for username and password) present in the File or the database.
If the username and password combination specified in the form fields matches what you have in the File (or a the database table), you could display a success message (using JOptionPane once again) and stop there itself or take him a new form where you might want to do some more processing.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."
"How to ask questions the smart way ?"
"How to ask questions the smart way ?"
•
•
Join Date: Feb 2009
Posts: 7
Reputation:
Solved Threads: 0
public class FrameMain extends javax.swing.JFrame {
private CarSnapshot car;
public class RecognizeThread extends Thread {
FrameMain pFrame = null;
public RecognizeThread(FrameMain pFrame) {
this.pFrame = pFrame;
}
public void run() {
String recognizedText = "";
this.pFrame.recognitionLabel.setText("processing ...");
int index = this.pFrame.chooseIndex;
try {
/// recognizedText = Main.systemLogic.recognize(this.pFrame.car);
} catch (Exception ex) {
this.pFrame.recognitionLabel.setText("");
return;
}
this.pFrame.recognitionLabel.setText(recognizedText);
this.pFrame.fileListModel.fileList.elementAt(index).plateRecognition = recognizedText;
}
}
public class LoadImageThread extends Thread {
FrameMain pFrame = null;
String url = null;
public LoadImageThread(FrameMain pFrame, String url) {
this.pFrame = pFrame;
this.url = url;
}
public void run() {
try {
this.pFrame.car = new CarSnapshot(url);
this.pFrame.panelCarContent = this.pFrame.car.duplicate().getBi();
this.pFrame.panelCarContent = Photo.linearResizeBi(this.pFrame.panelCarContent,
this.pFrame.panelCar.getWidth(),
this.pFrame.panelCar.getHeight());
this.pFrame.panelCar.paint(this.pFrame.panelCar.getGraphics());
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
///CarSnapshot car;
BufferedImage panelCarContent;
JFileChooser fileChooser;
private FileListModel fileListModel;
int chooseIndex = -1;
/** Creates new form FrameMain */
public FrameMain() {
initComponents();
// init : file chooser
this.fileChooser = new JFileChooser();
this.fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
/////this.fileChooser.setFileFilter(new ImageFileFilter());
// init : window dimensions and visibility
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
int width = this.getWidth();
int height = this.getHeight();
this.setLocation((screenSize.width - width)/2,(screenSize.height - height)/2);
this.setVisible(true);
}
private void fileListValueChanged(javax.swing.event.ListSelectionEvent evt) {
int selectedNow = this.fileList.getSelectedIndex();
if (selectedNow != -1 && this.chooseIndex != selectedNow) {
this.recognitionLabel.setText(this.fileListModel.fileList.elementAt(selectedNow).plateRecognition);
this.chooseIndex = selectedNow;
// proceed selectedNow
String path = ((FileListModel.FileListModelEntry)this.fileListModel.getElementAt(selectedNow)).fullPath;
//this.showImage(path);
/// new LoadImageThread(this,path).start();
}
}
private void recognizeActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
/// String plate = null;
// namiesto tohto urobime thread plate = Main.systemLogic.recognize(this.car);
// thread code start
/// new RecognizeThread(this).start();
}
private void loadImageActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
int returnValue;
String fileURL;
this.fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
this.fileChooser.setDialogTitle("Load Image");
returnValue = this.fileChooser.showOpenDialog((Component)evt.getSource());
if (returnValue != this.fileChooser.APPROVE_OPTION) return;
fileURL = this.fileChooser.getSelectedFile().getAbsolutePath();
File selectedFile = new File(fileURL);
this.fileListModel = new FileListModel();
for (String nameOfFile : selectedFile.list()) {
///// if (!ImageFileFilter.accept(nameOfFile)) continue; // not a image
this.fileListModel.addFileListModelEntry(nameOfFile, selectedFile+File.separator+nameOfFile);
}
this.fileList.setModel(fileListModel);
}
private void exitMouseClicked(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
System.exit(0);
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new FrameMain().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JMenu exit;
private javax.swing.JMenu file;
private javax.swing.JList fileList;
private javax.swing.JScrollPane fileListScrollPane;
private javax.swing.JMenuBar jMenuBar1;
private javax.swing.JMenuItem loadImage;
private javax.swing.JPanel panelCar;
private javax.swing.JLabel recognitionLabel;
private javax.swing.JButton recognize;
// End of variables declaration
}
private CarSnapshot car;
public class RecognizeThread extends Thread {
FrameMain pFrame = null;
public RecognizeThread(FrameMain pFrame) {
this.pFrame = pFrame;
}
public void run() {
String recognizedText = "";
this.pFrame.recognitionLabel.setText("processing ...");
int index = this.pFrame.chooseIndex;
try {
/// recognizedText = Main.systemLogic.recognize(this.pFrame.car);
} catch (Exception ex) {
this.pFrame.recognitionLabel.setText("");
return;
}
this.pFrame.recognitionLabel.setText(recognizedText);
this.pFrame.fileListModel.fileList.elementAt(index).plateRecognition = recognizedText;
}
}
public class LoadImageThread extends Thread {
FrameMain pFrame = null;
String url = null;
public LoadImageThread(FrameMain pFrame, String url) {
this.pFrame = pFrame;
this.url = url;
}
public void run() {
try {
this.pFrame.car = new CarSnapshot(url);
this.pFrame.panelCarContent = this.pFrame.car.duplicate().getBi();
this.pFrame.panelCarContent = Photo.linearResizeBi(this.pFrame.panelCarContent,
this.pFrame.panelCar.getWidth(),
this.pFrame.panelCar.getHeight());
this.pFrame.panelCar.paint(this.pFrame.panelCar.getGraphics());
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
///CarSnapshot car;
BufferedImage panelCarContent;
JFileChooser fileChooser;
private FileListModel fileListModel;
int chooseIndex = -1;
/** Creates new form FrameMain */
public FrameMain() {
initComponents();
// init : file chooser
this.fileChooser = new JFileChooser();
this.fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
/////this.fileChooser.setFileFilter(new ImageFileFilter());
// init : window dimensions and visibility
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
int width = this.getWidth();
int height = this.getHeight();
this.setLocation((screenSize.width - width)/2,(screenSize.height - height)/2);
this.setVisible(true);
}
private void fileListValueChanged(javax.swing.event.ListSelectionEvent evt) {
int selectedNow = this.fileList.getSelectedIndex();
if (selectedNow != -1 && this.chooseIndex != selectedNow) {
this.recognitionLabel.setText(this.fileListModel.fileList.elementAt(selectedNow).plateRecognition);
this.chooseIndex = selectedNow;
// proceed selectedNow
String path = ((FileListModel.FileListModelEntry)this.fileListModel.getElementAt(selectedNow)).fullPath;
//this.showImage(path);
/// new LoadImageThread(this,path).start();
}
}
private void recognizeActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
/// String plate = null;
// namiesto tohto urobime thread plate = Main.systemLogic.recognize(this.car);
// thread code start
/// new RecognizeThread(this).start();
}
private void loadImageActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
int returnValue;
String fileURL;
this.fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
this.fileChooser.setDialogTitle("Load Image");
returnValue = this.fileChooser.showOpenDialog((Component)evt.getSource());
if (returnValue != this.fileChooser.APPROVE_OPTION) return;
fileURL = this.fileChooser.getSelectedFile().getAbsolutePath();
File selectedFile = new File(fileURL);
this.fileListModel = new FileListModel();
for (String nameOfFile : selectedFile.list()) {
///// if (!ImageFileFilter.accept(nameOfFile)) continue; // not a image
this.fileListModel.addFileListModelEntry(nameOfFile, selectedFile+File.separator+nameOfFile);
}
this.fileList.setModel(fileListModel);
}
private void exitMouseClicked(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
System.exit(0);
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new FrameMain().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JMenu exit;
private javax.swing.JMenu file;
private javax.swing.JList fileList;
private javax.swing.JScrollPane fileListScrollPane;
private javax.swing.JMenuBar jMenuBar1;
private javax.swing.JMenuItem loadImage;
private javax.swing.JPanel panelCar;
private javax.swing.JLabel recognitionLabel;
private javax.swing.JButton recognize;
// End of variables declaration
}
![]() |
Similar Threads
- How to Connect MySQL from JSP Page (JSP)
- jsp code for values from database to textbox (JSP)
- redirect to login page if url of some entered (Java)
- LogIn page (Java)
- Plz help me out for the source code in java for login-logout (Java)
- Unable to view hotmail login page..... (Viruses, Spyware and other Nasties)
- Login page. JSP/Servlet (JSP)
Other Threads in the Java Forum
- Previous Thread: HELP!!
- Next Thread: jAVa_assistance
| Thread Tools | Search this Thread |
account android api applet application array arrays automation bidirectional binary birt bluetooth class classes client code columns component constructor database designadrawingapplicationusingjavajslider draw eclipse error errors exception expand fractal game givemetehcodez graphics gui guidancer homework html ide image inetaddress inheritance integer intellij j2me java javamicroeditionuseofmotionsensor javaprojects jlabel jme jni jpanel jtextfield jtree julia linux list loop map method methods midlethttpconnection mobile mobiledevelopmentcreatejar monitoring myaggfun netbeans newbie nullpointerexception open-source oracle plazmic print problem program project property recursion ria scanner search server set sharepoint smart sms smsspam sort sourcelabs splash sql sqlite static string subclass support swing testautomation threads tree unlimited webservices windows







....actually i need to implement a motor plate recognition system by using java language.Anyone have any idea? I just got 2 more months to develop this system.