I want to create User Login page, but i have no idea about this, any idea for me? because just start to learn java, but i need create Login page....

Recommended Answers

All 11 Replies

Using a desktop application or a web application??

I just wan create for a system login, just for admin to login the system.no need web application.

have you worked with Swing before?

create a DBConnection (since I think you'll want your passwords and usernames to be stored in a DB) and write a frame with contains two input fields.

what have you got this far?

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.

i just design the login interface. The problem i face is i don't know how to continue after design.

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.

ok, i will try it. Thanks for giving advise.:)....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.

how to load an image into the frame? Because i'm implementing a MOTOR PLATE RECOGNITION SYSTEM.

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


}

what do you mean by your last post? do you have a question about that code?
also, put it between Code-tags, it 'll be a lot easier to read

because it cannot load image into the panel. i'm facing this problem. And do you have any idea about java doing image processing, character segmentation? Thanks for ur replay.:)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.