public boolean dirty() {
    if (!XJApplication.shared().supportsPersistence()) return false;

    Boolean b = (Boolean) jFrame.getRootPane().getClientProperty(PROPERTY_WINDOW_MODIFIED);
    if (b == null) return false;
    else return b.booleanValue();
  }
 public void setVisible(boolean flag) {
   if (flag && !alreadyBecomeVisible) {
     alreadyBecomeVisible = true;
     restoreWindowBounds();
     becomingVisibleForTheFirstTime();
   }
   jFrame.setVisible(flag);
 }
  public void resetDirty() {
    if (!XJApplication.shared().supportsPersistence()) return;

    if (dirty) {
      dirty = false;
      jFrame.getRootPane().putClientProperty(PROPERTY_WINDOW_MODIFIED, Boolean.FALSE);
      menuItemStatusChanged(XJMainMenuBar.MI_SAVE);
    }
  }
  public void setDirty() {
    if (!XJApplication.shared().supportsPersistence()) return;

    // Use dirty member to speed up
    if (!dirty) {
      dirty = true;
      jFrame.getRootPane().putClientProperty(PROPERTY_WINDOW_MODIFIED, Boolean.TRUE);
      menuItemStatusChanged(XJMainMenuBar.MI_SAVE);
    }
  }
  public void close() {
    XJMainMenuBar.removeInstance(mainMenuBar);
    if (mainMenuBar != null) {
      mainMenuBar.setDelegate(null);
      mainMenuBar = null;
    }

    saveWindowBounds();

    jFrame.dispose();
    jFrame = null;

    if (delegate != null) delegate.frameDidClose(this);
  }
  public XJFrame() {
    jFrame = new JFrame();
    jFrame.addWindowListener(
        new WindowAdapter() {
          public void windowActivated(WindowEvent e) {
            XJFrame.this.windowActivated();
          }

          public void windowDeactivated(WindowEvent e) {
            // Don't send the deactivate event if the frame is closed
            // (because this event is send also when the window just closed
            // which is kind of weird)
            if (jFrame != null) XJFrame.this.windowDeactivated();
          }
        });
    setDefaultSize();
    undoEngine = new XJUndoEngine();
  }
 public boolean isActive() {
   return jFrame.isActive();
 }
 public boolean isVisible() {
   return jFrame.isVisible();
 }
 public JLayeredPane getLayeredPane() {
   return jFrame.getLayeredPane();
 }
 public void bringToFront() {
   jFrame.toFront();
 }
 public void setTitle(String title) {
   jFrame.setTitle(title);
 }
 public void setPosition(int x, int y) {
   jFrame.setLocation(x, y);
 }
 public Dimension getSize() {
   return jFrame.getSize();
 }
 public void setSize(Dimension size) {
   jFrame.setSize(size);
 }
 public void setSize(int dx, int dy) {
   jFrame.setSize(dx, dy);
 }
 public Point getLocation() {
   return jFrame.getLocation();
 }
 public void setLocation(Point loc) {
   jFrame.setLocation(loc);
 }
 public String getTitle() {
   return jFrame.getTitle();
 }
 public boolean isCompletelyOnScreen() {
   Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
   return jFrame.getX() + jFrame.getWidth() < dim.getWidth()
       && jFrame.getY() + jFrame.getHeight() < dim.getHeight();
 }
 public void center() {
   jFrame.setLocationRelativeTo(null);
 }
 public Component getGlassPane() {
   return jFrame.getGlassPane();
 }
 public void offsetPosition(int dx, int dy) {
   Point p = jFrame.getLocation();
   jFrame.setLocation(p.x + dx, p.y + dy);
 }
 public JRootPane getRootPane() {
   return jFrame.getRootPane();
 }
 public void setDefaultSize() {
   Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
   jFrame.setSize((int) (dim.width * 0.5), (int) (dim.height * 0.5));
 }
 public void setMainMenuBar(XJMainMenuBar menubar) {
   this.mainMenuBar = menubar;
   jFrame.setJMenuBar(mainMenuBar.getJMenuBar());
 }
 public void setResizable(boolean flag) {
   jFrame.setResizable(flag);
 }
 public void pack() {
   jFrame.pack();
 }
 public void setDefaultCloseOperation(int operation) {
   jFrame.setDefaultCloseOperation(operation);
 }
 public Container getContentPane() {
   return jFrame.getContentPane();
 }