Advertisement
Guest User

CFrame

a guest
Oct 16th, 2012
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.71 KB | None | 0 0
  1. /******************************************************************************
  2.  * Product: Adempiere ERP & CRM Smart Business Solution                       *
  3.  * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved.                *
  4.  * This program is free software; you can redistribute it and/or modify it    *
  5.  * under the terms version 2 of the GNU General Public License as published   *
  6.  * by the Free Software Foundation. This program is distributed in the hope   *
  7.  * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
  8.  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.           *
  9.  * See the GNU General Public License for more details.                       *
  10.  * You should have received a copy of the GNU General Public License along    *
  11.  * with this program; if not, write to the Free Software Foundation, Inc.,    *
  12.  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.                     *
  13.  * For the text or an alternative of this public license, you may reach us    *
  14.  * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA        *
  15.  * or via info@compiere.org or http://www.compiere.org/license.html           *
  16.  *****************************************************************************/
  17. package org.compiere.swing;
  18.  
  19. import java.awt.Container;
  20. import java.awt.GraphicsConfiguration;
  21. import java.awt.HeadlessException;
  22.  
  23. import javax.swing.JFrame;
  24. import javax.swing.JPanel;
  25.  
  26. /**
  27.  *  Adempiere Frame
  28.  * 
  29.  *  @author Jorg Janke
  30.  *  @version $Id: CFrame.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $
  31.  */
  32. public class CFrame extends JFrame
  33. {
  34.     /**
  35.      *
  36.      */
  37.     private static final long serialVersionUID = 6282268921005682543L;
  38.  
  39.     /**
  40.      *  CFrame
  41.      *  @throws HeadlessException
  42.      */
  43.     public CFrame () throws HeadlessException
  44.     {
  45.         super ();
  46.     }   //  CFrame
  47.  
  48.     /**
  49.      *  CFrame
  50.      *  @param gc
  51.      */
  52.     public CFrame (GraphicsConfiguration gc)
  53.     {
  54.         super (gc);
  55.     }   //  CFrame
  56.  
  57.     /**
  58.      *  CFrame
  59.      *  @param title
  60.      *  @throws HeadlessException
  61.      */
  62.     public CFrame (String title) throws HeadlessException
  63.     {
  64.         super (cleanup(title));
  65.     }   //  CFrame
  66.  
  67.     /**
  68.      *  CFrame
  69.      *  @param title
  70.      *  @param gc
  71.      */
  72.     public CFrame (String title, GraphicsConfiguration gc)
  73.     {
  74.         super (cleanup(title), gc);
  75.     }   //  CFrame
  76.  
  77.     /** Window ID           */
  78.     private int     p_AD_Window_ID = 0;
  79.    
  80.     /**
  81.      *  Frame Init.
  82.      *  Install ALT-Pause
  83.      */
  84.     protected void frameInit ()
  85.     {
  86.         super.frameInit ();
  87.         setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  88.         //
  89.         Container c = getContentPane();
  90.         if (c instanceof JPanel)
  91.         {
  92.             JPanel panel = (JPanel)c;
  93.             panel.getActionMap().put(CDialog.ACTION_DISPOSE, CDialog.s_dialogAction);
  94.             panel.getInputMap(JPanel.WHEN_IN_FOCUSED_WINDOW).put(CDialog.s_disposeKeyStroke, CDialog.ACTION_DISPOSE);
  95.         }
  96.     }   //  frameInit
  97.    
  98.     /**
  99.      *  Cleanedup Title
  100.      *  @param title title
  101.      *  @return title w/o mn
  102.      */
  103.     private static String cleanup (String title)
  104.     {
  105.         if (title != null)
  106.         {
  107.             int pos = title.indexOf('&');
  108.             if (pos != -1 && title.length() > pos)  //  We have a mnemonic
  109.             {
  110.                 int mnemonic = title.toUpperCase().charAt(pos+1);
  111.                 if (mnemonic != ' ')
  112.                     title = title.substring(0, pos) + title.substring(pos+1);
  113.             }
  114.         }
  115.         return title;
  116.     }   //  getTitle
  117.  
  118.     /**
  119.      *  Set Title
  120.      *  @param title title
  121.      */
  122.     public void setTitle(String title)
  123.     {
  124.         super.setTitle(cleanup(title));
  125.     }   //  setTitle
  126.  
  127.     /**
  128.      * @return Returns the AD_Window_ID.
  129.      */
  130.     public int getAD_Window_ID ()
  131.     {
  132.         return p_AD_Window_ID;
  133.     }   //  getAD_Window_ID
  134.  
  135.     /**
  136.      * @param window_ID The AD_Window_ID to set.
  137.      */
  138.     public void setAD_Window_ID (int window_ID)
  139.     {
  140.         p_AD_Window_ID = window_ID;
  141.     }   //  getAD_Window_ID
  142.  
  143. }   //  CFrame
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement