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

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

在控制臺中顯示多個詳細信息,但不在文本區域中顯示。

在控制臺中顯示多個詳細信息,但不在文本區域中顯示。

萬千封印 2023-10-18 20:53:05
類搜索擴展了 JFrame{private Container container;private Font font,font2;private JLabel label;private JTextField textField;private JButton search;private JTextArea textarea;search(){    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);    this.setBounds(100,40,600,380);    this.setTitle("SEARCH");    container = this.getContentPane();    container.setLayout(null);    font = new Font("Courier New",Font.BOLD,14);    font2 = new Font("Courier New",Font.BOLD,18);    label = new JLabel("SEARCH : ");    label.setBounds(40,20,150,50);    label.setFont(font);    container.add(label);    textField = new JTextField();    textField.setBounds(140,25,200,40);    textField.setFont(font2);    container.add(textField);    search = new JButton("SEARCH");    search.setBounds(370,25,110,37);    search.setFont(font);    container.add(search);    textarea = new JTextArea();    textarea.setBounds(40,85,500,200);    textarea.setFont(font2);    container.add(textarea);    search.addActionListener(new ActionListener() {        public void actionPerformed(ActionEvent event) {            String x = textField.getText();            try{                File file = new File("allinfo.txt");                BufferedReader reader = new BufferedReader(new FileReader(file));                String s = reader.readLine();                while(s!=null){                    String string[] = s.split(" ");                    String a = string[0];                    String b = string[1];                    String c = string[2];                    String d = string[3];這是一個搜索選項,我可以在其中搜索一個人的名字。如果有兩個人同名,則兩個選項都應顯示在文本區域中,但文本區域僅顯示一個人的詳細信息。但控制臺正在打印所有個人詳細信息。我需要有關如何在文本區域中顯示所有詳細信息的幫助。
查看完整描述

1 回答

?
喵喵時光機

TA貢獻1846條經驗 獲得超7個贊

代替

textarea.setText(f);

使用

textarea.append(f + "\n");


查看完整回答
反對 回復 2023-10-18
  • 1 回答
  • 0 關注
  • 116 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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