第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

點(diǎn)擊jList中的某一項(xiàng),卻不能顯示出該項(xiàng)對(duì)應(yīng)的詳細(xì)信息(JTextArea)的疑問(wèn)

點(diǎn)擊jList中的某一項(xiàng),卻不能顯示出該項(xiàng)對(duì)應(yīng)的詳細(xì)信息(JTextArea)的疑問(wèn)

Tesjunma 2017-01-05 20:16:18
public?abstract?class?Mainform?extends?JFrame{ ?protected?JPanel?pnlContent?=?null; ?protected?JPanel?pnlInformation?=?null; ?protected?JPanel?pnlButton?=?null; ?protected?JPanel?pnlTime?=?null; ? ?protected?JList<String>?jList?=?null; ?protected?DefaultListModel<String>?model?=?null; ?protected?ProductController?productController?=?null; ? ?protected?Cart?cart?=?null; ?protected?JButton?btnAdd?=?null;? ?protected?JTextArea?txtInform?=?null; ?protected?JScrollPane?scrollpnl?=?null; ? ?public?Mainform(){ ?? ??this.setSize(new?Dimension(800,600)); ??this.setBackground(Color.LIGHT_GRAY); ??this.setLocationRelativeTo(null); ??this.setTitle("Gourmet?Coffee?System"); ??this.setDefaultCloseOperation(DISPOSE_ON_CLOSE); ?? ??pnlContent?=?new?JPanel();? ??pnlTime?=?new?TimePanel();? ??pnlInformation?=?new?JPanel(); ??pnlInformation.setBackground(Color.GRAY);? ??pnlButton?=?new?JPanel(); ??pnlButton.setBackground(Color.white);? ??txtInform?=?new?JTextArea(500,600); ?? ?? ??setList(); ??this.add(pnlTime,?BorderLayout.NORTH); ??this.add(pnlContent,BorderLayout.WEST); ??this.add(pnlButton,BorderLayout.SOUTH); ?? ??addButton(pnlButton); ?? ?? ??showFrame(); ?} ? ?private?void?showFrame()?{ ??this.setVisible(true); ?} ? ?public?void?setList(){ ?? ??model?=?new?DefaultListModel<String>(); ??productController?=?new?ProductController("information","Product.txt"); ??for(Product?product:?productController.readObject("information",?"Product.txt")){ ???model.addElement(product.getCode()); ??} ??jList?=?new?JList(model); ??jList.setPreferredSize(new?Dimension(200,600)); ??pnlContent.add(jList); ??setText(); ?} ? ? ?public?void?setText(){ ??txtInform.setLineWrap(true); ??txtInform.setEditable(false); ??txtInform.setBackground(Color.blue); ??jList.addListSelectionListener(new?ListSelectionListener(){ ???@Override ???public?void?valueChanged(ListSelectionEvent?e)?{ ????if(!jList.getValueIsAdjusting()){ ????/* ?????*監(jiān)聽(tīng)過(guò)程中如果匹配,增加text內(nèi)容? ?????*/ ????String?code?=?jList.getSelectedValue(); ????ProductController?productcontroller?=?new?ProductController("information",?"Product.txt"); ????ArrayList<Product>?products?=? ??????productcontroller.readObject("information",?"Product.txt"); ?????for(Product?product:products){ ??????if(code?==?product.getCode()){ ???????txtInform.setText(product.toString());??? ??????} ?????} ????} ???} ??}); ??pnlInformation.add(txtInform); ??this.add(pnlInformation,BorderLayout.CENTER); ?} ? ? ? ?abstract?void?addButton(JPanel?pnlButton);參數(shù):jList列出目錄jTextArea我希望JList在鼠標(biāo)點(diǎn)擊的時(shí)候能顯示商品的詳細(xì)信息,詳細(xì)信息用JTextArea等表示。為此設(shè)置了一個(gè)事件ListSelectionListener在內(nèi)部類里面讀取商品文件的信息(讀取文件的函數(shù)返回ArrayList)查看是否有匹配(通過(guò)比較商品的屬性---Code是否一致的方式)我認(rèn)為我的邏輯上應(yīng)該是沒(méi)有問(wèn)題的。在? txtInform.setText(product.toString());這句設(shè)了斷點(diǎn)以后似乎發(fā)現(xiàn)有線程的沖突,還有空指針異?!坎锁B(niǎo)一個(gè),不懂怎么解決此類問(wèn)題…跪求大佬幫忙。這是設(shè)了斷點(diǎn)以后發(fā)現(xiàn)的問(wèn)題:剛剛step into?一步以后就顯示了這個(gè)…感謝?。。。?
查看完整描述

目前暫無(wú)任何回答

  • 0 回答
  • 1 關(guān)注
  • 1573 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)