Example usage for java.net URLConnection setDefaultAllowUserInteraction

List of usage examples for java.net URLConnection setDefaultAllowUserInteraction

Introduction

In this page you can find the example usage for java.net URLConnection setDefaultAllowUserInteraction.

Prototype

public static void setDefaultAllowUserInteraction(boolean defaultallowuserinteraction) 

Source Link

Document

Sets the default value of the allowUserInteraction field for all future URLConnection objects to the specified value.

Usage

From source file:Main.java

public static void main(String args[]) throws Exception {
    URL url = new URL("http://www.google.com");
    URLConnection httpCon = (URLConnection) url.openConnection();

    URLConnection.setDefaultAllowUserInteraction(true);

}

From source file:WebCrawler.java

  public WebCrawler() {
  // ("text/html");
  // ("audio/basic");
  // ("audio/au");
  // ("audio/aiff");
  // ("audio/wav");
  // ("video/mpeg");
  // ("video/x-avi");

  URLConnection.setDefaultAllowUserInteraction(false);
  searchThread = new Thread(this);
  searchThread.start();//from w w  w.j a  v  a2 s.co  m
}

From source file:WebCrawler.java

public void init() {

    // set up the main UI panel
    panelMain = new Panel();
    panelMain.setLayout(new BorderLayout(5, 5));

    // text entry components
    Panel panelEntry = new Panel();
    panelEntry.setLayout(new BorderLayout(5, 5));

    Panel panelURL = new Panel();
    panelURL.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5));
    Label labelURL = new Label("Starting URL: ", Label.RIGHT);
    panelURL.add(labelURL);//from ww  w  .j  a v  a 2 s  .  co  m
    textURL = new TextField("", 40);
    panelURL.add(textURL);
    panelEntry.add("North", panelURL);

    Panel panelType = new Panel();
    panelType.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5));
    Label labelType = new Label("Content type: ", Label.RIGHT);
    panelType.add(labelType);
    choiceType = new Choice();
    choiceType.addItem("text/html");
    choiceType.addItem("audio/basic");
    choiceType.addItem("audio/au");
    choiceType.addItem("audio/aiff");
    choiceType.addItem("audio/wav");
    choiceType.addItem("video/mpeg");
    choiceType.addItem("video/x-avi");
    panelType.add(choiceType);
    panelEntry.add("South", panelType);

    panelMain.add("North", panelEntry);

    // list of result URLs
    Panel panelListButtons = new Panel();
    panelListButtons.setLayout(new BorderLayout(5, 5));

    Panel panelList = new Panel();
    panelList.setLayout(new BorderLayout(5, 5));
    Label labelResults = new Label("Search results");
    panelList.add("North", labelResults);
    Panel panelListCurrent = new Panel();
    panelListCurrent.setLayout(new BorderLayout(5, 5));
    listMatches = new List(10);
    panelListCurrent.add("North", listMatches);
    labelStatus = new Label("");
    panelListCurrent.add("South", labelStatus);
    panelList.add("South", panelListCurrent);

    panelListButtons.add("North", panelList);

    // control buttons
    Panel panelButtons = new Panel();
    Button buttonSearch = new Button(SEARCH);
    buttonSearch.addActionListener(this);
    panelButtons.add(buttonSearch);
    Button buttonStop = new Button(STOP);
    buttonStop.addActionListener(this);
    panelButtons.add(buttonStop);

    panelListButtons.add("South", panelButtons);

    panelMain.add("South", panelListButtons);

    add(panelMain);
    setVisible(true);

    repaint();

    // initialize search data structures
    vectorToSearch = new Vector();
    vectorSearched = new Vector();
    vectorMatches = new Vector();

    // set default for URL access
    URLConnection.setDefaultAllowUserInteraction(false);
}