首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

如何使我的JButton计数并更改显示?

相关·内容

图书管理系统 出现的问题

JButton button_ok = new JButton("确定",new ImageIcon("ok.png")); southPanel.add(button_ok); button_ok.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { File f1 =SearchFrame.this.getClassName(); File[] f = f1.listFiles(); try { FileInputStream fr = new FileInputStream(f[0]); ObjectInputStream obo = new ObjectInputStream(fr); boolean exist = false;//用来判断有没有查到 do{ book_search =(Book)obo.readObject(); System.out.println(book_search); if(book_search.toString().contains(textField.getText())) { exist =true; Object[][] book=new Object[1][]; book[0][0]=book_search.getNumber(); book[0][1]=book_search.getName(); book[0][2]=book_search.getAuthor(); book[0][3]=book_search.getPress(); book[0][4]=book_search.getCount(); String [] book_info = {"编号","书名 ","作者","出版社","数量"}; table_search = new JTable(book,book_info); new SearchResult(); } }while(book_search==null); //当没有检索到书的时候显示结果 if(!exist){ JLabel label_result = new JLabel("没有检索到该书!!"); JOptionPane.showConfirmDialog(SearchFrame.this, label_result,"图书管理系统检索结果", JOptionPane.PLAIN_MESSAGE,JOptionPane.OK_OPTION , new ImageIcon("result.png")); } obo.close(); }catch(InvalidClassException e3) { e3.printStackTrace(); } catch (ClassNotFoundException e1) { e1.printStackTrace(); }catch(StreamCorruptedException e4){ e4.printStackTrace(); }catch(OptionalDataException e5) { e5.printStackTrace(); }catch(FileNotFoundException e6) { } catch (IOException e2) { e2.printStackTrace(); } } });

04
领券