typetrainapplet1.java~1~
来自「java的打字程序」· JAVA~1~ 代码 · 共 122 行
JAVA~1~
122 行
package chapter11;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import javax.swing.*;
public class TypeTrainApplet1
extends JApplet
{
boolean isStandalone = false;
BorderLayout borderLayout1 = new BorderLayout();
int stepLen;
int stepInterval;
int columnCount;
int generateInterval;
//Get a parameter value
public String getParameter(String key, String def)
{
return isStandalone ? System.getProperty(key, def) :
(getParameter(key) != null ? getParameter(key) : def);
}
//Construct the applet
public TypeTrainApplet1()
{
}
//Initialize the applet
public void init()
{
try
{
stepLen = Integer.parseInt(this.getParameter("stepLen", "2"));
}
catch (Exception e)
{
e.printStackTrace();
}
try
{
stepInterval = Integer.parseInt(this.getParameter("stepInterval",
"50"));
}
catch (Exception e)
{
e.printStackTrace();
}
try
{
columnCount = Integer.parseInt(this.getParameter("columnCount",
"10"));
}
catch (Exception e)
{
e.printStackTrace();
}
try
{
generateInterval = Integer.parseInt(this.getParameter(
"generateInterval", "500"));
}
catch (Exception e)
{
e.printStackTrace();
}
try
{
jbInit();
}
catch (Exception e)
{
e.printStackTrace();
}
}
//Component initialization
private void jbInit()
throws Exception
{
this.setSize(new Dimension(400, 300));
this.getContentPane().setLayout(borderLayout1);
}
//Get Applet information
public String getAppletInfo()
{
return "Applet Information";
}
//Get parameter info
public String[][] getParameterInfo()
{
java.lang.String[][] pinfo =
{
{
"stepLen", "int", "步长"},
{
"stepInterval", "int", "间隔"},
{
"columnCount", "int", "栏数"},
{
"generateInterval", "int", "间隔"},
};
return pinfo;
}
//static initializer for setting look & feel
static
{
try
{
//UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
//UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
}
catch (Exception e)
{
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?