473,405 Members | 2,141 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Problem with login screen

8
hi.. when i hit run all i get is the Clear button which fills the whole panel and nothing else comes up anyno where i went wrong

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Login extends JFrame implements ActionListener
{
JPanel cardHolder;
private CardLayout card;
private JLabel label1, label2;
private JTextField username;
private JPasswordField password;
private JButton loginBtn, clearBtn, PurchaseTickets;

public static void main(String args[])
{
Login app = new Login();
}

public Login() //constructor
{
super("Event Handling");
setTitle("Login");

cardHolder = new JPanel();
card = new CardLayout();
Container c = getContentPane();
cardHolder.setLayout(card);

label1 = new JLabel("Username:");

username = new JTextField(20);

label2 = new JLabel("Password:");

password = new JPasswordField(20);

loginBtn = new JButton("Login");
loginBtn.addActionListener(this);

clearBtn = new JButton("Clear");
clearBtn.addActionListener(this);

c.add(label1);
c.add(username);
c.add(label2);
c.add(password);
c.add(loginBtn);
c.add(clearBtn);

setSize(350, 170);
setVisible(true);
}

public void actionPerformed(ActionEvent e)
{
if (e.getSource() == loginBtn)
{
JOptionPane.showMessageDialog(null, "Welcome "+username.getText());
select sel = new select();
}

if (e.getSource() == clearBtn)
{
username.setText("");
password.setText("");
}
}
}
Mar 8 '08 #1
1 1289
JosAH
11,448 Expert 8TB
[quote=pleb]
Expand|Select|Wrap|Line Numbers
  1.         c.add(label1);
  2.         c.add(username);
  3.         c.add(label2);
  4.         c.add(password);
  5.         c.add(loginBtn);
  6.         c.add(clearBtn);
  7.  
You're adding all these component to your ContentPane which has a BorderLayout
by default. All the components end up in the same area of the BorderLayout, and
only the last one will be stored there and takes up the entire area available to
the ContentPane.

kind regards,

Jos
Mar 8 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Chip | last post by:
I am trying to get sessions to work on a log in screen to give certain users access to certain pages/directories. The problem is that when the login button is pushed (or the enter key pressed) the...
3
by: Pavel Vetesnik | last post by:
Greetings! I have some troubles with session variables. I can easily create a session, but the variable I append to global session array ( $_SESSION) lasts only until the end of current...
9
by: Bartosz Wegrzyn | last post by:
I need help with sessions. I createt set of web site for nav with authorization. first I go into main.php which looks like this: <?php //common functions include_once '../login/common.php';...
1
by: Ron L | last post by:
I am trying to setup a solution that will include a client which will access a database via remoting calls. I am hosting my remoting project in IIS, and am using Windows Integrated security. ...
7
by: Jack | last post by:
Hi, In my application, the main page is accessed via a login screen. A particular record is accessed based on the value of login page. Everything works fine. However, if this screen is kept idle...
2
by: Shaun | last post by:
Ok here is the situation… Have an access 20002 application that I'm converting to have a SQL Server backend (2000), the application has been in use with an access backend for years, no real...
1
by: George | last post by:
Hi. I've deployed a web application on a desktop computer running W2K and IIS. I'm using the desktop as a server. When I try to access the site, either from my development computer or if I...
9
by: dana lees | last post by:
Hello, I am developing a C# asp.net application. I am using the authentication and authorization mechanism, which its timeout is set to 60 minutes. My application consists of 2 frames - a...
3
by: bala | last post by:
Hi Gurus The scenario A MS Access frontend application with Oracle Backend (Linked Tables). The Database UserID and password is not stored and each user has a unique UserID and password. There...
10
by: =?Utf-8?B?UmljaGFyZCBCeXNvdXRo?= | last post by:
Hi In my app I have a SplashScreen, a login form and a main form. On launching the app, I'd like to show the SplashScreen while reading config files and attempting a database connection. I show...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.