Displaying Source Code(s)
|
|
--------------------------------------------------------------------------------
Window control in Java
--------------------------------------------------------------------------------
Description : Here window will open as a result of executing
program.This program gives a lot of detals of frame,panel etc in
java
import java.awt.*;
import java.applet.*;
public class MyWindow2 extends Applet {
Frame window;
Button open,close;
public void init()
{
open=new Button("Open Window");
add(open);
close=new Button("Colse Window");
add(close);
window=new BaseFrame1("A Pop Up Window");
window.resize(150,150);
MenuBar mbar=new MenuBar();
Menu myMenu=new Menu("File");
myMenu.add(new MenuItem("New"));
myMenu.add(new MenuItem("Open"));
myMenu.add(new MenuItem("Save"));
mbar.add(myMenu);
window.setMenuBar(mbar);
}
public boolean action(Event evt,Object arg)
{
if(evt.target instanceof Button)
{
String label=(String)arg;
if(label.equals("Open Window"))
{
if(!window.isShowing())
window.show();
}
else
{
if(window.isShowing())
window.hide();
}
return true;
}
else
return false;
}
}
|
|
|