⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 zscom_func.java

📁 JBuilder8开发的ComboEdit控件
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
package wisesoft;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
import com.borland.dx.dataset.*;
import com.borland.dx.sql.dataset.*;
import java.math.*;
import com.borland.dx.text.*;
import com.borland.dbswing.*;
import com.borland.jbcl.layout.*;
import java.text.Format;
import java.util.Calendar;
import java.lang.reflect.Field;
//import Padapt_Report.*;
//import Padapt_ToFiles.*;
import java.io.*;

/**
 * <p>Title:工程常用函数 </p>
 * <p>Description:系统常用公用函数,窗体显示,消息框显示,数据类型转换等,丰富哈!!! </p>
 * <p>Copyright: Copyright (c) 2003</p>
 * <p>Company: </p>
 * @author bear_king 熊运余
 * @version 1.0
 */

public class ZSCom_Func
{
  static Dialog m_FrameParent;
  //==============================================================================
  //列表的行号宽度
  public static final  int ROWHEADE_WIDTH =50;
  //===============================================================================
  //投影中心点的坐标和高度(用于计算限制区形状)
  public static double	DEF_ORG_LONG = 102.0;
  public static double	DEF_ORG_LAT = 30.0;
  public static int	DEF_ORG_HEIGHT = 500;
  public static int   C_STANDARD_RADIUS = 10;   //公里
  public static int   C_STANDARD_PCOUNT = 10;  //点数
  public static double  PI = 3.1415926;
 //================================================================================
 //窗体显示风格
  public static int C_SHOW_CENTER=1;//显示居中,查找窗体
  public static int C_SHOW_MAX=0;//最大显示
  public static int C_SHOW_Standard=2;//居中,窗体大小不限制
  public static int C_SHOW_SmallFind=3;//查询小窗体
  public static int C_SHOW_Default=6;//缺省对话框大小

  public static int C_FINDDLG_WIDTH=500;//查找中窗体宽
  public static int C_FINDDLG_HEIGHT=500;//查找中窗体高

  public static int C_EDITDLG_WIDTH=900;//录入窗体宽,缺省设置
  public static int C_EDITDLG_HEIGHT=700;//录入窗体高,缺省设置

  public static int C_FIND_SMALLDLG_WIDTH=500;//查找中窗体宽
  public static int C_FIND_SMALLDLG_HEIGHT=500;//查找中窗体高
  //===================================================================================
  /////////////////版本控制////////////
  public static String Data_Version="V2.10";
  /////////////////////////////
  // 连接数据库的信息
  public static String[] m_strConnectDBInfo = {"", "", "", ""};
  //设置光标显示类型
  public static Cursor C_WAIT_CURSOR = new Cursor(java.awt.Cursor.WAIT_CURSOR);
  public static Cursor C_DEFAULT_CURSOR = new Cursor(java.awt.Cursor.DEFAULT_CURSOR);
    // 字体大小
  private static boolean  m_bSameSize =true;// false;
  private static int  m_nFontSize = 12;
  private static double  m_FontRatio= 0.65;
  public static String c_font_str="Dialog";
  //设置界面背景颜色20031126
  public static Color m_colorPanel= new Color(120, 200, 250);
  public static Color m_EditBackcolor= new Color(255, 255, 255);//编辑框背景色
  //一级父窗体20031126
  public static JFrame C_Parent_Frame;
  public static JDialog C_Parent_Dlg;//二级父窗体,对话框
  //设置窗体背景颜色
  public static Color m_backcolor= new Color(96, 149, 185);
  public static Color m_oldbackcolor= new Color(174,178,195);  //
  //设置主要界面的标题

  public static String C_MainWindow_Title="";//主窗体名称
  public static String C_SubWindow_Title="";//子窗体名称

  public static Dimension m_dimEditBtn = new Dimension(90, 28);//设置编辑按钮大小
  public static String m_strFontNameEditBtn = new String("Dialog");//设置编辑按钮字体
  public static int m_nFontSizeEditBtn = 12;//设置编辑按钮字体大小


  public ZSCom_Func() {

  }

  //显示对话框大小、位置调整(),更改将显示方法加入进去
  public static void  SetUserDlg(JDialog AForm,JComponent AParent,int ShowType)
  {
    int nComponentSize = AForm.getComponentCount();
    AForm.setBackground(m_backcolor);
    for(int i=0; i<nComponentSize; i++)
     {
       ZSCom_Func.setComponentFont((JComponent)AForm.getComponent(i));

    }
    AForm.pack();

    switch(ShowType)
    {
      case  1://居中,标准查找窗体大小//Center
        {
          Dimension dlgSize = new Dimension();
          dlgSize.width = C_FINDDLG_WIDTH;
          dlgSize.height = C_FINDDLG_HEIGHT;
          AForm.setSize(dlgSize);
          Dimension frmSize = AParent.getSize();
          Point loc = AParent.getLocationOnScreen();
          //JOpctionPane.s
          AForm.setLocation( (frmSize.width - dlgSize.width) / 2 + loc.x,
                            (frmSize.height - dlgSize.height) / 2 + loc.y);

        }
       break;
       case  0://全屏大小//Max
       {
         Dimension frmSize = AParent.getSize();
         Point loc = AParent.getLocationOnScreen();
         AForm.setLocation(loc);
         frmSize.height = frmSize.height-40;
         frmSize.width = frmSize.width ;
         AForm.setSize(frmSize);
        }
        break;
        case 2://缺省大小,设计期大小//standard
        {
          Dimension dlgSize = AForm.getSize();
          Dimension frmSize = AParent.getSize();
          Point loc = AParent.getLocationOnScreen();
          //JOpctionPane.s
          AForm.setLocation( (frmSize.width - dlgSize.width) / 2 + loc.x,
                  (frmSize.height - dlgSize.height) / 2 + loc.y);

        }
        break;
        case 3://查找小窗体,居中C_SHOW_SmallFind
        {
          Dimension dlgSize = new Dimension();
          dlgSize.width = C_FIND_SMALLDLG_WIDTH;
          dlgSize.height = C_FIND_SMALLDLG_HEIGHT;
          AForm.setSize(dlgSize);
          Dimension frmSize = AParent.getSize();
          Point loc = AParent.getLocationOnScreen();
          //JOpctionPane.s
          AForm.setLocation( (frmSize.width - dlgSize.width) / 2 + loc.x,
                            (frmSize.height - dlgSize.height) / 2 + loc.y);
        }
        break;
        case 4://查找小窗体,下拉,居左
          {
            Dimension dlgSize = new Dimension();
            dlgSize.width = C_FIND_SMALLDLG_WIDTH;
            dlgSize.height = C_FIND_SMALLDLG_HEIGHT;
            AForm.setSize(dlgSize);
            Dimension frmSize = AParent.getSize();
            Point loc = AParent.getLocationOnScreen();
            AForm.setLocation( (frmSize.width - dlgSize.width) / 2 + loc.x,
                                (frmSize.height - dlgSize.height) / 2 + loc.y);
          }
        break;

        case  6://缺省大小//
        {
          Dimension frmSize = AParent.getSize();
          Dimension dlgSize = AForm.getSize();
          Point loc = AParent.getLocationOnScreen();
          frmSize.height =  frmSize.height;//1200 - 40;
          frmSize.width = frmSize.width ;//1600;
          dlgSize.height = C_EDITDLG_HEIGHT;//700
          dlgSize.width = C_EDITDLG_WIDTH;//900

          AForm.setLocation( (frmSize.width - dlgSize.width) / 2 + loc.x,
                            (frmSize.height - dlgSize.height) / 2 + loc.y);

          AForm.setSize(dlgSize.width, dlgSize.height);

        }
        break;

    }
    AForm.setModal(true);
    AForm.show();

  }

  public static void Showmessage(String str,String strtitle)
  {
    if(!isNull(C_Parent_Dlg))
    JOptionPane.showMessageDialog(C_Parent_Dlg,str,strtitle, JOptionPane.INFORMATION_MESSAGE);
    else
    JOptionPane.showMessageDialog(C_Parent_Frame,str,strtitle, JOptionPane.INFORMATION_MESSAGE);
  }

   public static void Showmessage(String str,String strtitle,JDialog m_pFrm)
    {
        JOptionPane.showMessageDialog(m_pFrm,str,strtitle, JOptionPane.INFORMATION_MESSAGE);
    }

  public static void SetQuery(Database database,QueryDataSet Qry,String sqlStr)
  {
      QueryDescriptor m_QD = new QueryDescriptor(database, sqlStr);
      Qry.setQuery(m_QD);
  }

  public static int sizeof(Object obj){
    Class cla = obj.getClass();
    if(cla.getName().equals("java.lang.Double"))
      return 8;
    else if(cla.getName().equals("java.lang.Integer"))
      return 4;
    else if(cla.getName().equals("java.lang.Byte"))
      return 1;
    else if(cla.getName().equals("java.lang.Float"))
      return 4;
    else if(cla.getName().equals("java.lang.Short"))
      return 2;
    else if(cla.getName().equals("java.lang.Long"))
      return 8;
    else return -1;
  }

  public static BigDecimal IntToBigdecimal (int i)
 {
    Variant m_variant=new Variant();
    m_variant.setInt(i);
    return m_variant.getAsBigDecimal();
 }
 public static int BigdecimalToInt (BigDecimal i)
 {
    Variant m_variant=new Variant();
    m_variant.setBigDecimal(i);
    return m_variant.getAsInt();
 }


  public static void  SetUserFrm(JFrame AForm,JComponent AParent,int ShowType)
    {
      int nComponentSize = AForm.getComponentCount();
      AForm.setBackground(m_backcolor);
      for (int i = 0; i < nComponentSize; i++) {
        setComponentFont( (JComponent) AForm.getComponent(i));
        setComponentBackColor( (JComponent) AForm.getComponent(i));
        //      setComponentGridbagLayout((JComponent)AForm.getComponent(i));
      }

      switch(ShowType)
      {
        case  1://C_SHOW_CENTER://居中,标准查找窗体大小
          {
            Dimension dlgSize = new Dimension();
            dlgSize.width = C_FINDDLG_WIDTH;
            dlgSize.height = C_FINDDLG_HEIGHT;
            AForm.setSize(dlgSize);
            Dimension frmSize = AParent.getSize();
            Point loc = AParent.getLocationOnScreen();
            //JOpctionPane.s
            AForm.setLocation( (frmSize.width - dlgSize.width) / 2 + loc.x,
                              (frmSize.height - dlgSize.height) / 2 + loc.y);

          }
         break;
         case  0://C_SHOW_MAX://全屏大小
         {
           Dimension frmSize = AParent.getSize();
           Point loc = AParent.getLocationOnScreen();
           loc.y= loc.y;
           loc.x= loc.x;
           AForm.setLocation(loc);
           frmSize.height = frmSize.height;
           frmSize.width = frmSize.width ;
           AForm.setSize(frmSize);

          }
          break;
          case 2://C_SHOW_Standard 缺省大小,设计期大小
          {
            Dimension dlgSize = AForm.getSize();
            Dimension frmSize = AParent.getSize();
            Point loc = AParent.getLocationOnScreen();
            //JOpctionPane.s
            AForm.setLocation( (frmSize.width - dlgSize.width) / 2 + loc.x,
                    (frmSize.height - dlgSize.height) / 2 + loc.y);

          }
          break;
          case 3://C_SHOW_SmallFind  查找小窗体,居中
          {
            Dimension dlgSize = new Dimension();
            dlgSize.width = C_FIND_SMALLDLG_WIDTH;
            dlgSize.height = C_FIND_SMALLDLG_HEIGHT;
            AForm.setSize(dlgSize);
            Dimension frmSize = AParent.getSize();
            Point loc = AParent.getLocationOnScreen();
            AForm.setLocation( (frmSize.width - dlgSize.width) / 2 + loc.x,
                              (frmSize.height - dlgSize.height) / 2 + loc.y);
          }
          break;
          case 4://查找小窗体,下拉,居左
            {
              Dimension dlgSize = new Dimension();
              dlgSize.width = C_FIND_SMALLDLG_WIDTH;
              dlgSize.height = C_FIND_SMALLDLG_HEIGHT;
              AForm.setSize(dlgSize);
              Dimension frmSize = AParent.getSize();
              Point loc = AParent.getLocationOnScreen();
              AForm.setLocation( (frmSize.width - dlgSize.width) / 2 + loc.x,
                                  (frmSize.height - dlgSize.height) / 2 + loc.y);
            }
          break;
      }
      //AForm.setUndecorated(true);
      //AForm.setDefaultLookAndFeelDecorated(false);
      AForm.show();
    }
  ////////////////////////////////////////////////////////////////////////////////////////////////////
// added by jqf 2003.09.30

  public static boolean  deleteMessageDlg()
  {
    if (!isNull(C_Parent_Dlg))
    {
      if (JOptionPane.showConfirmDialog(C_Parent_Dlg, "确实要删除吗?", "删除提示",
                                        JOptionPane.YES_NO_OPTION) ==
          JOptionPane.YES_OPTION) {
        return true;
      }
      else {
        return false;
      }
    }
    else
    {
      if (JOptionPane.showConfirmDialog(C_Parent_Frame, "确实要删除吗?", "删除提示",
                                        JOptionPane.YES_NO_OPTION) ==
          JOptionPane.YES_OPTION) {
        return true;
      }
      else {
        return false;
      }


    }

  }

  public static void  setComponentGridbagLayout(JComponent component)
  {

    int nComponent = component.getComponentCount();
    if(nComponent == 0)
    {
      return;
    }
    for(int i=0; i<nComponent; i++)
    {
      try
      {
        if( (component.getComponent(i).getClass().equals(JPanel.class) ||
             component.getComponent(i).getClass().equals(Panel.class)) &&
            ((JComponent)component.getComponent(i)).getLayout().getClass().equals(XYLayout.class))
        {
          ((JComponent)component.getComponent(i)).setLayout(new GridBagLayout());
          component.getComponent(i).validate();
        }
        setComponentGridbagLayout((JComponent)component.getComponent(i));
      }
      catch(Exception ex)
      {
//        ex.printStackTrace();
      }
    }
  }

  public static void  setComponentFont(JComponent component)
  {
   if(!m_bSameSize)
   {
     return;
   }
    int nComponent = component.getComponentCount();
    if(nComponent == 0)
    {
      return;
    }
    for(int i=0; i<nComponent; i++)
    {
      try
      {
        setComponentFont( (JComponent) component.getComponent(i));
      }
      catch(Exception ex)
      {
      }
    }
  }

      // 获取经度度数值
      public static  String getLongitudeDegree(String str)
      {
        int nLen = str.length();
        int i;
        String strLongigude;

        if((str.charAt(0) == 'e' || str.charAt(0) == 'E') && nLen <= 2 || nLen < 3)
        {
          JOptionPane.showMessageDialog(C_Parent_Frame, "您输入的经度度数值错误", "错误提示", JOptionPane.INFORMATION_MESSAGE);
          return "";
        }

        if(str.charAt(0) == 'e' || str.charAt(0) == 'E')
        {
          for(i=1; i<nLen; i++)
          {
            if(str.charAt(i) < '0' || str.charAt(i) > '9')
            {
              JOptionPane.showMessageDialog(C_Parent_Frame, "您输入的经度度数值错误", null, JOptionPane.INFORMATION_MESSAGE);
              return "";
            }
          }
          strLongigude = str.substring(1);
        }
        else
        {
          for(i=0; i<nLen; i++)
          {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -