JF_query_view.java
资源名称:Appjxc.rar [点击查看]
上传用户:whbcdz
上传日期:2008-08-04
资源大小:7683k
文件大小:7k
源码类别:
JavaScript
开发平台:
Java
- package appjxc.view;
- import java.awt.*;
- import javax.swing.*;
- import java.awt.BorderLayout;
- import java.awt.Font;
- import java.awt.Dimension;
- import javax.swing.border.Border;
- import java.util.Calendar;
- import java.util.Locale;
- import javax.swing.event.ChangeEvent;
- import javax.swing.event.ChangeListener;
- public class JF_query_view extends JFrame {
- BorderLayout borderLayout1 = new BorderLayout();
- JPanel jPanel1 = new JPanel();
- GridLayout gridLayout1 = new GridLayout();
- JPanel jPanel2 = new JPanel();
- JPanel jPanel3 = new JPanel();
- FlowLayout flowLayout1 = new FlowLayout();
- JCheckBox jCheckBox1 = new JCheckBox();
- JLabel jLabel1 = new JLabel();
- JComboBox jCid = new JComboBox();
- JComboBox jCysf = new JComboBox();
- JTextField jTvalue = new JTextField();
- JCheckBox jCheckBox2 = new JCheckBox();
- JLabel jLabel2 = new JLabel();
- JLabel jLabel3 = new JLabel();
- JLabel jLabel4 = new JLabel();
- JLabel jLabel6 = new JLabel();
- FlowLayout flowLayout2 = new FlowLayout();
- Border border1 = BorderFactory.createLineBorder(UIManager.getColor(
- "ToolBar.dockingForeground"), 2);
- Border border2 = BorderFactory.createLineBorder(Color.magenta, 1);
- JButton jByes = new JButton();
- JScrollPane jScrollPane1 = new JScrollPane();
- JTable jTable1 = new JTable();
- JFormattedTextField jFormattedTextField1 = new JFormattedTextField();
- JFormattedTextField jFormattedTextField2 = new JFormattedTextField();
- public JF_query_view() {
- try {
- jbInit();
- } catch (Exception exception) {
- exception.printStackTrace();
- }
- }
- public void setjSpinner(){
- }
- private void jbInit() throws Exception {
- jFormattedTextField1.setEnabled(false);
- jFormattedTextField2.setEnabled(false);
- border1 = BorderFactory.createLineBorder(Color.red, 1);
- jCheckBox1.setSelected(true);
- jCheckBox2.setSelected(false);
- jCysf.addItem("like");
- jCysf.addItem(">");
- jCysf.addItem("<");
- jCysf.addItem(">=");
- jCysf.addItem("<=");
- jCid.addItem("入库单据号");
- jCid.addItem("入库数量");
- jCid.addItem("入库金额");
- getContentPane().setLayout(borderLayout1);
- jCheckBox2.setFont(new java.awt.Font("新宋体", Font.PLAIN, 12));
- jCheckBox2.setText("日期查询");
- jCheckBox2.addChangeListener(new JF_query_view_jCheckBox2_changeAdapter(this));
- jLabel2.setFont(new java.awt.Font("新宋体", Font.PLAIN, 12));
- jLabel2.setText("起始日期:");
- jLabel3.setFont(new java.awt.Font("新宋体", Font.PLAIN, 12));
- jLabel3.setText("终止日期:");
- jLabel4.setFont(new java.awt.Font("新宋体", Font.PLAIN, 12));
- jLabel4.setText("运算符:");
- jLabel6.setFont(new java.awt.Font("新宋体", Font.PLAIN, 12));
- jLabel6.setText("数值:");
- flowLayout1.setHgap(8);
- jPanel3.setLayout(flowLayout2);
- flowLayout2.setHgap(8);
- jCheckBox1.setFont(new java.awt.Font("新宋体", Font.PLAIN, 12));
- jLabel1.setFont(new java.awt.Font("新宋体", Font.PLAIN, 12));
- jCid.setFont(new java.awt.Font("新宋体", Font.PLAIN, 12));
- jCid.setPreferredSize(new Dimension(97, 23));
- jPanel2.setBorder(border1);
- jPanel3.setBorder(border2);
- jTvalue.setPreferredSize(new Dimension(156, 24));
- jCysf.setPreferredSize(new Dimension(53, 23));
- jByes.setFont(new java.awt.Font("新宋体", Font.PLAIN, 12));
- jByes.setText("查询");
- jFormattedTextField1.setPreferredSize(new Dimension(139, 24));
- jFormattedTextField2.setPreferredSize(new Dimension(139, 24));
- this.getContentPane().add(jPanel1, java.awt.BorderLayout.NORTH);
- jPanel2.setLayout(flowLayout1);
- jCheckBox1.setText("查询条件");
- jLabel1.setText("选择字段:");
- jPanel1.add(jPanel2);
- jPanel2.add(jCheckBox1);
- jPanel2.add(jLabel1);
- jPanel2.add(jCid);
- jPanel2.add(jLabel4);
- jPanel2.add(jCysf);
- jPanel2.add(jLabel6);
- jPanel2.add(jTvalue);
- jPanel1.add(jPanel3);
- jPanel3.add(jCheckBox2);
- jPanel3.add(jLabel2);
- jPanel3.add(jFormattedTextField1);
- jPanel3.add(jLabel3);
- jPanel3.add(jFormattedTextField2);
- jPanel3.add(jByes);
- this.getContentPane().add(jScrollPane1, java.awt.BorderLayout.CENTER);
- jScrollPane1.getViewport().add(jTable1);
- gridLayout1.setColumns(1);
- gridLayout1.setRows(2);
- jPanel1.setLayout(gridLayout1);
- this.setSize(750,550);
- this.setVisible(true);
- }
- public static void main(String[] args) {
- JF_query_view jf_query_view = new JF_query_view();
- }
- public void jCheckBox2_stateChanged(ChangeEvent e) {
- if(jCheckBox2.isSelected()){
- jFormattedTextField1.setEnabled(true);
- jFormattedTextField2.setEnabled(true);
- long nCurrentTime = System.currentTimeMillis();
- java.util.Calendar calendar = java.util.Calendar.getInstance(new
- Locale("CN"));
- calendar.setTimeInMillis(nCurrentTime);
- int year = calendar.get(Calendar.YEAR);
- int month = calendar.get(Calendar.MONTH) + 1;
- int day = calendar.get(Calendar.DAY_OF_MONTH);
- String mm, dd;
- if (month < 10) {
- mm = "0" + String.valueOf(month);
- } else {
- mm = String.valueOf(month);
- }
- if (day < 10) {
- dd = "0" + String.valueOf(day);
- } else {
- dd = String.valueOf(day);
- }
- System.out.println(year + "-" + mm + "-" + dd);
- java.sql.Date date = java.sql.Date.valueOf(year + "-" + mm + "-" +
- dd);
- jFormattedTextField1.setText(String.valueOf(date));
- jFormattedTextField2.setText(String.valueOf(date));
- }else{
- jFormattedTextField1.setEnabled(false);
- jFormattedTextField2.setEnabled(false);
- jFormattedTextField1.setText(String.valueOf(""));
- jFormattedTextField2.setText(String.valueOf(""));
- }
- }
- }
- class JF_query_view_jCheckBox2_changeAdapter implements ChangeListener {
- private JF_query_view adaptee;
- JF_query_view_jCheckBox2_changeAdapter(JF_query_view adaptee) {
- this.adaptee = adaptee;
- }
- public void stateChanged(ChangeEvent e) {
- adaptee.jCheckBox2_stateChanged(e);
- }
- }