Example #1
0
  public static void main(String[] args) {
    Frame frame = new Frame("Tetris");
    Tetris tetris = new Tetris();
    frame.add(tetris);
    tetris.init();
    tetris.start();

    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });

    frame.setSize(489, 441);
    frame.setResizable(false);
    frame.setVisible(true);
  }
Example #2
0
  RootWindow(Container container, Screen screen, Format[] format, Client c) {
    super(screen.rootId);
    rootwindow = container;
    client = c;
    screen.setRoot((Window) this);
    this.width = (short) (screen.width);
    this.height = (short) (screen.height);
    this.screen = screen;
    depth = screen.rootDepth;
    id = screen.rootId;
    type = DRAWABLE_WINDOW;
    x = y = 0;
    origin.x = 0;
    origin.y = 0;
    clss = (byte) InputOutput;
    for (int i = 0; i < format.length; i++) {
      if (format[i].depth == screen.rootDepth) {
        this.bitsPerPixel = format[i].bpp;
      }
    }
    setVisual(screen.rootVisual);
    setBackgroundIsPixel();
    background.pixel = screen.white;

    setBorderIsPixel();
    border.pixel = screen.black;
    borderWidth = 0;
    Resource.add(this);
    makeOptional();
    attr &= ~(1 << 3); // cursorIsNone

    optional.cursor = Cursor.rootCursor;
    setColormap(screen.defaultColormap);

    //  if(rootwindow instanceof JFrame){
    //    rootwindow.setSize(this.width+10, this.height+30); // ??
    //  }
    //  else{
    rootwindow.setSize(this.width, this.height);
    //  }

    try {
      ddxwindow = (DDXWindow) (Window.dDXWindow.newInstance());
    } catch (Exception e) {
      System.err.println(e);
      /*ddxwindow=new DDXWindowImp();*/
    }

    ddxwindow.init(this);
    ddxwindow.setLocation(0, 0);

    if (rootwindow instanceof Frame) {
      // ((Frame)rootwindow).setLayout(null);
      ((Frame) rootwindow).setResizable(false);
      ((Frame) rootwindow).setMenuBar(null);
      ((Frame) rootwindow).add((java.awt.Component) ddxwindow);
    } else if (rootwindow instanceof Applet) {
      ((Applet) rootwindow).add((java.awt.Component) ddxwindow);
    }
    /*
        else if(rootwindow instanceof JFrame){
          ((JFrame)rootwindow).getContentPane().setLayout(null);
          ((JFrame)rootwindow).setResizable(false);
          ((JFrame)rootwindow).setJMenuBar(null);
          ((JFrame)rootwindow).getContentPane().add((java.awt.Component)ddxwindow);
        }
        else if(rootwindow instanceof JWindow){
          ((JWindow)rootwindow).getContentPane().setLayout(null);
          ((JWindow)rootwindow).getContentPane().add((java.awt.Component)ddxwindow);
        }
        else if (rootwindow instanceof JApplet){
          ((JApplet)rootwindow).setJMenuBar(null);
          ((JApplet)rootwindow).getContentPane().add((java.awt.Component)ddxwindow);
        }
    */
    else {
      rootwindow.add((java.awt.Component) ddxwindow);
    }

    if (screen.windowmode != WeirdX.InBrowser) {
      rootwindow.addNotify();
    } else {
      rootwindow.setVisible(true);
    }
    ddxwindow.setVisible(true);

    {
      rootwindow.validate();
      Insets insets = rootwindow.getInsets();
      rootwindow.setSize(
          this.width + insets.left + insets.right, this.height + insets.top + insets.bottom);
      ddxwindow.setLocation(insets.left, insets.top);
      rootwindow.validate();
    }

    ddxwindow.requestFocus();
    Window.focus.win = id;

    Window.LOCK = rootwindow.getTreeLock();
    Client.LOCK = rootwindow.getTreeLock();
    Resource.LOCK = rootwindow.getTreeLock();

    spriteTrace[0] = this;
    sprite.win = this;
  }