Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4124048
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T23:41:24+00:00 2026-05-20T23:41:24+00:00

import org.jsoup.Jsoup; @SuppressWarnings({ unused, serial }) public class SimpleWebCrawler extends JFrame implements ActionListener {

  • 0
import org.jsoup.Jsoup;


@SuppressWarnings({ "unused", "serial" })

public class SimpleWebCrawler extends JFrame implements ActionListener {

    JTextField yourInputField = new JTextField(20);
    static JTextArea _resultArea = new JTextArea(200, 200);
    JScrollPane scrollingArea = new JScrollPane(_resultArea);
    private final static String newline = "\n";




    @Override
    yourInputField.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
        // TODO Auto-generated method stub

    }









    public SimpleWebCrawler() throws MalformedURLException  {


        _resultArea.setEditable(false);

        String word2 = yourInputField.getText();

        try {
            URL my_url = new URL("http://" + word2 + "/");
            BufferedReader br = new BufferedReader(new InputStreamReader(
                    my_url.openStream()));
            String strTemp = "";
            while (null != (strTemp = br.readLine())) {
                _resultArea.append(strTemp + newline);
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }

        _resultArea.append("\n");
        _resultArea.append("\n");
        _resultArea.append("\n");


        String url = "http://" + word2 + "/";
        print("Fetching %s...", url);

        try{
        Document doc = Jsoup.connect(url).get();
        Elements links = doc.select("a[href]");


        System.out.println("\n");

        BufferedWriter bw = new BufferedWriter(new FileWriter("C:\\Users\\user\\fypworkspace\\FYP\\Link\\abc.txt"));
        _resultArea.append("\n");
        for (Element link : links) {
            print("  %s  ", link.attr("abs:href"), trim(link.text(), 35));

            bw.write(link.attr("abs:href"));
            bw.write(System.getProperty("line.separator"));
        }
        bw.flush();
        bw.close();
        } catch (IOException e1) {

        }
        JPanel content = new JPanel();

        content.setLayout(new BorderLayout());
        content.add(scrollingArea, BorderLayout.CENTER);
        content.add(yourInputField,BorderLayout.SOUTH);


        this.setContentPane(content);
        this.setTitle("Crawled Links");
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.pack();
        JPanel content2 = new JPanel();
        this.setContentPane(content2);
        this.setTitle("Input the URL");
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.pack();


        }

        private static void print(String msg, Object... args) {

            _resultArea.append(String.format(msg, args) +newline);
        }

        private static String trim(String s, int width) {
            if (s.length() > width)
                return s.substring(0, width - 1) + ".";
            else
                return s;
        }

        //.. Get the content pane, set layout, add to center




    public static void main(String[] args) throws IOException {

        JFrame win = new SimpleWebCrawler();
        win.setVisible(true);

    }



}

I got this error syntax error on addActionListener, (= is expected after this token)

yourInputField.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
        // TODO Auto-generated method stub

    }

Can anyone give me some pointer?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T23:41:25+00:00Added an answer on May 20, 2026 at 11:41 pm

    You are calling a method (yourInputField.addActionListener), and it has to happen inside of other method, not just in the class.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code: package org.optimization.geneticAlgorithm; import org.optimization.geneticAlgorithm.selection.Pair; public abstract class Chromosome implements Comparable<Chromosome>
package org.apache.wicket.examples.guestbook; import java.util.Date; import org.apache.wicket.IClusterable; public class Comment implements IClusterable { private String
I'm running play application. I have import org.junit.Before; public class Frontpage extends Controller {
I have a class that extends DataRow : import org.jdesktop.dataset.DataRow; public class MainDataRow extends
import org.ksoap2.SoapEnvelope; import org.ksoap2.serialization.SoapObject; import org.ksoap2.serialization.SoapPrimitive; import org.ksoap2.serialization.SoapSerializationEnvelope; import org.ksoap2.transport.AndroidHttpTransport; import org.ksoap2.transport.HttpTransportSE; public class
I have the following code: trait A { import org.somepackage.C._ } class B extends
I write the following class: import org.apache.commons.jexl2.*; public class NelderMead { // контсанты private
Please, take a look at this example: import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class Test
I'm running the following code: import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.ResourcesPlugin; public class WorkspaceTest { public
Given the following code in Eclipse: import org.eclipse.jdt.core.dom.AST; import org.eclipse.jdt.core.dom.ASTParser; import org.eclipse.jdt.core.dom.CompilationUnit; public class

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.