JF_query_view.java
上传用户:whbcdz
上传日期:2008-08-04
资源大小:7683k
文件大小:7k
源码类别:

JavaScript

开发平台:

Java

  1. package appjxc.view;
  2. import java.awt.*;
  3. import javax.swing.*;
  4. import java.awt.BorderLayout;
  5. import java.awt.Font;
  6. import java.awt.Dimension;
  7. import javax.swing.border.Border;
  8. import java.util.Calendar;
  9. import java.util.Locale;
  10. import javax.swing.event.ChangeEvent;
  11. import javax.swing.event.ChangeListener;
  12. public class JF_query_view extends JFrame {
  13.     BorderLayout borderLayout1 = new BorderLayout();
  14.     JPanel jPanel1 = new JPanel();
  15.     GridLayout gridLayout1 = new GridLayout();
  16.     JPanel jPanel2 = new JPanel();
  17.     JPanel jPanel3 = new JPanel();
  18.     FlowLayout flowLayout1 = new FlowLayout();
  19.     JCheckBox jCheckBox1 = new JCheckBox();
  20.     JLabel jLabel1 = new JLabel();
  21.     JComboBox jCid = new JComboBox();
  22.     JComboBox jCysf = new JComboBox();
  23.     JTextField jTvalue = new JTextField();
  24.     JCheckBox jCheckBox2 = new JCheckBox();
  25.     JLabel jLabel2 = new JLabel();
  26.     JLabel jLabel3 = new JLabel();
  27.     JLabel jLabel4 = new JLabel();
  28.     JLabel jLabel6 = new JLabel();
  29.     FlowLayout flowLayout2 = new FlowLayout();
  30.     Border border1 = BorderFactory.createLineBorder(UIManager.getColor(
  31.             "ToolBar.dockingForeground"), 2);
  32.     Border border2 = BorderFactory.createLineBorder(Color.magenta, 1);
  33.     JButton jByes = new JButton();
  34.     JScrollPane jScrollPane1 = new JScrollPane();
  35.     JTable jTable1 = new JTable();
  36.     JFormattedTextField jFormattedTextField1 = new JFormattedTextField();
  37.     JFormattedTextField jFormattedTextField2 = new JFormattedTextField();
  38.     public JF_query_view() {
  39.         try {
  40.             jbInit();
  41.         } catch (Exception exception) {
  42.             exception.printStackTrace();
  43.         }
  44.     }
  45.     public void setjSpinner(){
  46.     }
  47.     private void jbInit() throws Exception {
  48.         jFormattedTextField1.setEnabled(false);
  49.         jFormattedTextField2.setEnabled(false);
  50.         border1 = BorderFactory.createLineBorder(Color.red, 1);
  51.         jCheckBox1.setSelected(true);
  52.         jCheckBox2.setSelected(false);
  53.         jCysf.addItem("like");
  54.         jCysf.addItem(">");
  55.         jCysf.addItem("<");
  56.         jCysf.addItem(">=");
  57.         jCysf.addItem("<=");
  58.         jCid.addItem("入库单据号");
  59.         jCid.addItem("入库数量");
  60.         jCid.addItem("入库金额");
  61.         getContentPane().setLayout(borderLayout1);
  62.         jCheckBox2.setFont(new java.awt.Font("新宋体", Font.PLAIN, 12));
  63.         jCheckBox2.setText("日期查询");
  64.         jCheckBox2.addChangeListener(new JF_query_view_jCheckBox2_changeAdapter(this));
  65.         jLabel2.setFont(new java.awt.Font("新宋体", Font.PLAIN, 12));
  66.         jLabel2.setText("起始日期:");
  67.         jLabel3.setFont(new java.awt.Font("新宋体", Font.PLAIN, 12));
  68.         jLabel3.setText("终止日期:");
  69.         jLabel4.setFont(new java.awt.Font("新宋体", Font.PLAIN, 12));
  70.         jLabel4.setText("运算符:");
  71.         jLabel6.setFont(new java.awt.Font("新宋体", Font.PLAIN, 12));
  72.         jLabel6.setText("数值:");
  73.         flowLayout1.setHgap(8);
  74.         jPanel3.setLayout(flowLayout2);
  75.         flowLayout2.setHgap(8);
  76.         jCheckBox1.setFont(new java.awt.Font("新宋体", Font.PLAIN, 12));
  77.         jLabel1.setFont(new java.awt.Font("新宋体", Font.PLAIN, 12));
  78.         jCid.setFont(new java.awt.Font("新宋体", Font.PLAIN, 12));
  79.         jCid.setPreferredSize(new Dimension(97, 23));
  80.         jPanel2.setBorder(border1);
  81.         jPanel3.setBorder(border2);
  82.         jTvalue.setPreferredSize(new Dimension(156, 24));
  83.         jCysf.setPreferredSize(new Dimension(53, 23));
  84.         jByes.setFont(new java.awt.Font("新宋体", Font.PLAIN, 12));
  85.         jByes.setText("查询");
  86.         jFormattedTextField1.setPreferredSize(new Dimension(139, 24));
  87.         jFormattedTextField2.setPreferredSize(new Dimension(139, 24));
  88.         this.getContentPane().add(jPanel1, java.awt.BorderLayout.NORTH);
  89.         jPanel2.setLayout(flowLayout1);
  90.         jCheckBox1.setText("查询条件");
  91.         jLabel1.setText("选择字段:");
  92.         jPanel1.add(jPanel2);
  93.         jPanel2.add(jCheckBox1);
  94.         jPanel2.add(jLabel1);
  95.         jPanel2.add(jCid);
  96.         jPanel2.add(jLabel4);
  97.         jPanel2.add(jCysf);
  98.         jPanel2.add(jLabel6);
  99.         jPanel2.add(jTvalue);
  100.         jPanel1.add(jPanel3);
  101.         jPanel3.add(jCheckBox2);
  102.         jPanel3.add(jLabel2);
  103.         jPanel3.add(jFormattedTextField1);
  104.         jPanel3.add(jLabel3);
  105.         jPanel3.add(jFormattedTextField2);
  106.         jPanel3.add(jByes);
  107.         this.getContentPane().add(jScrollPane1, java.awt.BorderLayout.CENTER);
  108.         jScrollPane1.getViewport().add(jTable1);
  109.         gridLayout1.setColumns(1);
  110.         gridLayout1.setRows(2);
  111.         jPanel1.setLayout(gridLayout1);
  112.         this.setSize(750,550);
  113.         this.setVisible(true);
  114.     }
  115.     public static void main(String[] args) {
  116.         JF_query_view jf_query_view = new JF_query_view();
  117.     }
  118.     public void jCheckBox2_stateChanged(ChangeEvent e) {
  119.         if(jCheckBox2.isSelected()){
  120.             jFormattedTextField1.setEnabled(true);
  121.             jFormattedTextField2.setEnabled(true);
  122.             long nCurrentTime = System.currentTimeMillis();
  123.             java.util.Calendar calendar = java.util.Calendar.getInstance(new
  124.                     Locale("CN"));
  125.             calendar.setTimeInMillis(nCurrentTime);
  126.             int year = calendar.get(Calendar.YEAR);
  127.             int month = calendar.get(Calendar.MONTH) + 1;
  128.             int day = calendar.get(Calendar.DAY_OF_MONTH);
  129.             String mm, dd;
  130.             if (month < 10) {
  131.                 mm = "0" + String.valueOf(month);
  132.             } else {
  133.                 mm = String.valueOf(month);
  134.             }
  135.             if (day < 10) {
  136.                 dd = "0" + String.valueOf(day);
  137.             } else {
  138.                 dd = String.valueOf(day);
  139.             }
  140.             System.out.println(year + "-" + mm + "-" + dd);
  141.             java.sql.Date date = java.sql.Date.valueOf(year + "-" + mm + "-" +
  142.                     dd);
  143.             jFormattedTextField1.setText(String.valueOf(date));
  144.             jFormattedTextField2.setText(String.valueOf(date));
  145.         }else{
  146.             jFormattedTextField1.setEnabled(false);
  147.             jFormattedTextField2.setEnabled(false);
  148.             jFormattedTextField1.setText(String.valueOf(""));
  149.              jFormattedTextField2.setText(String.valueOf(""));
  150.         }
  151.     }
  152. }
  153. class JF_query_view_jCheckBox2_changeAdapter implements ChangeListener {
  154.     private JF_query_view adaptee;
  155.     JF_query_view_jCheckBox2_changeAdapter(JF_query_view adaptee) {
  156.         this.adaptee = adaptee;
  157.     }
  158.     public void stateChanged(ChangeEvent e) {
  159.         adaptee.jCheckBox2_stateChanged(e);
  160.     }
  161. }