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

📄 mb.java

📁 一个简单的visio程序。
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* function Msgbox
   Msgbox function return FUNC_TEM id
   4/18/97
   Author BaiWei*/

package HPCore.stdfunc;

import java.awt.*;
import java.awt.event.*;
import java.net.URL;
import java.util.Vector;
import java.util.StringTokenizer;
import HPCore.stdstmt.hpfileio;
import HPCore.Exception.*;
import HECore.stddata.*;

class  FUNC_TEM
{
  short id=0;
}

/* msgbox function*/
public class mb
{
	static Frame frame=null;
	public static short MsgBox(String msg) throws HpException
	{
		FUNC_TEM  r=null;
		FUNC_TEM  p=null;
      if (msg == null)
         throw new HpException(94,"Invalid use of Null");

      if (frame == null)
         frame = new Frame();
	   InfoDialog  msgb=new InfoDialog(frame,msg);
    	r = msgb.R;
    	p = msgb.P;
    	msgb.show();
    	while(p.id!=1)
    	    ;
    	return r.id;
	}

	public static short MsgBox(String msg,short type)  throws HpException
	{
    	FUNC_TEM  r=null;
    	FUNC_TEM  p=null;
      if (msg == null)
         throw new HpException(94,"Invalid use of Null");
      if (frame == null)
        frame = new Frame();
    	InfoDialog  msgb=new InfoDialog(frame,msg,type);
    	r = msgb.R;
    	p = msgb.P;
    	msgb.show();
    	while(p.id!=1)
    	    ;
    	return r.id;
   }

	public static short MsgBox(String msg,short type,String title) throws HpException
	{
    	FUNC_TEM  r=null;
    	FUNC_TEM  p=null;
      if (msg == null)
         throw new HpException(94,"Invalid use of Null");
      if (frame == null)
        frame = new Frame();
    	InfoDialog msgb=new InfoDialog(frame,msg,type,title);
    	r = msgb.R;
    	p = msgb.P;
    	msgb.show();
    	while(p.id!=1)
    	    ;
    	return r.id;
	}

   public static short MsgBox(String msg,short type,String title,String helpfile) throws HpException
   {
		throw new HpException(95,"Invalid procedure call.");
   }

   public static short MsgBox(String msg,short type,String title,String helpfile,short context) throws HpException
   {
    	FUNC_TEM  r=null;
    	FUNC_TEM  p=null;
      if (msg == null || title == null || helpfile == null)
         throw new HpException(94,"Invalid use of Null");

      if (frame == null)
        frame = new Frame();
    	InfoDialog msgb=new InfoDialog(frame,msg,type,title,helpfile,context);
    	r = msgb.R;
    	p = msgb.P;
    	msgb.show();
    	while(p.id!=1)
    	    ;
    	return r.id;
   }
}// end of class MB

class InfoDialog extends Dialog implements ActionListener,KeyListener
{
	FUNC_TEM P = new FUNC_TEM();
	FUNC_TEM R = new FUNC_TEM();
	int mtype = 0;
	Button ok     = new Button("   Ok   ");
	Button cancel = new Button(" Cancel ");
	Button abort  = new Button(" Abort  ");
	Button retry  = new Button(" Retry  ");
	Button ignore = new Button(" Ignore ");
	Button yes    = new Button("  Yes   ");
	Button no     = new Button("   No   ");
	boolean second = false;
	boolean third = false;
	boolean escflag = false;
	boolean okflag = false;
	String helpfile = null;
	String msg = "";
	int maxWidth = 90;
	Image stop=null;
	String title = "";

	public InfoDialog(Frame frame,String msg)
	{
    	super(frame,"Project1",true); /// Project1 is temp ....
		int ind;
	   if ((ind = msg.indexOf('\0')) != -1)
		   msg = msg.substring(0,ind);
		filldailog(msg,0);
		this.msg = msg;
	}

	public InfoDialog(Frame frame,String msg,int type)
	{
		super(frame,"Project1",true);//"Project1" will come from compiler
		int ind;
		if ((ind = msg.indexOf('\0')) != -1)
			msg = msg.substring(0,ind);
		filldailog(msg,type);
		this.msg = msg;
	}

	public InfoDialog(Frame frame,String msg,int type,String title)
	{
		super(frame,title,true);
		int ind;
		if ((ind = title.indexOf('\0')) != -1)
		  title = title.substring(0,ind);
		if ((ind = msg.indexOf('\0')) != -1)
		  msg = msg.substring(0,ind);
		this.title = title;
		filldailog(msg,type);
		this.msg = msg;
	}

	public InfoDialog(Frame frame,String msg,int type,String title,String helpf,int context)
	{
		super(frame,title,true);
		int ind;
		if ((ind = title.indexOf('\0')) != -1)
		  title = title.substring(0,ind);
		if ((ind = msg.indexOf('\0')) != -1)
		  msg = msg.substring(0,ind);
		this.title = title;
		filldailog(msg,type);
		helpfile = helpf;
		this.msg = msg;
	}

	public void actionPerformed(ActionEvent e)
	{
		Object obj = e.getSource();

    	if(obj == ok)
    	{
    	    R.id = 1;
    	    P.id = 1;
    	    this.dispose(); 
    	}
    	else if(obj == cancel)
    	{
    	    R.id = 2;
    	    P.id = 1;
    	    this.dispose(); 
    	}
    	else if(obj == abort)
    	{
    	    R.id = 3;
    	    P.id = 1;
    	    this.dispose(); 
    	}
    	else if(obj == retry)
    	{
    	    R.id = 4;
    	    P.id = 1;
    	    this.dispose(); 
    	}
    	else if(obj == ignore)
    	{
    	    R.id = 5;
    	    P.id = 1;
    	    this.dispose(); 
    	}
    	else if(obj == yes)
    	{
    	    R.id = 6;
    	    P.id = 1;
    	    this.dispose(); 
    	}
    	else if(obj == no)
    	{
    	    R.id = 7;
    	    P.id = 1;
    	    this.dispose(); 
    	}
   }

	public void keyPressed(KeyEvent e)
	{
	    int keycode = e.getKeyCode();
	    Object obj = e.getSource();

	   if  (keycode == KeyEvent.VK_SPACE)
		   this.pressSpaceKey = true; // xiang rong 98 - 02 -20

        if (keycode == KeyEvent.VK_F1)
	    {
			if (helpfile != null)
			{
				String command[] = new String[2];
    			command[0] = "winhlp32";
    			command[1] = helpfile;
    			Runtime runtime = Runtime.getRuntime();
    			try{
    				runtime.exec(command);
				}catch(java.io.IOException ioe){
					System.out.println("ShowHelp Error. " + ioe);
    			}
				
    			runtime.gc();
			}
	    }
	    else if (obj == cancel && (keycode == KeyEvent.VK_TAB ||
	                           keycode == KeyEvent.VK_RIGHT))
	    {
    		if (mtype == 1)
    		    ok.requestFocus();
    		else if (mtype == 5)
    		    retry.requestFocus();
    		else if (mtype == 3)
    		    yes.requestFocus();
    	}
    	else if (obj == ok && mtype == 1 && (keycode == KeyEvent.VK_TAB ||
    	         keycode == KeyEvent.VK_RIGHT || keycode == KeyEvent.VK_LEFT))
    	{
    		cancel.requestFocus();
    	}
    	else if (obj == no && (keycode == KeyEvent.VK_TAB ||
    	                      keycode == KeyEvent.VK_RIGHT))
    	{
    		if (mtype == 3 )
    		    cancel.requestFocus();
    		else if (mtype == 4)
    		    yes.requestFocus();
    	}
    	else if (obj == yes && (keycode == KeyEvent.VK_TAB ||
    	                        keycode == KeyEvent.VK_RIGHT))
    	{
    	       no.requestFocus();
    	}
    	else if (obj == abort && (keycode == KeyEvent.VK_TAB ||
    	                         keycode == KeyEvent.VK_RIGHT))
    	{
    		retry.requestFocus();
    	}
    	else if (obj == retry && (keycode == KeyEvent.VK_TAB ||
    	                          keycode == KeyEvent.VK_RIGHT))
    	{
    		if (mtype == 2)
    		    ignore.requestFocus();
    		else if (mtype == 5)
    		     cancel.requestFocus();
    	}
		else if (obj == ignore && (keycode == KeyEvent.VK_TAB ||
		                           keycode == KeyEvent.VK_RIGHT))
		{
			abort.requestFocus();
	    }
	    else if (obj == yes && keycode == KeyEvent.VK_LEFT)
	    {
		    if (mtype == 3)
        	    cancel.requestFocus();
    		else if (mtype == 4)
    		    no.requestFocus();
    	}
	    else if (obj == no && keycode == KeyEvent.VK_LEFT)
	    {
	    	yes.requestFocus();
    	}
    	else if (obj == cancel && keycode == KeyEvent.VK_LEFT)
    	{
    		if (mtype == 3)
    		   no.requestFocus();
    		else if (mtype == 5)
    		   retry.requestFocus();
    		else if (mtype == 1)
    		   ok.requestFocus();
    	}
    	else if (obj == abort && keycode == KeyEvent.VK_LEFT)
    	{
    		ignore.requestFocus();
    	}
    	else if (obj == retry && keycode == KeyEvent.VK_LEFT)
    	{
    		if (mtype == 5)
    		    cancel.requestFocus();
    		else if (mtype == 2)
    		    abort.requestFocus();
    	}
		else if (obj == ignore && keycode == KeyEvent.VK_LEFT)
		{
			retry.requestFocus();
		}
    	else if (keycode == KeyEvent.VK_O)
    	{
    	    if(mtype == 1)
    		{
    			R.id = 1;
    			P.id = 1;
            this.dispose(); 
    		}
    	}
    	else if(keycode == KeyEvent.VK_A)
    	{
    	    if (mtype == 2)
    	    {
    			R.id = 3;
   			P.id = 1;
	         this.dispose(); 
    	    }
    	}
    	else if(keycode == KeyEvent.VK_R)
    	{
			if ( mtype == 5 || mtype == 2)
			{
				R.id = 4;
				P.id = 1;
				this.dispose(); 
    		}
    	}
    	else if(keycode == KeyEvent.VK_Y)
    	{
    	    if (mtype == 3 || mtype == 4)
    		{
    			R.id = 6;
    			P.id = 1;
				this.dispose(); 
    		}
    	}
    	else if (keycode == KeyEvent.VK_C)
    	{
    	    if(mtype == 1 || mtype == 3 || mtype == 5)
    		{
    			R.id = 2;
    			P.id = 1;
            this.dispose(); 
    		}
    	}
    	else if (keycode == KeyEvent.VK_I)
    	{
    	    if(mtype == 2)
    		{
    			R.id = 5;
    			P.id = 1;
    	        this.dispose(); 
    		}
    	}
    	else if(keycode == KeyEvent.VK_N)
    	{
    		if(mtype == 3 || mtype == 4)
    		{
    			R.id = 7;
    			P.id = 1;
    	        this.dispose(); 
    		}
    	}
    	else if (obj == ok && keycode == KeyEvent.VK_ENTER )
    	{
			R.id = 1;
			P.id = 1;
    	    this.dispose(); 
    	}
    	else if (obj == yes && keycode == KeyEvent.VK_ENTER )
    	{
			R.id = 6;
			P.id = 1;
    	    this.dispose(); 
    	}
    	else if (obj == no && keycode == KeyEvent.VK_ENTER )
    	{
			R.id = 7;
			P.id = 1;
    	    this.dispose(); 
    	}
    	else if (obj == cancel && keycode == KeyEvent.VK_ENTER )
    	{
			R.id = 2;
			P.id = 1;
    	    this.dispose(); 
    	}
    	else if (obj == abort && keycode == KeyEvent.VK_ENTER )
    	{
			R.id = 3;
			P.id = 1;
    	    this.dispose(); 
    	}
    	else if (obj == retry && keycode == KeyEvent.VK_ENTER )
    	{
			R.id = 4;
			P.id = 1;
    	    this.dispose(); 
    	}
		else if (obj == ignore && keycode == KeyEvent.VK_ENTER )
		{
	    	R.id = 5;
			P.id = 1;
    	    this.dispose(); 
    	}
	}

	public void keyTyped(KeyEvent e){}

   private boolean pressSpaceKey = false;// xiang rong 98-02-20

	public void keyReleased(KeyEvent e)
	{
	    Object obj = e.getSource();

⌨️ 快捷键说明

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