statusexample.java

来自「window下使用j2ee的jms工具做的网络应用的一个架构程序」· Java 代码 · 共 47 行

JAVA
47
字号
/* This Applet will show status bar messages in your browser.
We will use an ActionListener to practice on it.
*/

import java.awt.*;
import java.awt.event.*;
import java.applet.*;

public class StatusExample extends Applet implements ActionListener
{
	//The text in this field will be shown
	TextField statusField;
	// when this button is clicked
	Button statusButton;

	
	public void init() 
	{
		setLayout(new FlowLayout());
		statusButton = new Button("Set Status");
		statusField = new TextField("Type here");
		statusButton.addActionListener(this);
		// You can add ActionListeners to TextFields too.
		// An ActionEvent will be triggered when the user presses
		// ENTER in the textfield.
		statusField.addActionListener(this);
		add(statusButton);
		add(statusField);

	}
	
	public void actionPerformed(ActionEvent act) 
	{
		if (act.getSource() == statusButton)
			// The simple method to set a Status bar message.
			// This will take the text from thze textfield and append some extra
			// info to it.
			getAppletContext().showStatus(statusField.getText() + " (With Button Action)");
		else
			getAppletContext().showStatus(statusField.getText() + " (With Field Action)");
	}
}
		

// It's really easy. Next example is about opening web pages with 
// a browser through an applet. 
// Go to ShowDocumentExample

⌨️ 快捷键说明

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