Package jsynoptic.ui

Source Code of jsynoptic.ui.JSynopticFrame

/* ========================
* JSynoptic : a free Synoptic editor
* ========================
*
* Project Info:  http://jsynoptic.sourceforge.net/index.html
*
* This program is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* (C) Copyright 2001-2005, by :
*     Corporate:
*         EADS Astrium SAS
*         EADS CRC
*     Individual:
*         Claude Cazenave
*
* $Id: JSynopticFrame.java,v 1.6 2009/02/04 13:43:50 ogor Exp $
*
* Changes
* -------
* 15 d�c. 2005 : Initial public release (CC);
*
*/
package jsynoptic.ui;

import java.awt.BorderLayout;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.Vector;

import javax.swing.JFrame;
import javax.swing.JMenuBar;
import javax.swing.WindowConstants;

/**
* The default implementation of JSynoptic with the default panels from
* JSynopticPanels layout into a JFrame
*
* @author cazenave
* @version 1.0
*
*/
public class JSynopticFrame extends JSynopticPanels {
 
  public JSynopticFrame(JFrame frame, Vector commands) {
    super(commands, frame, frame.getContentPane());
   
    // on exit
    frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    frame.addWindowListener(new WindowAdapter() {
      public void windowClosing(WindowEvent e) {
        exit();
      }
    });
  }

    protected void init(Vector commands) {
      super.init(commands);
    ((JFrame)getOwner()).setIconImage(resources.getIcon("jsynIcon").getImage());
    }

  /**
   * Display progress ratio
   *
   * @param percent
   */
  protected void progress(int percent){
    if (Run.splashSreen.isVisible())
      Run.splashSreen.setProgressBarPosition(percent);
  }
 
  /**
   * Display the GUI
   */
  protected void display() {
      super.display();
      ((JFrame)getOwner()).show();
  }

  /**
   * Create menus
   */
  protected void createMenu(){
    super.createMenu();
    ((JFrame)getOwner()).setJMenuBar((JMenuBar)menuBar);
  }

  /**
   * Create tool bar
   */
  public void createToolBar() {
    super.createToolBar();
    container.add(BorderLayout.NORTH, toolbar);
  }
 
  // Properties Management => save and restore size
  static protected String propW = "jsynoptic.ui.JSynoptic.width";

  static protected String propH = "jsynoptic.ui.JSynoptic.height";

  static protected int propWDefault = 700;

  static protected int propHDefault = 500;

  protected void saveProperties() {
    userProperties.setInt(propW, ((JFrame)getOwner()).getWidth());
    userProperties.setInt(propH, ((JFrame)getOwner()).getHeight());
    super.saveProperties();
  }
 
  protected void loadProperties() {
    ((JFrame)getOwner()).setSize(userProperties.getInt(propW, propWDefault), userProperties
        .getInt(propH, propHDefault));
    super.loadProperties();
  }
}
TOP

Related Classes of jsynoptic.ui.JSynopticFrame

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.