#setText in textpane not working

3 messages · Page 1 of 1 (latest)

frank plover
#

I have tried so many different approaches and for some reason it just will not set the text in the textpane below is my current code


        for (Component c : profilerscriptpanel.getComponents()) {
            if (c instanceof JCheckBox) {
                JCheckBox checkbox = (JCheckBox) c;
                if (checkbox.isSelected()) {
                    String text = checkbox.getText();
                    File file = new File("Main/Scripts/" + text + ".txt");
                    try {
                        List<String> lines = Files.readAllLines(file.toPath());
                        StringBuilder sb = new StringBuilder();
                        for(String line: lines) {
                            sb.append(line);
                            sb.append(System.lineSeparator());
                        }
                        scriptparametertextbox.setText(sb.toString());
                        scriptparametertextbox.revalidate();
                        scriptparametertextbox.repaint();
                        scriptparametersavenametextbox.setText(text);
                        scriptparametersavenametextbox.revalidate();
                        scriptparametersavenametextbox.repaint();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }
        }
    }```

Any help is greatly appreciated
mossy juncoBOT
#

This post has been reserved for your question.

Hey @frank plover! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.