Objectmix
Tags Register Mark Forums Read

[example] code to show URL content : Java

This is a discussion on [example] code to show URL content within the Java forums in Programming Languages category; <sscce> import javax.swing.JEditorPane; import javax.swing.JScrollPane; import javax.swing.JOptionPane; import java.net.URL; /** Simple code to dump a web page to a JEditorPane onscreen. Example usage.. java ShowURL http://www.physci.org/codes/ ..or.. java ShowURL @author Andrew Thompson @version 2007/04/23 */ public class ShowURL { public static void main(String[] args) { String address = null; if (args.length==0) { address = JOptionPane.showInputDialog(null, "URL?"); } else { address = args[0]; } JEditorPane jep = null; try { URL url = new URL(address); jep = new JEditorPane(url); } catch(Exception e) { jep = new JEditorPane(); jep.setText( e.toString() ); } JScrollPane jsp = new JScrollPane(jep); jsp.setPreferredSize(new java.awt.Dimension(400,300)); JOptionPane.showMessageDialog(null, jsp); } ...


Object Mix > Programming Languages > Java > [example] code to show URL content

Reply

 

LinkBack Thread Tools
  #1  
Old 04-23-2007, 06:09 AM
Junior Member
 
Join Date: Nov 2009
Posts: 0
Application Development is on a distinguished road
Default [example] code to show URL content

<sscce>
import javax.swing.JEditorPane;
import javax.swing.JScrollPane;
import javax.swing.JOptionPane;
import java.net.URL;

/**
Simple code to dump a web page to a JEditorPane onscreen.
Example usage..
java ShowURL http://www.physci.org/codes/
..or..
java ShowURL
@author Andrew Thompson
@version 2007/04/23
*/
public class ShowURL {

public static void main(String[] args) {
String address = null;
if (args.length==0) {
address = JOptionPane.showInputDialog(null, "URL?");
} else {
address = args[0];
}
JEditorPane jep = null;
try {
URL url = new URL(address);
jep = new JEditorPane(url);
} catch(Exception e) {
jep = new JEditorPane();
jep.setText( e.toString() );
}
JScrollPane jsp = new JScrollPane(jep);
jsp.setPreferredSize(new java.awt.Dimension(400,300));
JOptionPane.showMessageDialog(null, jsp);
}
}
</sscce>

--
Andrew Thompson
http://www.athompson.info/andrew/

Message posted via http://www.javakb.com

Reply

Thread Tools


Similar Threads

Thread Thread Starter Forum Replies Last Post
Do templates show source code? usenet c++ 7 05-09-2007 10:09 AM
JComboBox to show names but return a code. usenet Java 4 08-23-2006 10:26 AM
OWA does not show a content of the message, when click reply usenet Microsoft Exchange 0 03-16-2005 08:21 AM
how to show or hide system tray clock through code. usenet basic.visual 0 01-31-2004 08:30 PM
Re: Show me the code ! usenet logo 0 09-05-2003 03:51 AM


All times are GMT -5. The time now is 01:02 AM.

Managed by Infnx Pvt Ltd.