//MainForm.java
import com.ms.wfc.app.*;
import com.ms.wfc.core.*;
import com.ms.wfc.ui.*;
import com.ms.wfc.html.*;
import com.ms.wfc.io.*; //input/output
exception.
/**
* 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
'MainForm' is
* created in the main() method.
*/
public class MainForm extends Form
{
//
Variables
File fil;
Image imag;
String CurrentDirectory;
public MainForm()
{
super();
// Required for Visual J++ Form Designer support
initForm();
//
Current Directory
CurrentDirectory = fil.getCurrentDirectory();
// PictureBox control
this.pictureBox1.setImage(imag.loadImage(fil.open(String.valueOf(CurrentDirectory.toString()
+ "\\Pic\\ingraphic1.gif"))));
// TODO: Add any constructor code after initForm call
}
/**
* MainForm overrides dispose so it can clean up the
* component list.
*/
public void dispose()
{
super.dispose();
components.dispose();
}
public void
formClose(Event e)
{
Application.exit();
}
//
Timer control event
private void timer1_timer(Object source, Event e)
{
Time tm = new Time() ;
lbtime.setText(tm.formatLongTime().toString());
}
// MenuItem event
private void ExitMenu_click(Object source, Event e)
{
Application.exitThread();
Application.exit();
}
private void
BookMenu_click(Object source, Event e)
{
Book myBook = new Book();
myBook.show();
}
private void
AboutMenu_click(Object source, Event e)
{
About myAbout = new About();
myAbout.show();
}
/**
* 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();
MainMenu mainMenu1 = new MainMenu();
MenuItem InfoMenu = new MenuItem();
MenuItem BookMenu = new MenuItem();
MenuItem menuItem1 = new MenuItem();
MenuItem menuItem2 = new MenuItem();
MenuItem AboutMenu = new MenuItem();
MenuItem Seperator2 = new MenuItem();
MenuItem ExitMenu = new MenuItem();
PictureBox pictureBox1 = new PictureBox();
Label lbtime = new Label();
Timer timer1 = new Timer(components);
Label Teachlabel = new Label();
private void
initForm()
{
BookMenu.setText("Book");
menuItem1.setText("-");
menuItem2.setText("-");
AboutMenu.setText("About");
Seperator2.setText("-");
ExitMenu.setText("Exit");
InfoMenu.setMenuItems(new MenuItem[] {
BookMenu,
menuItem1,
AboutMenu,
Seperator2,
menuItem2,
ExitMenu});
InfoMenu.setText("Indo mani");
mainMenu1.setMenuItems(new MenuItem[] {
InfoMenu});
/* @designTimeOnly mainMenu1.setLocation(new Point(96, 16));
*/
this.setText("Main
...");
this.setAutoScaleBaseSize(13);
this.setClientSize(new Point(636, 393));
this.setMaximizeBox(false);
this.setMenu(mainMenu1);
this.setStartPosition(FormStartPosition.CENTER_SCREEN);
pictureBox1.setLocation(new Point(128, 64));
pictureBox1.setSize(new Point(375, 199));
pictureBox1.setTabIndex(2);
pictureBox1.setTabStop(false);
pictureBox1.setText("pictureBox1");
lbtime.setLocation(new Point(496, 360));
lbtime.setSize(new Point(120, 16));
lbtime.setTabIndex(3);
lbtime.setTabStop(false);
lbtime.setText("");
lbtime.setTextAlign(HorizontalAlignment.CENTER);
timer1.setEnabled(true);
/* @designTimeOnly timer1.setLocation(new Point(408, 360));
*/
Teachlabel.setFont(new Font("Times New Roman",
12.0f, FontSize.POINTS, FontWeight.BOLD, true, false,
false, CharacterSet.DEFAULT, 0));
Teachlabel.setLocation(new Point(8, 296));
Teachlabel.setSize(new Point(624, 19));
Teachlabel.setTabIndex(0);
Teachlabel.setTabStop(false);
Teachlabel.setText("Learn how to write a Microsoft
Visual J++ Application");
Teachlabel.setAutoSize(true);
Teachlabel.setTextAlign(HorizontalAlignment.CENTER);
this.setNewControls(new Control[] {
Teachlabel,
lbtime,
pictureBox1});
}
/**
* 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 MainForm());
}
}
|