0

I am struggling to find a way to print a Specific row from JTable by searching using a text field to write id and print that row in a lapel and add it into the frame after clicking the get student button

 JLabel resultSearchLable = new JLabel();
    
    resultSearchLable.setSize(100,200);
    
    resultSearchLable.setBounds(500,300,300,50);
    
    getStudentButton.addActionListener(new ActionListener() {


        public void actionPerformed(ActionEvent e) {
        if(!(Objects.equals(searchFiled.getText(), "")) )
        {
          int i = 0;
          while (i < tableCSF.getRowCount()){
              if (searchFiled.getText() == tableCSF.getValueAt(i,0)) {
                  resultSearchLable.setText((String) tableCSF.getValueAt(i,0));
                  frame.add(resultSearchLable);
              } i++;
          }
            }
        }

});

the o

GBR
  • 1
  • 1
  • Perhaps use **TableRowSorter.setRowFilter()** and display the search results directly within the JTable itself. – DevilsHnd Dec 07 '21 at 21:15

0 Answers0