Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /////////////////
- // Main class //
- /////////////////
- package views;
- // imports...
- public class Main extends JFrame {
- // Main class with all variables and methods...
- //..........
- //..........
- public Main() {
- initComponents();
- createEvents(); // A method from the other class is called here like this: Helpers.checkDataLine(line.trim());
- // Error: Cannot make a static reference to the non-static method checkDataLine(String) from the type Helpers
- }
- // Getters n Setters
- public JTextArea getTextAreaOuput() {
- return textAreaOuput;
- }
- public void setTextAreaOuput(JTextArea textAreaOuput) {
- this.textAreaOuput = textAreaOuput;
- }
- }
- //////////////////
- // Helper class //
- //////////////////
- package views;
- // imports...
- public class Helpers {
- public void checkDataLine(String line) {
- try { // it is a URL
- URL url = new URL(line);
- } catch (MalformedURLException e) { // it's not a URL
- // ERROR: Cannot make a static reference to the non-static method getTextAreaOuput() from the type Main
- Main.getTextAreaOuput().append("~~ [" + line + "] ~~ is NO URL ~~\n");
- searchText(line);
- }
- }
- public void searchText(String line) {
- Document doc;
- StringBuilder rootUrl = new StringBuilder("http://blah/");
- try {
- // Download the page
- doc = Jsoup.connect(rootUrl.append(line).toString()).get();
- Elements results = doc.select("a.match");
- for (Element element : results) {
- // ERROR: Cannot make a static reference to the non-static method getTextAreaOuput() from the type Main
- Main.getTextAreaOuput().append(element.text() + "\n");
- }
- } catch (IOException e) {
- // TODO: handle exception
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement