A online java game
Hallo me and my friends are scripting a java game we are starting smal hehe now my question is i just scripted a login screen here it is :
--
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class Login extends JPanel
{
private JLabel component1;
private JLabel component2;
private JTextField component3;
private JPasswordField component4;
private JButton component5;
private JButton component6;
public Login()
{
//construct components
component1 = new JLabel ("Username");
component2 = new JLabel ("Password");
component3 = new JTextField (5);
component4 = new JPasswordField (5);
component5 = new JButton ("Login");
component6 = new JButton ("Cancel");
//adjust size and set layout
setPreferredSize (new Dimension (253, 148));
setLayout (null);
//add components
add (component1);
add (component2);
add (component3);
add (component4);
add (component5);
add (component6);
//set component bounds
component1.setBounds (20, 20, 70, 25);
component2.setBounds (20, 60, 70, 25);
component3.setBounds (95, 20, 120, 25);
component4.setBounds (95, 60, 120, 25);
component5.setBounds (15, 105, 100, 25);
component6.setBounds (135, 105, 100, 25);
}
public static void main (String[] args)
{
JFrame frame = new JFrame ("Login Screen");
frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add (new Login());
frame.pack();
frame.setVisible (true);
}
}
-
as you can see there is a login button a password box etc ... but how can i make the login button connect to the database and check if the password is correct ? if this is even possible btw hehe or els its gonna be a offline game
Message was edited by:
MeLL1eJ

