In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
In this article Xiaobian for you to introduce in detail the "Java preparation of how to achieve the landing window", the content is detailed, the steps are clear, the details are handled properly, I hope this "Java preparation of how to achieve the landing window" article can help you solve your doubts, the following follow the editor's ideas slowly in-depth, together to learn new knowledge.
Requirements: after the user name and password are correct, go to the home page, the error prompt is wrong, and will exit the window after 3 errors.
1. The main window has a text input box and a login button, as shown in the figure
2. Set the time monitoring mechanism on the login button and cancel button
Canceling: quitting the program
Login: get the user name and password, and then compare it with the user name and password you saved. Now, in both cases, right and wrong
Correct: close the login window and pop up a new window, which is the home page
Error: a new window pops up, prompts the error, and accumulates, and launches the program more than three times
Now stick the code.
Import java.awt.Container;import java.awt.Image;import java.awt.event.ActionEvent;import java.awt.event.ActionListener; import javax.swing.ImageIcon;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JTextField; public class Test10_3 {public static void main (String [] args) {Denglu de = new Denglu ();}} class Denglu {private JFrame jf = new JFrame ("login window") Private JButton jb1 = new JButton ("username"); private JButton jb2 = new JButton ("password"); private JButton jbLogin = new JButton ("login"); private JButton jbquxiao = new JButton ("cancel"); private JTextField jtName = new JTextField (); private JTextField jtPwd = new JTextField (); private final String mima = "sss111"; / / this is the default password private int count = 0; private JFrame jfZhu = new JFrame () ImageIcon image = new ImageIcon ("C:\ Users\\ sss\\ Desktop\\ index.jpg"); / / this is my picture path private JLabel jlZhu = new JLabel (image); private JFrame jfCuo = new JFrame (); private JLabel jlCuo = new JLabel ("the username password you entered does not match!") ; public Denglu () {Container cp = jf.getContentPane (); cp.setLayout (null); jtName.setBounds (150pas 50lce100lce20); cp.add (jtName); jb1.setBounds (10pc50lce100pr 20); cp.add (jb1); jtPwd.setBounds (150pc100pr 100lr.20); cp.add (jtPwd); jb2.setBounds (10Mee 100lt 100lce20); cp.add (jb2) JbLogin.setBounds (20,150,100,20); jbquxiao.setBounds (150,150,100,20); cp.add (jbLogin); cp.add (jbquxiao); jbquxiao.addActionListener (new ActionListener () {public void actionPerformed (ActionEvent e) {System.exit (0);}}) JbLogin.addActionListener (new ActionListener () {public void actionPerformed (ActionEvent e) {String name = jtName.getText (); String pwd = jtPwd.getText (); String aa = name+pwd; if (aa.equals (mima)) {/ / Java) uses the equals () function to determine the equality of two strings. Jf.dispose (); / / close the landing panel Container cp2 = jfZhu.getContentPane (); cp2.setLayout (null); jlZhu.setBounds (0,0400,300); cp2.add (jlZhu); jfZhu.setSize (400300) JfZhu.setVisible (true);} else {if (0
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.