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

📄 modstore.java

📁 个人消费助理 早期的在学校的实训作品 使用ACCESS 数据库
💻 JAVA
字号:
package shophelper.factory;

import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
import java.sql.*;
import shophelper.database.*;

public class ModStore extends JInternalFrame {
	
	private JButton butCancel,butOk;
    private JLabel jLabel1,jLabel2,jLabel3,jLabel4;
    private JComboBox jnum;
	private JTextField jtf2,jtf3;
    public ModStore() 
	{
		super("修改店铺信息");
        initComponents();
        
        this.setVisible(true);
        this.setClosable(true);
        this.setSize(260,265);        
   }
    private void initComponents() {
    	
    	//实例化并添加控件
        jLabel1 = new JLabel();
		jLabel2 = new JLabel();
		jLabel3 = new JLabel();
		jLabel4 = new JLabel();
   
        jnum = new JComboBox(); 
		jtf2=new JTextField();
		jtf3=new JTextField();
        butOk = new JButton();
        butCancel = new JButton();       
        //实例化并添加控件完成

        getContentPane().setLayout(null);//设置布局
        
        
        //为空间放置具体位置
		jLabel1.setText("店铺名 ");
        getContentPane().add(jLabel1);
        jLabel1.setBounds(35, 30, 70, 20);

        jLabel2.setText("联系方法");
        getContentPane().add(jLabel2);
        jLabel2.setBounds(35, 60, 70, 20);
		
		jLabel3.setText("地址");
        getContentPane().add(jLabel3);
        jLabel3.setBounds(35, 90, 180, 20); 

		getContentPane().add(jLabel4);
        jLabel4.setBounds(55, 90, 180, 20);
                
        getContentPane().add(jnum);
        jnum.setBounds(100, 30, 130, 24);

        getContentPane().add(jtf2);
        jtf2.setBounds(100, 60, 130, 24);

		getContentPane().add(jtf3);
        jtf3.setBounds(100, 90, 130, 24);

        
        butOk.setText("添加");

        getContentPane().add(butOk);
        butOk.setBounds(80, 120, 70, 27);

        butCancel.setText("取消");
        getContentPane().add(butCancel);
        butCancel.setBounds(160, 120, 70, 27);

//将所有用户读出来
		
		try{
			ResultSet rs = AccessSql.showStore();
         	while(rs.next()){
				String s1 = rs.getString(1);
				String s2 = rs.getString(2);

         		jnum.addItem(new Us(s1,s2));
         	}
			rs.close();
         }
       	catch(Exception ea)
		{
			System.out.println("DeleUser Exception:"+ea);
		}
					
      
//为添加和取消按钮加事件-----------------------------------------
     
        butOk.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				String id=((Us)jnum.getSelectedItem()).s1;
				String call=jtf2.getText();
				String address=jtf3.getText();
				AccessSql.modStore(id,call,address);
				jLabel4.setText("修改成功");
					
        	}
        });	
        	

        butCancel.addActionListener(new ActionListener(){
        	public void actionPerformed(ActionEvent e){	
			dispose();
        		}
        	});

    }
	class Us
	{
		String s1,s2;
		Us(String a,String b)
		{
			s1=a;
			s2=b;
		}
		public String toString()
		{
			return s2;
		}
	};
}

⌨️ 快捷键说明

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