亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

以下是我的LoginPanel按鈕代碼,關于用戶傳值的問題,請問該怎么辦?

以下是我的LoginPanel按鈕代碼,關于用戶傳值的問題,請問該怎么辦?

元芳怎么了 2022-05-26 11:07:59
//以下是我的LoginPanel按鈕代碼,我想把輸出的user.getCidId() 傳到第二個Swing (MainPanel)的JLabelprivate void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {// TODO add your handling code here:String at = log_a.getText();// int i = Integer.parseInt(at);String bt = new String(log_b.getPassword());boolean b = true;if (at.equals("")) {log_check_a.setText("卡號不能為空");b = false;}if (bt.equals("")) {log_check_b.setText("密碼不能為空");b = false;}Users user = new Users();user.setCidId(at);user.setPassWord(bt);UsersService usersService = new UsersService();Users u = usersService.loging(user);if (at.equals(user.getCidId())) {System.out.println("卡號:" + user.getCidId() + "\n" + "已登錄銀行系統!");MainPanel.main(null);dispose();} else {System.out.println("登錄失敗");JOptionPane.showConfirmDialog(null, "卡號或密碼不正確,如需幫助請撥打熱線");}}private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {// TODO add your handling code here: 卡戶跳轉RegPanel.main(null);dispose();}/*** @param args the command line arguments*/public static void main(String args[]) {java.awt.EventQueue.invokeLater(new Runnable() {public void run() {new LoginPanel().setVisible(true);}});}
查看完整描述

1 回答

?
翻過高山走不出你

TA貢獻1875條經驗 獲得超3個贊

MainPanel改造下:


public class MainPanel{    // 構造函數     public MainPanel(){}     // 初始化后MainPanel     public void initMainPanel(){            // 構建界面,初始化變量等      }    public void setValues(String cidId){        // 根據cidId進行一些設置        .......其他一些自己的方法和變量......      }

LoginPanel的下面一段改造下:


if (at.equals(user.getCidId())) {    System.out.println("卡號:" + user.getCidId() + "\n" "已登錄銀行系統!");    MainPanel mainPanel=new MainPanel(); // 創建界面實例    mainPanel.initMainPanel();           // 初始化界面    mainPanel.setValues(user.getCidId());// 給界面設置值     dispose();    }


查看完整回答
反對 回復 2022-05-30
  • 1 回答
  • 0 關注
  • 206 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號