[591] in java-interest

home help back first fref pref prev next nref lref last post

Re: Invisible winodws

daemon@ATHENA.MIT.EDU (Francois BOUSSARD)
Wed Jul 5 13:28:29 1995

Date: Wed, 05 Jul 95 12:21:20 0200
From: Francois BOUSSARD <francois@coplanet.fr>
To: java-interest@java.Eng.Sun.COM

This is a multi-part message in MIME format.

---------------------------------14750120953791
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=us-ascii

> Okay,
> By uing the Hotjava sourvce as a guide Iw as able to write code that
> creates and strats a WServer, creates a frame and then creates a
> window in the frame and it all runs without error .
> 
> Problem is, I don't see ANYTHING. I've tried using map. It still
> displays ntohing. I've tried drawString, THEN map, and still
> nothing.
> 
> Help???
> 
> JK

	Well, I'm working on windowing tools on java and I've begun to write this
code. It's creating new classes for window, frame, menu. And it's work for the
moment (it's just a draft). I hope it will be usefull for you.


-- 
__________________________________________________________________________
Francois BOUSSARD        
Coplanet : Tel : 44.64.87.60
162 Bd Davout. 75020 PARIS
FRANCE fb@coplanet.fr
__________________________________________________________________________

---------------------------------14750120953791
Content-Transfer-Encoding: 7bit
Content-Type: text/plain

/*
import awt.Graphics;
import awt.Frame;
import awt.WServer;
import awt.Window;
import awt.Color;
import awt.MenuBar, awt.Menu, awt.MenuItem;

*/

import awt.*;

interface CallbackAble {
  public int Callback(String msg,Object p);
}

class MyMenuDefaultCallback 
implements CallbackAble {
  public int Callback(String msg,Object p) {
    return(0);
  }
}

class DesMenu 
implements CallbackAble {
  static protected MyMenuDefaultCallback DummyCallback;

  String Txt;
  boolean Toggled;
  boolean Enabled;

  boolean IsTitle;
  CallbackAble Handler;
  String CallbackString;
  Object CallbackParam;

  private void clear() {
    Handler=DummyCallback;
    Txt="Elem";
    Toggled=false;
    Enabled=true;
    IsTitle=false;
    CallbackParam=null;
  }

  public int Callback(String msg,Object p) {
    CallbackString=msg;
    CallbackParam=p;
    return(Callback());
  }

  public int Callback() {
    return(Handler.Callback(CallbackString,CallbackParam));
  }

  public DesMenu(){
    clear();
  }

  public DesMenu(String vTxt,boolean vIsTitle) {
    clear();
    Txt=vTxt;
    IsTitle=vIsTitle;
    Txt="Title";
  }

  public DesMenu(String vTxt,boolean vToggled,boolean vEnabled) {
    clear();
    Txt=vTxt;
    Toggled=vToggled;
    Enabled=vEnabled;
  }
}

class MyMenuItem 
extends MenuItem 
implements CallbackAble {
  DesMenu mydes;

  public void setMark(boolean t) {super.setMark(t); mydes.Toggled=t; }
  public void enable() {super.enable(); mydes.Enabled=true; }
  public void disable() {super.disable(); mydes.Enabled=false; }

  public int Callback(String msg,Object p) {
    return(mydes.Callback(msg,p));
  }

  public int Callback() {
    return(mydes.Callback());
  }

  public void selected() {   
    Callback();  
  }


  public MyMenuItem(Menu m,DesMenu Des){
    super(Des.Txt,m,Des.Toggled);
    
    mydes=Des;
    setMark(Des.Toggled);
    if(Des.Enabled) enable();
    else disable();
  }
}

class MyMenu {
  MenuBar mymenubar;
  Menu    mymenu[];
  MyMenuItem myitems[][]=new MyMenuItem[40][];
  
  public void map() {
    int i;

    for(i=0;i<mymenu.length;i++) mymenu[i].show();
  }
  public void unMap() {
    int i;

    for(i=0;i<mymenu.length;i++) mymenu[i].hide();
  }


  public MyMenu(Frame fr,DesMenu menu[]){
    int i,j,n,m;

    mymenubar=new MenuBar(fr);

    n=0;
    m=0;
    for(i=0;i<menu.length && menu[i]!=null ;i++) {
      if(menu[i].IsTitle ) {
	if(n>0) myitems[n-1]=new MyMenuItem[m];
	m=0;
	n++;
      }
      else m++;
    }
    mymenu=new Menu[n];
    if(n>0 && m>0) myitems[n-1]=new MyMenuItem[m];
    
    n=0;
    m=0;
    for(i=0;i<menu.length && menu[i]!=null;i++) {
      if(menu[i].IsTitle) {
	mymenu[n]=new Menu(menu[i].Txt,mymenubar);
	m=0;
	n++;
      }
      else {
	myitems[n-1][m]=new MyMenuItem(mymenu[n-1],menu[i]);
	m++;
      }
    }
  }
}

class MyWindow extends Window {
  Graphics mygraphics;

  public void map() {
    super.map();
    System.out.println("In MyWindows Map");
    mygraphics=new Graphics(this);
  }

  public void unmap() {
    mygraphics.dispose();
  }

  public void paint() {
    System.out.println("In MyWindow Paint");

    setForeground(Color.green);
    setBackground(Color.gray);
    drawString("Ha que c'est la windows la !",10,50);

    mygraphics.setForeground(Color.black);
    mygraphics.setBackground(Color.red);
    mygraphics.drawString("Ha que COUCOU !",20,20);

  }

  public MyWindow(Frame myframe) {
    super(myframe,"WindowMain",Color.white,200,200);    

    System.out.println("In MyWindows Const 1");
    move(100,100);
  }

}

class MyFrame  {
  WServer myserver;
  Frame   myframe;
  MyWindow  mywindow;
  MyMenu  mymenu;
  DesMenu mydesmenu[];

  public void map() {
    if(mymenu==null) mymenu=new MyMenu(myframe,mydesmenu);
    myframe.map();
    mywindow.map();
    mymenu.map();
  }

  public void unMap() {
    mymenu.unMap();
    mywindow.unMap();
    myframe.unMap();
  }

  public MyFrame(WServer ws, boolean hasTitlebar, boolean isModal, 
		 Frame parentFrame, int w, int h, Color bg,
		 String Title,DesMenu menu[]) {

    myserver=ws;
    mydesmenu=menu;

    myframe=new Frame(myserver,hasTitlebar,isModal,parentFrame,w,h,bg);
    myframe.setTitle(Title);

    mywindow=new MyWindow(myframe);

  }
}



class hello {
  static DesMenu menu[]=new DesMenu[6];

  public static void main (String args[]) {

    menu[0]=new DesMenu("Titre1",true);
    menu[1]=new DesMenu("Elem 1",false,true);
    menu[2]=new DesMenu("Elem 2",false,true);
    menu[3]=new DesMenu("Elem 3",false,true);
    menu[4]=new DesMenu("Elem 4",false,true);

    WServer myserver=new WServer();
    myserver.start();
    MyFrame myframe=new MyFrame(myserver,true,false,null,500,500,Color.blue,
				"Essai de Frame",menu);
    myframe.map();
  }
}

---------------------------------14750120953791--

-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post