Example based on external wing-non-connected database, external wing Database

Source: Internet
Author: User

Example based on external wing-non-connected database, external wing Database

Project Structure:

  

Constant. java

Package com. mstf. test; import java. io. serializable; public class Constant implements Serializable {public static final long serialVersionUID = 1L; // public static final String URI1 = "the first URL to be opened "; public static final String URI2 = "the second URL to be opened"; // account and password public static final String userName = "admin "; public static final String passWord = "123456 ";}

Test. java

Package com. mstf. test; import java. awt. desktop; import java. awt. eventQueue; import javax. swing. JFrame; import javax. swing. JPanel; import javax. swing. JPasswordField; import javax. swing. border. emptyBorder; import javax. swing. JLabel; import javax. swing. JOptionPane; import javax. swing. JTextField; import javax. swing. JButton; import java. awt. event. actionListener; import java. io. IOException; import java.net. URI; import Java.net. URISyntaxException; import java. awt. event. actionEvent; import java. awt. color; import java. awt. font; import java. awt. toolkit; public class Test extends JFrame {private static final long serialVersionUID = 1L; private JPanel contentPane; private JTextField text_userName; private JTextField text_passWord;/*** Launch the application. */public static void main (String [] args) {EventQueue. invokeLater (New Runnable () {public void run () {try {Test frame = new Test (); frame. setVisible (true);} catch (Exception e) {e. printStackTrace () ;}});}/*** Create the frame. */public Test () {setIconImage (Toolkit. getdefatooltoolkit (). getImage (Test. class. getResource ("/images/favicon.png"); setTitle ("rain fall autumn-Background Logon"); setdefaclocloseoperation (JFrame. EXIT_ON_CLOSE); setBounds (100,100,450,300); contentPane = new JPanel (); ContentPane. setBorder (new EmptyBorder (5, 5, 5, 5); setContentPane (contentPane); contentPane. setLayout (null); JLabel labe_l1 = new JLabel ("username:"); labe_l1.setForeground (Color. RED); labe_l1.setBounds (86, 86, 54, 15); contentPane. add (labe_l1); JLabel label_2 = new JLabel ("Password:"); label_2.setForeground (Color. RED); label_2.setBounds (86,130, 54, 15); contentPane. add (label_2); text_userName = new JTextField (); te Xt_userName.setForeground (Color. DARK_GRAY); text_userName.setBounds (144, 83,166, 21); contentPane. add (text_userName); text_userName.setColumns (10); text_passWord = new JPasswordField (); text_passWord.setForeground (Color. DARK_GRAY); text_passWord.setBounds (145,127,165, 21); contentPane. add (text_passWord); text_passWord.setColumns (10); JButton login = new JButton ("log on to the background"); login. setForeground (Color. RED); log In. addActionListener (new ActionListener () {public void actionreceivmed (ActionEvent arg0) {// method of the logon button if (text_userName.getText (). trim (). equals (Constant. userName) & text_passWord.getText (). trim (). equals (Constant. passWord) {JOptionPane. showMessageDialog (contentPane, "Login successful! "," Title ", JOptionPane. WARNING_MESSAGE); StartBrowse (Constant. URI1); System. exit (0);} else {JOptionPane. showMessageDialog (contentPane, "the user name or password is incorrect !! "," Title ", JOptionPane. WARNING_MESSAGE); // The account password is incorrect. The account and password text_userName.setText (""); text_passWord.setText ("") ;}}) are automatically cleared; login. setBounds (70,194, 93, 23); contentPane. add (login); JButton regeist = new JButton ("view permission"); regeist. setForeground (Color. BLUE); regeist. addActionListener (new ActionListener () {public void actionreceivmed (ActionEvent e) {// method of registering a button if (text_userName.getText (). trim (). equals (Constant. userNa Me) & text_passWord.getText (). trim (). equals (Constant. passWord) {JOptionPane. showMessageDialog (contentPane, "Login successful! "," Title ", JOptionPane. WARNING_MESSAGE); StartBrowse (Constant. URI2); System. exit (0);} else {JOptionPane. showMessageDialog (contentPane," You are not logged on !! "," Title ", JOptionPane. WARNING_MESSAGE); // The account password is incorrect. The account and password text_userName.setText (""); text_passWord.setText ("") ;}}) are automatically cleared; regeist. setBounds (255,194, 93, 23); contentPane. add (regeist); JLabel lblHttpsceetgovtop = new JLabel ("Official Website: https://ceet-gov.top"); lblHttpsceetgovtop. setForeground (Color. RED); lblHttpsceetgovtop. setBounds (116,236,222, 15); contentPane. add (lblHttpsceetgovtop); JLabel label = new JLabel ("rain fall autumn-background management system"); label. setForeground (Color. MAGENTA); label. setFont (new Font ("", Font. PLAIN, 36); label. setBounds (23, 23,378, 39); contentPane. add (label);}/*** use the default browser to open the specified hyperlink ** @ param uri */public void StartBrowse (String uri) {Desktop desktop = Desktop. getDesktop (); try {desktop. browse (new URI (uri);} catch (IOException e1) {e1.printStackTrace ();} catch (URISyntaxException e1) {e1.printStackTrace ();}}}

  

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.