freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

基于java的在線考試系統(tǒng)(編輯修改稿)

2025-07-22 13:40 本頁面
 

【文章內(nèi)容簡介】 eredReader(new InputStreamReader( getClass().getReaource().openStream())) loginFrame的實現(xiàn)創(chuàng)建內(nèi)容面板,在內(nèi)容面板里面創(chuàng)建中間面板和Button面板,中間面板主要是顯示用戶名和密碼框,是用來得到用戶輸入的。按鈕面板上嵌入2個按鈕,分別是login按鈕,cancel按鈕。1)創(chuàng)建內(nèi)容面板,在內(nèi)容面板里面有中間面板和按鈕面板,并用邊框布局將面板放在特定的位置,邊框布局的北邊設置一個標簽,用來顯示用戶界面的標題,中間面板放在邊框布局的中間,按鈕面板放在邊框布局的南邊。 private JPanel createContentPane(){ JPanel p=new JPanel(new BorderLayout())。 (new EmptyBorder(8,8,8,8))。//4個方向空白邊框 (,(new JLabel(登錄系統(tǒng),)))。 (,createCenterPane())。 (,createBtnPane())。 return p。 }2)實現(xiàn)在內(nèi)容面板中定義的中間面板,先設置一個空白邊框,并在邊框布局的北邊創(chuàng)建Id和Pwd面板,將登錄得錯誤信息顯示在邊框布局的中間,最后將設置好的面板返回,用于用戶操作。 private JPanel createCenterPane(){ JPanel p=new JPanel(new BorderLayout())。 (new EmptyBorder(8,0,0,0))。 (,createIdPwdPane())。 message=new JLabel(,)。 (,message)。 return p。 }3)實現(xiàn)在內(nèi)容面板中定義的按鈕面板,創(chuàng)建2個按鈕,分別是Login和Cancel,login按鈕是為了得到用戶的登錄請求, cancel按鈕是為了得到用戶的取消請求,將按鈕添加到面板中。 private JPanel createBtnPane(){ JPanel p=new JPanel(new FlowLayout())。 JButton login=new JButton(Login)。 JButton cancel=new JButton(Cancel)。 getRootPane().setDefaultButton(login)。 (login)。 (cancel)。 =idField。 (,idField)。 return p。 } 4)為登錄界面增加方法,用來獲取用戶的ID(getUserId())和PWD(getPwd()),用來判斷是否在設備文件中。 private JTextField idField。 private JPasswordField pwdField。 private JLabel message。 public int getUserId(){ return (())。 } public String getPassword(){ char[] pwd=()。 return new String(pwd)。 } public void showMessage(String message){ (message)。 }5)若用戶名或密碼錯誤,設置錯誤提示消息,拋出自定義異常 IdOrPwdException,自定義異常的聲明必須繼承自它的父類Exception才能實現(xiàn),原本的id:1002和pwd:1234,在這里輸錯密碼,用于執(zhí)行密碼異常,最后將這個錯誤信息在邊框布局的中間顯示。(測試的Id:1002;pwd:3456)6)為loginFrame增加對控制器對象的引用, LoginFrame 界面增加 (ClientContext) 的引用和對象注入代碼 。一定要這樣做,不然會產(chǎn)生空指針異常。 private ClientContext clientContext。 public void setClientContext(ClientContext clientContext){ =clientContext。 } loginFrame窗體 menuFrame的實現(xiàn) 創(chuàng)建內(nèi)容面板,在內(nèi)容面板實現(xiàn)菜單面板,在菜單面板更新考試信息和創(chuàng)建按鈕面板,在按鈕面板創(chuàng)建4個按鈕,分別為開始按鈕,分數(shù)按鈕,消息按鈕,退出按鈕。1)內(nèi)容面板,內(nèi)容面板里面有2個標簽和一個菜單面板,其中,一個標簽用來顯示圖片,另外一個標簽用來顯示版權信息,菜單面板的具體設置在另外一個面板實現(xiàn),這里就實現(xiàn)了簡單工廠的方法。不在這個面板具體實現(xiàn),而是在別的面板聲明,這個簡單工廠的方法在別的窗體里面同樣可以實現(xiàn)。另外,在菜單面板中創(chuàng)建一個標簽,用來顯示用戶信息,因為當用戶登錄用戶登錄成功后,就會返回一個登錄用戶,將這個登錄用戶在界面上顯示,用來表達友好的效果。其次,在菜單面板中在創(chuàng)建一個按鈕面板,最后將創(chuàng)建好的按鈕和標簽返回給菜單面板。 private JPanel createContentPane(){ JPanel p=new JPanel(new BorderLayout())。 ImageIcon icon=new ImageIcon(().getResource())。 (,new JLabel(icon))。 (,createMenuPane())。 (,new JLabel(版權所有,違版必究!,))。 return p。 } private JPanel createMenuPane(){ JPanel p=new JPanel(new BorderLayout())。 userInfo=new JLabel(,)。 (,userInfo)。 (,createBtnPane())。 return p。 }2)實現(xiàn)在菜單面板中定義的按鈕面板,開始按鈕是用來讓用戶考試的,當用戶點擊開始按鈕的時候,就會跳到考試窗體具體考試;當用戶點分數(shù)按鈕的時候,就會用一個消息框顯示用戶考試的成績,注意,只有當用戶已經(jīng)考完試了才會有具體的分數(shù),這在業(yè)務邏輯里面具體判斷;當用戶點考試規(guī)則按鈕的時候,就會用一個消息框來具體顯示考試規(guī)則;當用戶點退出按鈕的時候,就會顯示一個確定框提示用戶,真的退出嗎?。若用戶點是,則表示退出系統(tǒng),若用戶點否,則表示用戶需要停留在該頁面,則保持頁面不動。private JPanel createBtnPane(){ JPanel p=new JPanel(new FlowLayout())。 JButton start=createImgBtn(,開始)。 JButton result=createImgBtn(,分數(shù))。 JButton msg=createImgBtn(,考試規(guī)則)。 JButton exit=createImgBtn(,退出)。 (start)。 (result)。 (msg)。 (exit)。 getRootPane().setDefaultButton(start)。3)分別為start,result,msg,exit按鈕添加觸發(fā)事件, 當用戶點開始按鈕的時候,就去ClientContext調(diào)用start()方法 當用戶點分數(shù)按鈕的時候,就去ClientContext調(diào)用sresult()方法 當用戶點考試規(guī)則按鈕的時候,就去ClientContext調(diào)用msg()方法 當用戶點退出按鈕的時候,就去ClientContext調(diào)用exit()方法 start .addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent a){ ()。 } })。 (new ActionListener(){ public void actionPerformed(ActionEvent e){ ()。 } })。 (new ActionListener(){ public void actionPerformed(ActionEvent e){ ()。 } })。4)更新用戶界面若登錄成功,就會返回一個用戶對象,務必將userInfo 引用到界面控件對象用戶顯示當前是哪個用戶在考試,顯示歡迎界面,以達到有好的界面效果,更新用戶界面信息,以便于用戶考試。 private JLabel userInfo。 public void updateView(User user){ String str=歡迎+user+參加考試!。 (str)。 } JButton btn=new JButton(txt,icon)。 ()。 ()。5)為menuFrame添加對控制器對象的引用, LoginFrame 界面增加 控制器(ClientContext) 的引用和對象注入代碼 。一定要這樣做,不然會產(chǎn)生空指針異常。 private ClientContext clientContext。 public void setClientCo
點擊復制文檔內(nèi)容
環(huán)評公示相關推薦
文庫吧 www.dybbs8.com
備案圖片鄂ICP備17016276號-1