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

📄 adovj.java

📁 vc ADO 连接数据库
💻 JAVA
字号:
//******************************************************************************
// ADOVJ.java:	Applet
//
//******************************************************************************
import java.applet.*;
import java.awt.*;
import java.util.*;

import ADOVJFrm;

import LogEx;		// ADO Rosetta Stone Exception Handling Code
import ADOUtils;	// ADO Rosetta Stone Utilities
import ADOCore;		// ADO Rosetta Stone Event Handlers


//==============================================================================
// Main Class for applet ADOVJ
//
//==============================================================================


//==============================================================================
// Main Class for applet ADOVJ
//
//==============================================================================
public class ADOVJ extends Applet
{
	// STANDALONE APPLICATION SUPPORT:
	//		m_fStandAlone will be set to true if applet is run standalone
	//--------------------------------------------------------------------------
	private boolean m_fStandAlone = false;
	
	// Initialize buttons and list box members.
	Button m_Button1 = new Button( "Open Access Database" );
	Button m_Button2 = new Button( "Provider Properties" );
	Button m_Button3 = new Button( "Code Template" );
	Button m_Button4 = new Button( "Input / Output / Return Parameters (Requires SQL Server)" );
	List   m_List	 = new List();

	ADOCore	m_ADOCore = new ADOCore();

	// Initialize various panels needed for applet.
	Panel m_panelMain		= new Panel();
	Panel m_panelNorth		= new Panel();
	Panel m_panelNorthRow1	= new Panel();
	Panel m_panelNorthRow2	= new Panel();

	// Debug window is handy for debugging in Browser mode.
	// DebugWindow dbg	 = new DebugWindow(); // DEBUG

	// STANDALONE APPLICATION SUPPORT
	// 	The main() method acts as the applet's entry point when it is run
	// as a standalone application. It is ignored if the applet is run from
	// within an HTML page.
	//--------------------------------------------------------------------------
	public static void main( String args[] )
	{
		// Create Toplevel Window to contain applet ADOVJ
		//----------------------------------------------------------------------
		ADOVJFrm frame = new ADOVJFrm( "ActiveX Data Objects w/Visual J++ 1.1 and Java Typelib Wizard" );

		// Must show Frame before we size it so insets() will return valid values
		//----------------------------------------------------------------------
		frame.show();
        frame.hide();
		frame.resize(frame.insets().left + frame.insets().right  + 800,
					 frame.insets().top  + frame.insets().bottom + 600);

		// The following code starts the applet running within the frame window.
		// It also calls GetParameters() to retrieve parameter values from the
		// command line, and sets m_fStandAlone to true to prevent init() from
		// trying to get them from the HTML page.
		//----------------------------------------------------------------------
		ADOVJ applet_ADOVJ = new ADOVJ();

		frame.add( "Center", applet_ADOVJ );
		applet_ADOVJ.m_fStandAlone = true;
		applet_ADOVJ.init();
		applet_ADOVJ.start();
        frame.show();

	}

	// ADOVJ Class Constructor
	//--------------------------------------------------------------------------
	public ADOVJ()
	{
//		System.out.println( "ADOVJ.ADOVJ()" );	// DEBUG
	}

	// APPLET INFO SUPPORT:
	//		The getAppletInfo() method returns a string describing the applet's
	// author, copyright date, or miscellaneous information.
    //--------------------------------------------------------------------------
	public String getAppletInfo()
	{
//		System.out.println( "ADOVJ.getAppletInfo()" ); // DEBUG
		return "Name: ADOVJ\r\n" +
		       "Author: Matt\r\n" +
		       "Created with Microsoft Visual J++ Version 1.1";
	}

	// The init() method is called by the AWT when an applet is first loaded or
	// reloaded.  Override this method to perform whatever initialization your
	// applet needs, such as initializing data structures, loading images or
	// fonts, creating frame windows, setting the layout manager, or adding UI
	// components.
    //--------------------------------------------------------------------------
	public void init()
	{
//		System.out.println( "ADOVJ.init()" ); // DEBUG

        // If you use a ResourceWizard-generated "control creator" class to
        // arrange controls in your applet, you may want to call its
        // CreateControls() method from within this method. Remove the following
        // call to resize() before adding the call to CreateControls();
        // CreateControls() does its own resizing.
        //----------------------------------------------------------------------
    	resize( 400, 400 );

		// Set applet's background color
		setBackground( Color.lightGray );

		// Put m_panelMain in center of applet window.
		setLayout( new BorderLayout() );
		m_panelMain.setLayout( new BorderLayout() );
		add( "Center", m_panelMain );

		// Create 2 row grid layout for north section buttons and add to applet.

		m_panelNorth.setLayout( new GridLayout( 3, 0 ) );
		m_panelMain.add( "North", m_panelNorth );

		// Create two sub-panels for North panel for layout purposes
		m_panelNorthRow1.setLayout( new GridLayout( 0, 3, 20, 0 ) );
		m_panelNorth.add( m_panelNorthRow1 );

		m_panelNorthRow2.setLayout( new GridLayout( 0, 1 ) );
		m_panelNorth.add( m_panelNorthRow2 );

		// Add buttons to appropriate sub-panels
		m_panelNorthRow1.add( m_Button1 );
		m_panelNorthRow1.add( m_Button2 );
		m_panelNorthRow1.add( m_Button3 );
		m_panelNorthRow2.add( m_Button4 );
		
		// Add spacer label between list box and buttons.
		m_panelNorth.add( new Label() );

		// Add spacers all around "Center" where panelMain is located.
		add( "North", new Label() );
		add( "South", new Label());
		add( "East", new Label() );
		add( "West", new Label() );

		// List

		// Add the list box to the applet window in the "center" location.
		m_panelMain.add( "Center", m_List );
		m_List.setBackground( new Color( 255, 255, 255) );

		// Initialize ADOCore class
		m_ADOCore.init();

	}

	public boolean  action(Event  evt, Object  what)
	{
//		System.out.println( "ADOVJ.action() Object=" + what.toString() + " ID=" + evt.id +" Key=" + evt.key + " {x,y}={" + evt.x + "," + evt.y + "}" ); // DEBUG
		
		// All major actions (button clicks/list box clicks) are processed here.
		if ( evt.target == m_Button1 )
		{
			m_ADOCore.OpenAccessDatabase( m_List );
		}
		if ( evt.target == m_Button2 )
		{
			m_ADOCore.ProviderProperties( m_List );	
		}
		if ( evt.target == m_Button3 )
		{
			m_ADOCore.CodeTemplate( m_List );	
		}
		if ( evt.target == m_Button4 )
		{
			m_ADOCore.InputOutputReturnParams( m_List );	
		}
		return true;
	}

	// Place additional applet clean up code here.  destroy() is called when
	// when you applet is terminating and being unloaded.
	//-------------------------------------------------------------------------
	public void destroy()
	{
//		System.out.println( "ADOVJ.destroy()" );	// DEBUG
	}

	// ADOVJ Paint Handler
	//--------------------------------------------------------------------------
	public void paint(Graphics g)
	{
//		System.out.println( "ADOVJ.paint()" );	// DEBUG
	}

	//		The start() method is called when the page containing the applet
	// first appears on the screen. The AppletWizard's initial implementation
	// of this method starts execution of the applet's thread.
	//--------------------------------------------------------------------------
	public void start()
	{
//		System.out.println( "ADOVJ.start()" );	// DEBUG		
	}
	
	// The stop() method is called when the page containing the applet is
	// no longer on the screen. The AppletWizard's initial implementation of
	// this method stops execution of the applet's thread.
	//--------------------------------------------------------------------------
	public void stop()
	{
//		System.out.println( "ADOVJ.stop()" ); // DEBUG
	}

}

⌨️ 快捷键说明

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