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

📄 dynamichtml.java

📁 用java编写的动态网页效果
💻 JAVA
字号:
// DynamicHTML.java -- Written by Chuck Wood for Visual J++ Secrets
import wfc.html.*;
// Step 1: Make a new class that inherits DhModule
public class DynamicHTML extends DhModule {
// Step 2: override the loader method
	public void documentLoad(Object sender, DhEvent p) {
	//Step 3: Create any elements
		DhButton button1 = new DhButton();
		DhButton button2 = new DhButton("Button 2");
		DhText text1 = new DhText("DynamicHTML");
	// Step 4: get the containing document
		DhDocument doc = getDocument();
	// Step 5: Add elements to the document
		button1.setText("Button 1");
		DhStyle s = new DhStyle();
		s. setColor(DhColors.DARKMAGENTA);
		s.setFont( "arial", 14 );
		text1.setStyle(s);
		doc.add(text1);		// Add a text
		doc.newLine();		// Go to the next line
		doc.newLine();		// Go to the next line
		doc.add(button1);	// Add a button
		doc.add(button2);	// Add a button
	// Step 6: Add any event handlers to the elements
		button1.addOnClick(new DhEventHandler(button1Click));
		button2.addOnClick(new DhEventHandler(button2Click));
	}
	// Step 7: Code the event handler
//button1Click is called whenever the button2 is clicked
	public void button1Click( Object sender, DhEvent e) {
	// Get the containing document
		DhDocument doc = getDocument();
	// Make a new text element
		DhText t = new DhText("Button 1 was clicked");
	// Add a new line to the containing document
		doc.newLine();
	// Add the text to the document
		doc.add(t);
	}
//button2Click is called whenever the button2 is clicked
	public void button2Click( Object sender, DhEvent e) {
	// Get the containing document
		DhDocument doc = getDocument();
	// Make a new text element
		DhText t = new DhText("Button 2 was clicked");
	// Add a new line to the containing document
		doc.newLine();
	// Add the text to the document
		doc.add(t);
	}
}

⌨️ 快捷键说明

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