📄 inputonebyone.java
字号:
import com.ms.wfc.app.*;
import com.ms.wfc.core.*;
import com.ms.wfc.ui.*;
public class inputonebyone extends Form{
public inputonebyone(){
initForm();
}
//定义变量
public int max;//作多可以定义的数据点的数目
public int length=1;//数据序列的长度(为输入的最大序号数)
public double data[];//存放定义后的数据
private void yesButton_click(Object source, Event e)
{
}
private void upDown4_upDownChanged(Object source, UpDownChangedEvent e)
{
System.out.println("upDownChanged:value="+this.upDown4.getValue()+",text="+this.edit5.getText());
}
private void edit5_keyUp(Object source, KeyEvent e)
{
try{
int p=Math.abs(Integer.parseInt(edit5.getText()));
if(p>max){
MessageBox.show("你输入的数据太大!数据序列最多只有"+max+"个数据点。","警告!",MessageBox.OK+MessageBox.ICONWARNING);
this.label10.setText("???");
}
else this.label10.setText(String.valueOf(this.data[this.upDown4.getValue()]));
}catch(NumberFormatException ee){
MessageBox.show("你输入了非法字符,请检查后重新输入!\n注意:此处只能输入整数。","警告!",MessageBox.OK+MessageBox.ICONWARNING);
}
}
private void button1_click(Object source, Event e)//逐点输入的确认按钮
{
try{
int p=Math.abs(Integer.parseInt(edit1.getText()));//获取输入序号
double pp=Double.valueOf(this.edit2.getText()).doubleValue();//获取输入的数据
if(p>max){
this.edit1.setText(String.valueOf(this.max));
MessageBox.show("你输入的数据太大!最多只允许输入"+max+"个数据点。","警告!",MessageBox.OK+MessageBox.ICONWARNING);
}
else{
this.data[p]=pp;
this.edit1.setText(String.valueOf(p+1));
this.edit2.setText("0");
if(p>length){
length=p;
this.yesButton.setEnabled(true);
}
}
}catch(NumberFormatException ee){
MessageBox.show("你输入了非法字符,请检查后重新输入!\n注意:序号数只能输入整数,数据栏只能输入双精度数。","警告!",MessageBox.OK+MessageBox.ICONWARNING);
}
}
private void upDown4_valueChanged(Object source, Event e)//查询数值的输出
{
this.label10.setText(String.valueOf(this.data[this.upDown4.getValue()]));
//System.out.println("valuechanged:value="+this.upDown4.getValue()+",text="+this.edit5.getText());
}
private void button2_click(Object source, Event e)//线性赋值确认按钮
{
try{
int n=Math.abs(Integer.parseInt(edit3.getText()));//获取输入序号1
int m=Math.abs(Integer.parseInt(edit4.getText()));//获取输入序号2
if(n>max){
MessageBox.show("你输入的数据太大!最多只允许输入"+max+"个数据点。","警告!",MessageBox.OK+MessageBox.ICONWARNING);
this.edit3.setText(String.valueOf(this.max));}
if(m>max){
MessageBox.show("你输入的数据太大!最多只允许输入"+max+"个数据点。","警告!",MessageBox.OK+MessageBox.ICONWARNING);
this.edit4.setText(String.valueOf(this.max));}
if(Math.abs(n-m)<2)
MessageBox.show("输入有误!这两个数据点之间至少间隔1个数据点,故不能重合或相邻。","警告!",MessageBox.OK+MessageBox.ICONWARNING);
else{
int a;
if(n>m){a=n;n=m;m=a;}
for(int i=n+1;i<=m-1;i++)
this.data[i]=(double)(i-n)*this.data[m]/(double)(m-n)+(double)(m-i)*this.data[n]/(double)(m-n);
if(m>length){
length=m;
this.yesButton.setEnabled(true);
}
}
}catch(NumberFormatException ee){
MessageBox.show("你输入了非法字符,请检查后重新输入!\n注意:此处只能输入整数。","警告!",MessageBox.OK+MessageBox.ICONWARNING);
}
}
Container components = new Container();
Button yesButton = new Button();
Button cancelButton = new Button();
GroupBox groupBox1 = new GroupBox();
Label label1 = new Label();
Edit edit1 = new Edit();
UpDown upDown1 = new UpDown();
Label label2 = new Label();
Edit edit2 = new Edit();
GroupBox groupBox2 = new GroupBox();
GroupBox groupBox3 = new GroupBox();
Label label3 = new Label();
Label label4 = new Label();
Label label5 = new Label();
Edit edit4 = new Edit();
UpDown upDown2 = new UpDown();
Edit edit3 = new Edit();
UpDown upDown3 = new UpDown();
Label label6 = new Label();
Label label7 = new Label();
GroupBox groupBox4 = new GroupBox();
Edit edit5 = new Edit();
UpDown upDown4 = new UpDown();
Label label8 = new Label();
Label label9 = new Label();
Label label10 = new Label();
Button button1 = new Button();
Button button2 = new Button();
private void initForm()
{
// NOTE: This form is storing resource information in an
// external file. Do not modify the string parameter to any
// resources.getObject() function call. For example, do not
// modify "foo1_location" in the following line of code
// even if the name of the Foo object changes:
// foo1.setLocation((Point)resources.getObject("foo1_location"));
IResourceManager resources = new ResourceManager(this, "inputonebyone");
yesButton.setEnabled(false);
yesButton.setLocation(new Point(80, 288));
yesButton.setSize(new Point(80, 24));
yesButton.setTabIndex(4);
yesButton.setText("完成");
yesButton.setDialogResult(DialogResult.YES);
cancelButton.setLocation(new Point(312, 288));
cancelButton.setSize(new Point(80, 24));
cancelButton.setTabIndex(5);
cancelButton.setText("取消");
cancelButton.setDialogResult(DialogResult.CANCEL);
this.setText("逐点输入数据");
this.setAutoScaleBaseSize(new Point(6, 12));
this.setBorderStyle(FormBorderStyle.FIXED_DIALOG);
this.setCancelButton(cancelButton);
this.setClientSize(new Point(477, 324));
this.setIcon((Icon)resources.getObject("this_icon"));
this.setMaximizeBox(false);
this.setMinimizeBox(false);
this.setStartPosition(FormStartPosition.CENTER_SCREEN);
groupBox1.setLocation(new Point(8, 16));
groupBox1.setSize(new Point(320, 88));
groupBox1.setTabIndex(0);
groupBox1.setTabStop(false);
groupBox1.setText("基本工具");
label1.setLocation(new Point(16, 24));
label1.setSize(new Point(24, 16));
label1.setTabIndex(0);
label1.setTabStop(false);
label1.setText("将第");
label1.setTextAlign(HorizontalAlignment.CENTER);
edit1.setLocation(new Point(40, 24));
edit1.setSize(new Point(48, 19));
edit1.setTabIndex(1);
edit1.setText("1");
edit1.setWordWrap(false);
upDown1.setBuddyControl(edit1);
upDown1.setLocation(new Point(88, 24));
upDown1.setSize(new Point(16, 19));
upDown1.setTabIndex(2);
upDown1.setMinimum(1);
upDown1.setValue(1);
label2.setLocation(new Point(104, 24));
label2.setSize(new Point(96, 16));
label2.setTabIndex(5);
label2.setTabStop(false);
label2.setText("个数据点的值设为");
edit2.setLocation(new Point(200, 24));
edit2.setSize(new Point(72, 19));
edit2.setTabIndex(3);
edit2.setText("0");
groupBox2.setLocation(new Point(8, 112));
groupBox2.setSize(new Point(320, 104));
groupBox2.setTabIndex(1);
groupBox2.setTabStop(false);
groupBox2.setText("线性成批赋值工具");
groupBox3.setLocation(new Point(336, 16));
groupBox3.setSize(new Point(136, 256));
groupBox3.setTabIndex(2);
groupBox3.setTabStop(false);
groupBox3.setText("说明");
label3.setLocation(new Point(8, 16));
label3.setSize(new Point(120, 232));
label3.setTabIndex(0);
label3.setTabStop(false);
label3.setText("(1)可以隔点赋值,未赋值点默认为0; (2)输入正确的数值后,点击相应的确认按钮,数值才能有效; (3)定义的数据序列的长度,即为你在定义过程中输入的最大的数据点序数; (4)线性成批赋值,是指将第n个数据和第m个数据之间的点,按照数据X(n)和X(m)赋值,使这些数据点(包括第n个和第m个)的取值呈线性变化。");
label4.setLocation(new Point(16, 24));
label4.setSize(new Point(24, 16));
label4.setTabIndex(0);
label4.setTabStop(false);
label4.setText("将第");
label5.setLocation(new Point(104, 24));
label5.setSize(new Point(72, 16));
label5.setTabIndex(4);
label5.setTabStop(false);
label5.setText("个数据点和第");
edit4.setLocation(new Point(40, 24));
edit4.setSize(new Point(48, 19));
edit4.setTabIndex(1);
edit4.setText("1");
edit4.setWordWrap(false);
upDown2.setBuddyControl(edit4);
upDown2.setLocation(new Point(88, 24));
upDown2.setSize(new Point(16, 19));
upDown2.setTabIndex(3);
upDown2.setMinimum(1);
upDown2.setValue(1);
edit3.setLocation(new Point(176, 24));
edit3.setSize(new Point(48, 19));
edit3.setTabIndex(5);
edit3.setText("1");
edit3.setWordWrap(false);
upDown3.setBuddyControl(edit3);
upDown3.setLocation(new Point(224, 24));
upDown3.setSize(new Point(16, 19));
upDown3.setTabIndex(7);
upDown3.setMinimum(1);
upDown3.setValue(1);
label6.setLocation(new Point(240, 24));
label6.setSize(new Point(72, 16));
label6.setTabIndex(2);
label6.setTabStop(false);
label6.setText("个数据点之间");
label7.setLocation(new Point(16, 56));
label7.setSize(new Point(240, 16));
label7.setTabIndex(6);
label7.setTabStop(false);
label7.setText("的所有数据点用这两个数据点线性填充赋值。");
groupBox4.setLocation(new Point(8, 224));
groupBox4.setSize(new Point(320, 48));
groupBox4.setTabIndex(3);
groupBox4.setTabStop(false);
groupBox4.setText("查看赋值");
edit5.setLocation(new Point(64, 24));
edit5.setSize(new Point(48, 19));
edit5.setTabIndex(3);
edit5.setText("1");
edit5.setHideSelection(false);
edit5.setWordWrap(false);
edit5.addOnKeyUp(new KeyEventHandler(this.edit5_keyUp));
upDown4.setBuddyControl(edit5);
upDown4.setLocation(new Point(112, 24));
upDown4.setSize(new Point(16, 19));
upDown4.setTabIndex(4);
upDown4.setMinimum(1);
upDown4.setValue(1);
upDown4.addOnValueChanged(new EventHandler(this.upDown4_valueChanged));
label8.setLocation(new Point(16, 24));
label8.setSize(new Point(40, 16));
label8.setTabIndex(0);
label8.setTabStop(false);
label8.setText("查询第");
label9.setLocation(new Point(128, 24));
label9.setSize(new Point(96, 16));
label9.setTabIndex(1);
label9.setTabStop(false);
label9.setText("个数据点的值为:");
label10.setLocation(new Point(224, 24));
label10.setSize(new Point(88, 16));
label10.setTabIndex(2);
label10.setTabStop(false);
label10.setText("");
label10.setBorderStyle(BorderStyle.FIXED_3D);
button1.setLocation(new Point(256, 56));
button1.setSize(new Point(56, 24));
button1.setTabIndex(4);
button1.setText("确认");
button1.addOnClick(new EventHandler(this.button1_click));
button2.setLocation(new Point(256, 72));
button2.setSize(new Point(56, 24));
button2.setTabIndex(8);
button2.setText("确认");
button2.addOnClick(new EventHandler(this.button2_click));
this.setNewControls(new Control[] {
groupBox4,
groupBox3,
groupBox2,
groupBox1,
cancelButton,
yesButton});
groupBox1.setNewControls(new Control[] {
button1,
edit2,
label2,
upDown1,
edit1,
label1});
groupBox2.setNewControls(new Control[] {
button2,
label7,
label6,
upDown3,
edit3,
label5,
upDown2,
edit4,
label4});
groupBox3.setNewControls(new Control[] {
label3});
groupBox4.setNewControls(new Control[] {
label10,
label9,
label8,
upDown4,
edit5});
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -