⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 loginscreen.java

📁 We intend to develop a wifi enabled p2p file sharing system on a linux platform using jxta and java.
💻 JAVA
字号:
package edu.uiuc.cs.cs327.linuxwifi.gui;



import java.awt.*;

import javax.swing.*;

import javax.swing.event.*;

import java.awt.*;

import java.awt.event.*;

import java.net.*;

import java.io.*;

import java.util.Vector;



    /**

     * Class that contains all information pertaining to the Login Screen

     */    







class LoginScreen extends JPanel implements ActionListener {



	private static final boolean DEBUG = false;

	private MainGUI mainGUI;

	



    LoginScreen( MainGUI mainGUI ) {  	

        

	

	        this.mainGUI = mainGUI;

			

			JPanel panel1 = this;

			panel1.setLayout(null);

			panel1.setSize(new Dimension(800,600));

			

			

			

			JLabel welcome = new JLabel("Please Login");

			welcome.setFont(new Font(welcome.getFont().getFontName(), welcome.getFont().getStyle(), 20));

		    welcome.setSize(welcome.getPreferredSize());

		

			JLabel userName = new JLabel("Username: ");

			userName.setSize(userName.getPreferredSize());

			

            JTextField userNameEntry = new JTextField(8);

            userNameEntry.setSize(userNameEntry.getPreferredSize());



			JLabel password = new JLabel("Password: ");

			password.setSize(password.getPreferredSize());

			

            JPasswordField passwordEntry = new JPasswordField(8);

            passwordEntry.setSize(passwordEntry.getPreferredSize());

			

			panel1.add(welcome);

			welcome.setLocation((panel1.getWidth()-welcome.getWidth())/2, 100);

			

			panel1.add(userName);			

			userName.setLocation((panel1.getWidth()-(userName.getWidth() + 5 + userNameEntry.getWidth()))/2, 150);

			

			panel1.add(userNameEntry);			

			userNameEntry.setLocation((panel1.getWidth()-(userNameEntry.getWidth()+ 5 + userName.getWidth()))/2 + userName.getWidth(), 150);

			

			panel1.add(password);

            password.setLocation((panel1.getWidth()-(password.getWidth()+5+passwordEntry.getWidth()))/2, 175);

            

            panel1.add(passwordEntry);

			passwordEntry.setLocation((panel1.getWidth()-(password.getWidth()+5+passwordEntry.getWidth()))/2 + password.getWidth(), 175);

			

			

			

			JButton quit = new JButton("Quit");			

			quit.addActionListener(this);

			quit.setActionCommand("cancel");

			

			JButton submit = new JButton("Submit");

			submit.addActionListener(this);

			submit.setActionCommand("submit");

			

			panel1.add(quit);

			panel1.add(submit);

			

			quit.setSize(submit.getPreferredSize());

			submit.setSize(submit.getPreferredSize());

			

			

//			System.out.println("panel width: " + panel1.getWidth() + "quit width: " + quit.getWidth() + 

			

			quit.setLocation((panel1.getWidth() - quit.getWidth()+10+submit.getWidth())/2,225);

			submit.setLocation((panel1.getWidth() - quit.getWidth()+10+submit.getWidth())/2+10+quit.getWidth(),225);

			

			System.out.println("Window Shown");



    }

    

		public void actionPerformed(ActionEvent e) 

		{



            if (e.getActionCommand().equals("submit")) {

                System.out.println("Submit was hit on the login screen");

                mainGUI.successfulLogin();

            }

            else if(e.getActionCommand().equals("cancel")) {

                System.out.println("System cancel recognized");

                System.exit(0);

            }

		

		}

    



			



}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -