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

📄 displaygui.java

📁 这是一个买卖系统,一个模拟的系统,根据下订单,看订单,买,等功能
💻 JAVA
字号:
package Clients;

import java.awt.*;
//import java.awt.event.*;
import javax.swing.*;

//import java.text.NumberFormat;
//import java.util.Locale;

//import Catalogue.*;
import Middle.*;
//import Processing.*;

/**
 * Implements the GUI for the Display Client.
 * @auth
 * @version 2.0
 */

class DisplayGUI
{


  private static final int H = 500;       // Height of window pixels
  private static final int W = 400;       // Width  of window pixels

  private JLabel      theCollect  = new JLabel();
  private JScrollPane theSPCollect      = new JScrollPane();
  private JTextArea   theOutputCollect  = new JTextArea();
  private StockReadWriter theStock     = null;
  private OrderProcessing theOrder     = null;
  
  
  public DisplayGUI(  RootPaneContainer rpc, MiddleFactory mf  )
  {
    try                                            
    {      
      theStock = mf.makeStockReadWriter();        // DataBase access
      theOrder = mf.makeOrderProcessing();        // Process order
     
    } catch ( Exception e )
    {
      System.out.println("Exception: " + e.getMessage() );
    }


    Container cp         = rpc.getContentPane();    // Content Pane
    Container rootWindow = (Container) rpc;         // Root Window
    cp.setLayout(null);                             // No layout manager
    rootWindow.setSize( W, H );                     // Size of Window

    Font f = new Font("Monospaced",Font.PLAIN,12);  // Font f
    Font g = new Font("Monospaced",Font.BOLD, 14);	//Font g

    theCollect.setBounds( 100, 25 , 210, 60 );       // Message area
    theCollect.setText( "Orders Status System" );	//default message
    theCollect.setFont( g );						// Use font g 
    cp.add( theCollect );                            //  Add to canvas
      
    theSPCollect.setBounds( 20, 80, 360, 300 );          // Scrolling pane
    theOutputCollect.setText( "" );                        //  Blank
    theOutputCollect.setFont( f );                         //  Uses font f
    cp.add( theSPCollect );                                //  Add to canvas
    theSPCollect.getViewport().add( theOutputCollect );           //  In TextArea
  
   
    rootWindow.setVisible( true );                  // Make visible
  }		//end of constructor
  
 	public void makeThread(){    //create a thread
 		Thread t = new Thread ( new Incoming());
 		t.start();   //start the thread and wait to run
 		
 	}
 		
 			
  public class Incoming implements Runnable {   //thread action
 			
 	 		public void run(){
 	 		 try{	
 					while (true){	
 							
 						theOutputCollect.setText("");  //clear
 	 					theOutputCollect.append(theOrder.getOrderState());   //get order state
 	 					
 	 					Thread.sleep(5*1000);    //update information every 5 seconds
 	 				}	//end of while loop
 				  }	//end of try
 			   
 				
 	 			catch(Exception ex){
 	 				ex.printStackTrace();
 	 			}
 	 		}	//end of method run
 	 	}	//end of class Incoming


}

⌨️ 快捷键说明

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