2 changed files with 156 additions and 0 deletions
Unified View
Diff Options
-
156LoginFrame.java
-
0filename
@ -0,0 +1,156 @@ |
|||||
|
import java.awt.BorderLayout; |
||||
|
import java.awt.EventQueue; |
||||
|
|
||||
|
import javax.swing.JFrame; |
||||
|
import javax.swing.JPanel; |
||||
|
import javax.swing.border.EmptyBorder; |
||||
|
import java.awt.SystemColor; |
||||
|
import java.awt.Color; |
||||
|
import javax.swing.JLabel; |
||||
|
import javax.swing.JOptionPane; |
||||
|
import javax.swing.JCheckBox; |
||||
|
import javax.swing.JButton; |
||||
|
import java.awt.Font; |
||||
|
import java.awt.Image; |
||||
|
|
||||
|
import javax.swing.JTextField; |
||||
|
import javax.swing.JPasswordField; |
||||
|
import javax.swing.ImageIcon; |
||||
|
import javax.swing.UIManager; |
||||
|
import java.awt.event.ActionListener; |
||||
|
import java.io.File; |
||||
|
import java.io.FileNotFoundException; |
||||
|
import java.util.Scanner; |
||||
|
import java.awt.event.ActionEvent; |
||||
|
|
||||
|
public class LoginFrame extends JFrame { |
||||
|
|
||||
|
private JPanel contentPane; |
||||
|
//private Image img_logo = new ImageIcon(LoginFrame.class.getResource("C:\\\\Users\\\\skc\\\\Pictures\\\\Top-best-Android-Apps-to-watch-and-stream-free-movies-online.jpg")).getImage().getScaledInstance(90, 90,Image.SCALE_SMOOTH); |
||||
|
private JTextField tf_login; |
||||
|
|
||||
|
boolean found=false; |
||||
|
/** |
||||
|
* Launch the application. |
||||
|
*/ |
||||
|
public static void main(String[] args) { |
||||
|
EventQueue.invokeLater(new Runnable() { |
||||
|
public void run() { |
||||
|
try { |
||||
|
LoginFrame frame = new LoginFrame(); |
||||
|
frame.setVisible(true); |
||||
|
} catch (Exception e) { |
||||
|
e.printStackTrace(); |
||||
|
} |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Create the frame. |
||||
|
*/ |
||||
|
public LoginFrame() { |
||||
|
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
||||
|
setBounds(100, 100, 406, 435); |
||||
|
contentPane = new JPanel(); |
||||
|
contentPane.setBackground(new Color(0, 0, 51)); |
||||
|
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); |
||||
|
setContentPane(contentPane); |
||||
|
contentPane.setLayout(null); |
||||
|
|
||||
|
JPanel panel = new JPanel(); |
||||
|
panel.setBackground(new Color(0, 0, 51)); |
||||
|
panel.setBounds(30, 41, 329, 295); |
||||
|
contentPane.add(panel); |
||||
|
panel.setLayout(null); |
||||
|
|
||||
|
JLabel lblNewLabel = new JLabel("Login Details"); |
||||
|
lblNewLabel.setFont(new Font("Tahoma", Font.BOLD, 24)); |
||||
|
lblNewLabel.setForeground(new Color(255, 255, 255)); |
||||
|
lblNewLabel.setBounds(72, 32, 233, 37); |
||||
|
panel.add(lblNewLabel); |
||||
|
|
||||
|
JLabel lbl_username = new JLabel("Enter UserName:"); |
||||
|
lbl_username.setForeground(new Color(255, 255, 255)); |
||||
|
lbl_username.setFont(new Font("Tahoma", Font.BOLD, 16)); |
||||
|
lbl_username.setBounds(72, 131, 183, 37); |
||||
|
panel.add(lbl_username); |
||||
|
|
||||
|
tf_login = new JTextField(); |
||||
|
tf_login.setBounds(72, 180, 170, 28); |
||||
|
panel.add(tf_login); |
||||
|
tf_login.setColumns(10); |
||||
|
|
||||
|
JButton btnLogin = new JButton("OK"); |
||||
|
btnLogin.addActionListener(new ActionListener() { |
||||
|
public void actionPerformed(ActionEvent e) { |
||||
|
String username= tf_login.getText(); |
||||
|
|
||||
|
//file importing for login credentials Manager |
||||
|
|
||||
|
File filex=new File("C:\\Users\\skc\\eclipse-workspace\\first\\Favorite_Movies\\src\\files\\login_cred.txt"); |
||||
|
Scanner scan; |
||||
|
|
||||
|
try { |
||||
|
scan = new Scanner(filex); |
||||
|
|
||||
|
scan.useDelimiter("[\n]"); |
||||
|
|
||||
|
|
||||
|
if(scan.hasNext() && !found ) { |
||||
|
|
||||
|
String line_ = scan.nextLine(); |
||||
|
|
||||
|
if(line_.equals(username)) { |
||||
|
|
||||
|
found=true; |
||||
|
if(found==true) { |
||||
|
JOptionPane.showMessageDialog(null,"Login Successful"); |
||||
|
|
||||
|
Main_HomePage mhp=new Main_HomePage(); |
||||
|
mhp.setVisible(true); |
||||
|
if(mhp.isVisible()) { |
||||
|
//use to display only one screen |
||||
|
LoginFrame.this.dispose(); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
else { |
||||
|
JOptionPane.showMessageDialog(null,"Enter Valid UserName !"); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
JOptionPane.showMessageDialog(null,"User Name not found !"); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
||||
|
else { |
||||
|
JOptionPane.showMessageDialog(null,"Please Try Again !"); |
||||
|
} |
||||
|
scan.close(); |
||||
|
} catch (FileNotFoundException e1) { |
||||
|
// TODO Auto-generated catch block |
||||
|
e1.printStackTrace(); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/*Main_HomePage mhp=new Main_HomePage(); |
||||
|
mhp.setVisible(true); |
||||
|
if(mhp.isVisible()) { |
||||
|
//use to display only one screen |
||||
|
LoginFrame.this.dispose(); |
||||
|
}*/ |
||||
|
} |
||||
|
}); |
||||
|
btnLogin.setBackground(UIManager.getColor("Button.light")); |
||||
|
btnLogin.setBounds(117, 233, 89, 23); |
||||
|
panel.add(btnLogin); |
||||
|
|
||||
|
|
||||
|
} |
||||
|
|
||||
|
} |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue