📄 form1.java
字号:
import com.ms.wfc.app.*;
import com.ms.wfc.core.*;
import com.ms.wfc.ui.*;
import com.ms.wfc.html.*;
/**
* This class can take a variable number of parameters on the command
* line. Program execution begins with the main() method. The class
* constructor is not invoked unless an object of type 'Form1' is
* created in the main() method.
*/
public class Form1 extends Form
{
int priestNum;
int wildManNum;
int maxLoad;
int depth;
Problem problem;
public Form1()
{
// Required for Visual J++ Form Designer support
initForm();
// TODO: Add any constructor code after initForm call
this.radioButton1.setChecked(true);
this.comboBox1.setText("3");
this.comboBox2.setText("3");
this.comboBox3.setText("2");
this.comboBox4.setText("11");
}
/**
* Form1 overrides dispose so it can clean up the
* component list.
*/
public void dispose()
{
super.dispose();
components.dispose();
}
private void button1_click(Object source, Event e)
{
this.richEdit1.setText("");
try{
this.priestNum =Integer.valueOf((this.comboBox1.getText())).intValue();
this.wildManNum=Integer.valueOf((this.comboBox2.getText())).intValue();
this.maxLoad =Integer.valueOf((this.comboBox3.getText())).intValue();
this.depth =Integer.valueOf((this.comboBox4.getText())).intValue();
}catch(Exception exception){ Warning warning = new Warning();
warning.showDialog ();return;}
problem=new Problem(priestNum,wildManNum,maxLoad,richEdit1);
for(int i=0;i<depth;i++)problem.extendOneDepth();
problem.printOutSolution(problem.widthFirstSearch());
if(this.richEdit1.getLines().length==1)
this.richEdit1.setText(" 在"+this.depth+"步内此问题无解,请增加搜索深度!");
}
private void radioButton1_checkedChanged(Object source, Event e)
{
if(this.radioButton1.getChecked())
{this.comboBox1.setText("3");
this.comboBox2.setText("3");
this.comboBox3.setText("2");
this.comboBox4.setText("11");}
}
private void radioButton2_checkedChanged(Object source, Event e)
{
if(this.radioButton2.getChecked())
{this.comboBox1.setText("5");
this.comboBox2.setText("5");
this.comboBox3.setText("3");
this.comboBox4.setText("11");}
}
private void radioButton3_checkedChanged(Object source, Event e)
{
if(this.radioButton3.getChecked())
{this.comboBox1.setText("6");
this.comboBox2.setText("6");
this.comboBox3.setText("4");
this.comboBox4.setText("9");}
}
private void radioButton4_checkedChanged(Object source, Event e)
{
if(this.radioButton4.getChecked())
{this.comboBox1.setText("3");
this.comboBox2.setText("2");
this.comboBox3.setText("2");
this.comboBox4.setText("10");}
}
private void radioButton5_checkedChanged(Object source, Event e)
{
if(this.radioButton5.getChecked())
{this.comboBox1.setText("4");
this.comboBox2.setText("2");
this.comboBox3.setText("2");
this.comboBox4.setText("10");}
}
private void radioButton6_checkedChanged(Object source, Event e)
{
if(this.radioButton6.getChecked())
{this.comboBox1.setText("4");
this.comboBox2.setText("3");
this.comboBox3.setText("2");
this.comboBox4.setText("12");}
}
private void radioButton7_checkedChanged(Object source, Event e)
{
if(this.radioButton7.getChecked())
{this.comboBox1.setText("5");
this.comboBox2.setText("4");
this.comboBox3.setText("3");
this.comboBox4.setText("9");}
}
private void radioButton8_checkedChanged(Object source, Event e)
{
if(this.radioButton8.getChecked())
{this.comboBox1.setText("7");
this.comboBox2.setText("7");
this.comboBox3.setText("4");
this.comboBox4.setText("11");}
}
private void setAllRadioChecked(boolean bool)
{
this.radioButton1.setChecked(bool);
this.radioButton2.setChecked(bool);
this.radioButton3.setChecked(bool);
this.radioButton4.setChecked(bool);
this.radioButton5.setChecked(bool);
this.radioButton6.setChecked(bool);
this.radioButton7.setChecked(bool);
}
private void comboBox1_selectedIndexChanged(Object source, Event e)
{
this.setAllRadioChecked(false);
}
private void comboBox2_selectedIndexChanged(Object source, Event e)
{
this.setAllRadioChecked(false);
}
private void comboBox3_selectedIndexChanged(Object source, Event e)
{
this.setAllRadioChecked(false);
}
private void comboBox4_selectedIndexChanged(Object source, Event e)
{
this.setAllRadioChecked(false);
}
private void button2_click(Object source, Event e)
{
Application.exit();
}
private void button3_click(Object source, Event e)
{
About myAbout = new About();
myAbout.showDialog ();
}
/**
* NOTE: The following code is required by the Visual J++ form
* designer. It can be modified using the form editor. Do not
* modify it using the code editor.
*/
Container components = new Container();
GroupBox groupBox1 = new GroupBox();
GroupBox groupBox2 = new GroupBox();
GroupBox groupBox3 = new GroupBox();
Label label1 = new Label();
Label label2 = new Label();
Label label3 = new Label();
ComboBox comboBox1 = new ComboBox();
ComboBox comboBox2 = new ComboBox();
ComboBox comboBox3 = new ComboBox();
Label label4 = new Label();
ComboBox comboBox4 = new ComboBox();
Label label5 = new Label();
Button button1 = new Button();
RichEdit richEdit1 = new RichEdit();
RadioButton radioButton1 = new RadioButton();
GroupBox groupBox4 = new GroupBox();
RadioButton radioButton2 = new RadioButton();
RadioButton radioButton3 = new RadioButton();
RadioButton radioButton4 = new RadioButton();
RadioButton radioButton5 = new RadioButton();
RadioButton radioButton6 = new RadioButton();
RadioButton radioButton7 = new RadioButton();
Label label6 = new Label();
RadioButton radioButton8 = new RadioButton();
Button button2 = new Button();
Button button3 = 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, "Form1");
this.setText("人工智能实验之三(传教士和野人问题)");
this.setAutoScaleBaseSize(new Point(6, 12));
this.setClientSize(new Point(547, 549));
this.setIcon((Icon)resources.getObject("this_icon"));
this.setStartPosition(FormStartPosition.CENTER_SCREEN);
groupBox1.setLocation(new Point(8, 8));
groupBox1.setSize(new Point(312, 184));
groupBox1.setTabIndex(0);
groupBox1.setTabStop(false);
groupBox1.setText("问题描述");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -