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

📄 maingui.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 edu.uiuc.cs.cs327.linuxwifi.services.*;



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;



    /**

     * Main class of the entire application that creates the GUI

     * and associated classes.

     */







public class MainGUI  extends Frame {



	private static final boolean DEBUG = false;



	private static LoginScreen loginScreen=null;

	private JTabbedPane mainTabPane=null;

	private JDesktopPane desktop;



	private static MainScreen mainScreen;

	private static ConfigScreen configScreen;

    private static SearchScreen searchScreen;

    private static StatusScreen statusScreen;

    private static PrefScreen prefScreen;



    private ServicesApi servicesAPI;



    public MainGUI(String[] args) {

			super("Linux WiFi P2P Sharing Application");



			servicesAPI = new ServicesApi(this);





			if(DEBUG) System.out.println("Drawing main frame");



			// Add the desktop pane

//			setLayout( new BorderLayout() );

			desktop = new JDesktopPane();

			desktop.setLayout(null);

			desktop.setDoubleBuffered(true);

			add("Center", desktop);

			setMenuBar(createMenuBar());



			setVisible(true);



			try {

					UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");

			} catch (Exception e) {

					if (DEBUG) System.err.println("Could not initialize java.awt Metal lnf");

			}



			addWindowListener( new WindowAdapter() {

					public void windowClosing(WindowEvent we) {

					System.exit(0);

					}

			} );



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



            loginScreen = new LoginScreen(this);



			add(loginScreen,"Center");



//    		show();





    		successfulLogin();



    }



    public void successfulLogin()

    {



         remove(loginScreen);



         mainScreen = new MainScreen(this);

         configScreen = new ConfigScreen(this);

         searchScreen = new SearchScreen(servicesAPI);

         statusScreen = new StatusScreen(this, servicesAPI);

         prefScreen   = new PrefScreen(this);



         mainTabPane = new JTabbedPane(JTabbedPane.BOTTOM);



         mainTabPane.addTab("Main",mainScreen);

         mainTabPane.addTab("Search",searchScreen);

         mainTabPane.addTab("Status",statusScreen);

         mainTabPane.addTab("Config",configScreen);

         mainTabPane.addTab("Preferences",prefScreen);



         add(mainTabPane);



         mainTabPane.show();

         show();



         mainTabPane.setSelectedIndex(0);

    }



    public void logOut()

    {

        System.out.println("MainGUI::logOut::Remove mainTabPane");



        mainTabPane.removeAll();

        mainTabPane.setVisible(false);

        remove(mainTabPane);



        System.out.println("MainGUI::logOut::Remove mainTabPane");



        add(loginScreen,"Center");

        loginScreen.show();



        System.out.println("MainGUI::logOut::Showing");



        show();

    }



    /**

     * Informs GUI that a file has been added/removed from the PeerVector

     * GUI should re-query the peer vector and populate its' apporpriate screens

     */

    public void notifyPeerVectorChanged()

    {

//        System.out.println("NNNNNNNNN ****** NNNNNNN");

        StatusScreen.updatePeerVector();



//          ActionEvent ae = new ActionEvent(this,0,"refresh");



//          StatusScreen.dispatchEvent(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "refresh"));

    }





    public  static void main(String[] args) {



        MainGUI maingui = new MainGUI(args);

        System.out.println("Hello World");



    }



		// creates the menu bar

		private MenuBar createMenuBar() {

			ActionListener al = new ActionListener() {

					public void actionPerformed(ActionEvent ae) {

						String command = ae.getActionCommand();

						if (command.equals("Exit")) {

								dispose();

								System.exit(0);

						}

					}

			};



			MenuItem item;

			MenuBar mb = new MenuBar();



			// File Menu

			Menu mnFile = new Menu("File");

			mnFile.add(item = new MenuItem("Exit"));

			item.addActionListener(al);



			mb.add(mnFile);

			return mb;

		}







}

⌨️ 快捷键说明

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