webnovel

Realizing a user login window by programming in the javax language

2024-09-19 02:54
[Requirements: (When the username is "admin" and the password is "123", the display is correct. Otherwise, the user does not exist.] I'm a beginner. I haven't made it up for a long time. Please help me, I'm very grateful!
1 answer

To program a user login window in the Java language, you can refer to the following sample code: ```java import javaawt*; import javaawtevent*; import javaxswing*; import javautil*; public class UserLoginWindow extends JFrame implements ActionListener { private static final long serialVersionUID = 1L; private JPanel contentPane; private JTextField usernameField; private JTextField passwordField; private JButton registerButton; private JButton loginButton; private String username; private String password; private boolean register = false; private boolean login = false; public UserLoginWindow() { super(user login); contentPane = new JPanel(); contentPanesetLayout(new GridLayout(4 4)); usernameField = new JTextField(20); passwordField = new JTextField(20); registerButton = new JButton(register); loginButton = new Jbutton(login); contentPaneadd(username Field); contentPaneadd(passwordField); contentPaneadd(registerButtonbutton); contentPaneadd(loginButtonbutton); JPanel buttonPanel = new JPanel(); buttonPanelsetLayout(new BorderLayout(0 0)); add(contentPane BorderLayoutCENTER); add(buttonPanel BorderLayout BorderLayoutEAST); setSize(400 300); setDefaultCloseOperation(JFrameEXIT_ON_CLOSE); setVisible(true); } public void actionPerformed(ActionEvent e) { String username = usernameFieldgetText(); String password = passwordFieldgetText(); if (usernameequals(admin) && passwordequals(password)) { registerButtonsetEnabled(true); System outprint (login successful!); } else if (usernameequals(user) && passwordequals(123456)) { loginButtonsetEnabled(true); System out print in (User name or password error, please re-enter!); } else { System out print in (User name or password error!); } } public static void main(String[] args) { UserLoginWindow window = new UserLoginWindow(); } } ``` The user login window contains a text box for entering a username and password and two buttons for registering and logging in. When the user clicks the register button, the username and password text boxes will be cleared and the username and password entered will be checked to see if they match the username and password verified by the server. If it matches, the registration is successful. Otherwise, the user will be prompted to re-enter. When the user clicks the login button, the username and password text boxes will be cleared and the user name entered will be checked to see if it matches the username verified by the server. If it matches, the login is successful. Otherwise, the user will be prompted that the username or password is wrong.

How to make jar e-books with javax programming
1 answer
2024-09-15 01:59
Creating a jar e-book requires writing a java-based application and packaging the e-book file as a JAR file into the application. The following was a simple step: 1 Create a...
What programming language is it written in?
1 answer
2024-09-13 08:24
Thriller Battlefield was a multiplayer online shooting game developed by Tengxun Games. Its source code was not made public. However, based on the design and technical features of the game,...
In programming language development, what exactly was an API? I understand a little but not deeply.
1 answer
2024-09-15 22:56
The application Programming interface (API) was an interface definition document used to describe the interface protocol and rules between software systems. The API allows developers to interact with other software...
Every time I read Sohu News, a user login box would pop up. It was very annoying! How to cancel it
1 answer
2024-09-09 21:29
To cancel the login box that popped up in Sohu News, you can follow the following steps: 1 Open the Sohu News client and enter the news page that you...
Which was better, programming with ape tutoring or programming with learning and thinking?
1 answer
2024-09-16 05:05
As a fan of online literature, I can't give specific suggestions because Ape Tutor and Learn and Think are both well-known online education institutions. Their curriculum quality and teaching standards...
Hello, I want to write a love line in programming language. How do I do it? very simple
1 answer
2024-09-19 17:26
To write a love line in programming language, you can refer to the following example: ```python import time print(Darling) timesleep(15) print(you) timesleep(15) print(OK) timesleep(15) print(cute) timesleep(15) print(very good) timesleep(15) print(!);...
Qidian author login portal?
1 answer
2024-09-06 02:27
Starting point: 1 Open the Qidian website and type "" in the search box or directly search for "Qidian entrance" and click the "" button. 2 Enter the Qidian page...
Where should I start learning programming? How should I start? Which language should I start with?
1 answer
2024-09-09 09:11
Learning programming could start from learning basic grammar, data structures, algorithms, and object-oriented programming. Beginners can choose a programming language such as Python or Java, which is easy to learn...
Find the name of a very famous book about C programming language. It was written by a foreign author. It was very thin and short.
1 answer
2024-09-09 19:03
The book you want is called C Primer Plus. It consisted of more than 60 pages of text and 15 pages of aptitudes. It was a very thin and short...
What are the channels for realizing content?
1 answer
2024-09-16 08:14
The current content realization channels mainly include the following: 1. Advertising revenue: This is one of the main ways to realize content. When content is placed on advertising platforms, creators...
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z