I have a list that contains String
s and I am trying to set its items as JLabel
text, the only problem is that the result is a single line
JButton btnSearch = new JButton("Search");
btnSearch.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent arg0) {
String fileName = textField.getText();
StringBuilder result = new StringBuilder();
List <String> searchResult = new Search().cautaFisiere("C:\\AdwCleaner", fileName);
for (int x = 0; x < searchResult.size(); x++) {
result.append(searchResult.get(x)).append("\n");
}
lblNewLabel.setText(result.toString());
}
});
As you can see I tried appending items as new line but no result. I also tried append(System.getProperty("line.separator"))
but still no result, the text is still displayed in one line