📄 form4.java
字号:
//Form4.java
import com.ms.wfc.app.*;
import com.ms.wfc.core.*;
import com.ms.wfc.ui.*;
import com.ms.wfc.data.*;
import com.ms.wfc.data.ui.*;
public class Form4 extends Form
{
public void btnRefresh_Click(Object sender, Event evt)
{
try
{
btnRefresh.setEnabled( false );
dataSource1.getRecordset().cancelBatch();
Object bm = dataSource1.getRecordset().getBookmark();
dataSource1.requery();
if( bm != null )
dataSource1.getRecordset().setBookmark( bm );
}
catch (Exception e)
{
handleADOException(e);
}
btnRefresh.setEnabled( true );
}
public void btnClose_Click(Object sender, Event evt)
{
this.dispose();
}
public void dispose()
{
super.dispose();
components.dispose();
}
public Form4()
{
// Required for Visual J++ Form Designer support
initForm();
this.show();
this.update();
//TODO: Add any constructor code after initForm call
}
public void formClose(Event e)
{
Application.exit();
}
void handleADOException(Exception e)
{
e.printStackTrace();
MessageBox.show( e.toString(), "Form4" );
}
/**
* 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();
DataSource dataSource1 = new DataSource(components);
Button btnRefresh = new Button();
Button btnClose = new Button();
Panel panel1 = new Panel();
DataNavigator dataNavigator = new DataNavigator();
DataGrid dataGrid = new DataGrid();
Column column1 = new Column();
Column column2 = new Column();
Column column3 = new Column();
Column column4 = new Column();
Column column5 = new Column();
Column column6 = new Column();
Column column7 = new Column();
private void initForm()
{
this.setBackColor(new Color(0, 192, 192));
this.setForeColor(new Color(0, 0, 192));
this.setLocation(new Point(7, 7));
this.setText("按姓名浏览");
this.setAutoScaleBaseSize(new Point(6, 12));
this.setAutoScroll(true);
this.setClientSize(new Point(774, 573));
this.setStartPosition(FormStartPosition.CENTER_SCREEN);
dataSource1.setConnectionString("PROVIDER=Microsoft.Jet.OLEDB.3.51;Data Source=C:\\My Documents\\db3.mdb");
dataSource1.setCommandText("select 姓名, 读者借书证号, 国籍, 借书情况, 生日, 出生地, 附注 from 表2 ORDER by 姓名");
dataSource1.setSort(null);
dataSource1.setStayInSync(true);
dataSource1.setUserId(null);
dataSource1.setPassword(null);
btnRefresh.setLocation(new Point(93, 8));
btnRefresh.setSize(new Point(70, 30));
btnRefresh.setTabIndex(0);
btnRefresh.setText("&刷新纪录");
btnRefresh.addOnClick(new EventHandler(this.btnRefresh_Click));
btnClose.setLocation(new Point(256, 8));
btnClose.setSize(new Point(70, 30));
btnClose.setTabIndex(1);
btnClose.setText("&关闭");
btnClose.addOnClick(new EventHandler(this.btnClose_Click));
panel1.setDock(ControlDock.BOTTOM);
panel1.setLocation(new Point(0, 504));
panel1.setSize(new Point(774, 50));
panel1.setTabIndex(1);
panel1.setText("");
dataNavigator.setDock(ControlDock.BOTTOM);
dataNavigator.setLocation(new Point(0, 554));
dataNavigator.setSize(new Point(774, 20));
dataNavigator.setTabIndex(2);
dataNavigator.setTabStop(false);
dataNavigator.setText("");
dataNavigator.setDataMember("");
dataNavigator.setDataSource(dataSource1);
column1.setWidth(300);
column1.setAlignment(ContentAlignment.MIDDLELEFT);
column1.setBoundFieldName("姓名");
column1.setCaption("姓名");
column1.setIndex(0);
column2.setWidth(80);
column2.setAlignment(ContentAlignment.MIDDLELEFT);
column2.setBoundFieldName("读者借书证号");
column2.setCaption("读者借书证号");
column2.setIndex(1);
column3.setWidth(300);
column3.setAlignment(ContentAlignment.MIDDLELEFT);
column3.setBoundFieldName("国籍");
column3.setCaption("国籍");
column3.setIndex(2);
column4.setWidth(56);
column4.setAlignment(ContentAlignment.MIDDLELEFT);
column4.setBoundFieldName("借书情况");
column4.setCaption("借书情况");
column4.setIndex(3);
column5.setWidth(48);
column5.setAlignment(ContentAlignment.MIDDLELEFT);
column5.setBoundFieldName("生日");
column5.setCaption("生日");
column5.setIndex(4);
column6.setWidth(300);
column6.setAlignment(ContentAlignment.MIDDLELEFT);
column6.setBoundFieldName("出生地");
column6.setCaption("出生地");
column6.setIndex(5);
column7.setWidth(600);
column7.setAlignment(ContentAlignment.MIDDLELEFT);
column7.setBoundFieldName("附注");
column7.setCaption("附注");
column7.setIndex(6);
dataGrid.setAnchor(ControlAnchor.TOPLEFTRIGHT);
dataGrid.setBackColor(new Color(0, 192, 192));
dataGrid.setForeColor(new Color(0, 0, 128));
dataGrid.setSize(new Point(774, 504));
dataGrid.setTabIndex(0);
dataGrid.setText("");
dataGrid.setCaption("");
dataGrid.setColumns(new Column[] {
column1,
column2,
column3,
column4,
column5,
column6,
column7});
dataGrid.setHeaderFont(Font.DEFAULT_GUI);
dataGrid.setDynamicColumns(false);
dataGrid.setDataMember("");
dataGrid.setDataSource(dataSource1);
this.setNewControls(new Control[] {
dataNavigator,
panel1,
dataGrid});
panel1.setNewControls(new Control[] {
btnRefresh,
btnClose});
dataSource1.begin();
}
//NOTE: End of form designer support code.
/**
* The main entry point for the application.
*
* @param args Array of parameters passed to the application
* via the command line.
*/
public static void main(String args[])
{
Application.run( new Form4() );
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -