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....

8 Years
Discussion Span
Last Post by snail_snail21

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.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,
} catch (IOException ex) {

///CarSnapshot car;

BufferedImage panelCarContent;
JFileChooser fileChooser;
private FileListModel fileListModel;
int chooseIndex = -1;
/** Creates new form FrameMain */
public FrameMain() {
// init : file chooser
this.fileChooser = new JFileChooser();
/////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);
private void fileListValueChanged(javax.swing.event.ListSelectionEvent evt) {
int selectedNow = this.fileList.getSelectedIndex();

if (selectedNow != -1 && this.chooseIndex != selectedNow) {
this.chooseIndex = selectedNow;
// proceed selectedNow
String path = ((FileListModel.FileListModelEntry)this.fileListModel.getElementAt(selectedNow)).fullPath;
///  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.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);

private void exitMouseClicked(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:

* @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


Edited by happygeek: fixed formatting


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.:)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.