lendview.java

来自「一个企业小型固定资产系统的源代码。发布出来让刚学习java的人研究。」· Java 代码 · 共 171 行

JAVA
171
字号
package project;

/*
 *
 .java:建立固定资产借用与归还管理界面(类)。
 *包括:借用、归还2个子界面。
 */
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.*;
import javax.swing.event.*;
import java.text.SimpleDateFormat;

public class LendView extends JDialog   {
   public LendPanel p1;
   public LendView(ButPanel p2) {
        getContentPane().setLayout(new BorderLayout());
        p1 = new LendPanel();
        getContentPane().add(p1,BorderLayout.CENTER);
        getContentPane().add(p2,BorderLayout.SOUTH);
   }
}
class LendPanel extends JPanel  {
   private Container cont;
   private GridBagLayout layout;
   private GridBagConstraints cons;
   String [] empno;
   String [] isret = {"1","1"};
   JLabel lblAssetId;
   JLabel lblAssetName;
   JLabel lblModel;
   JLabel lblPrice;
   JLabel lblEmpno;
   JLabel lblUsedate;
   JLabel lblRetdate;
   JLabel lblIsreturn;
   JLabel lblLender;
   JLabel lblRemarks;
   JLabel lbllenProess ;
    JLabel lbldate;
java.util.Date nowTime;
   public JTextField jtfAssetId ;
   public JTextField jtfAssetName ;
   public JTextField jtfModel ;
   public JTextField jtfPrice ;
   public JTextField  jtfEmpno ;
   public JTextField jtfUsedate ;
   public JTextField jtfRetdate ;
   public JComboBox jcbIsreturn ;
   public JTextField jtfLender ;
   public JTextField jtfprocess ;
    public JTextField jtfdate ;
   public JTextArea  jtalenRemark  ;

      JScrollPane jScrollPane1 ;

   public LendPanel() {
        cont = this;
        layout = new GridBagLayout();
        cont.setLayout(layout);
        cons = new GridBagConstraints();

        lblAssetId = new JLabel("资产代码");
        lblAssetName = new JLabel("资产名称");
        lblModel = new JLabel("规格型号");
        lblPrice = new JLabel("单位") ;
        lblEmpno = new JLabel("数量");
        lblUsedate = new JLabel("单价");
        lblRetdate = new JLabel("金额");
        lblIsreturn = new JLabel("仓库");
        lblLender = new JLabel("操作人");
        lbllenProess = new JLabel("用途");
        lblRemarks = new JLabel("备注");
         lbldate = new JLabel("日期");
        jtfAssetId = new JTextField(10);
        jtfAssetName = new JTextField(10);
        jtfModel = new JTextField(10);
        jtfPrice = new JTextField(10);
        jtfEmpno  = new JTextField(10);
        jtfEmpno.setText("0.00");



        jtfUsedate = new JTextField(10);
        jtfUsedate.setText("0.00");

        nowTime = new java.util.Date();
   SimpleDateFormat HMFromat = new SimpleDateFormat("yyyy-MM-dd");
   String dispalyNowTime = HMFromat.format(nowTime);
        jtfRetdate = new JTextField(10);
          jtfdate = new JTextField(10);
        jtfdate.setText(dispalyNowTime);
        jtfRetdate.setText("0.00");
        jcbIsreturn = new JComboBox(isret);
        jcbIsreturn.setOpaque(true);
        jcbIsreturn.setPreferredSize(new Dimension(110,20));
        jcbIsreturn.setBackground(Color.white);
        jtfLender = new JTextField(10);
        jtfLender.setText(Share.operator);
        jtfLender.setEnabled(false);
        jtfprocess = new JTextField(10);
        jtalenRemark= new JTextArea(5,10);
        jScrollPane1 = new JScrollPane(jtalenRemark);


        addComponent(lblAssetId,0,0,1,1);
        addComponent(jtfAssetId,0,1,1,1);
        addComponent(lblAssetName,0,2,1,1);
        addComponent(jtfAssetName,0,3,1,1);
        addComponent(lblModel,1,0,1,1);
        addComponent(jtfModel,1,1,1,1);
        addComponent(lblPrice,1,2,1,1);
        addComponent(jtfPrice,1,3,1,1);
        addComponent(lblEmpno,2,0,1,1);
        addComponent(jtfEmpno,2,1,1,1);
        addComponent(lblUsedate,2,2,1,1);
        addComponent(jtfUsedate,2,3,1,1);
        addComponent(lblRetdate,3,0,1,1);
        addComponent(jtfRetdate,3,1,1,1);
        addComponent(lblIsreturn,3,2,1,1);
        addComponent(jcbIsreturn,3,3,1,1);
        addComponent(lblLender,4,0,1,1);
        addComponent(jtfLender,4,1,1,1);
        addComponent(lbllenProess,4,2,1,1);
        addComponent( jtfprocess,4,3,1,1);

        addComponent(lblRemarks,5,0,1,1);
        addComponent(jScrollPane1,5,1,1,1);
        addComponent(lbldate,5,2,1,1);
        addComponent(jtfdate,5,3,1,1);
        setVisible(true);
   }
   private void addComponent(Component comp,
        int row,int column,int width,int height) {
                cons.gridx = column;
                cons.gridy = row;
                cons.gridwidth = width;
                cons.gridheight = height;
                layout.setConstraints(comp,cons);
                cont.add(comp);
   }






}
class LenLendView extends LendView {
        public LenLendView(ButPanel p) {
                super(p);
                 p1.jtfAssetName.setEnabled(false);
                p1.jtfModel.setEnabled(false);
               p1.jtfPrice.setEnabled(false);
               p1.jtfRetdate.setEnabled(false);

                setTitle("资产出库");
        }
}
class RetLendView extends LendView {
        public RetLendView(ButPanel p) {
                super(p);
                p1.jtfAssetName.setEnabled(false);
             p1.jtfModel.setEnabled(false);
            p1.jtfPrice.setEnabled(false);
            p1.jtfRetdate.setEnabled(false);
                setTitle("资产入库");
        }
}

⌨️ 快捷键说明

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