?? 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 + -