HTML Pages in Java

let see if you can help me..
these seeems to be really simple, but I dont what to do first.
Simply, I need to show an html in a JFrame (or Frame)..
only a simple IExplorer, but done in Java..
where can I find information about this? or about the classes
that I must use?

Off of the top of my head, JLabel and JEditorPane components support HTML right out of the box, that is, you specify the tags inside your content and those components will render them as reasonably expected. Both of these components can be embedded within a JFrame.
If you'd like to glance at some sample code, I suggest going to Marty Hall's "Core Web Programming" web site, http://www.corewebprogramming.com, selecting "Source Code", chapter 14: Basic Swing, and looking at the following URLs:
http://archive.corewebprogramming.com/Chapter14/JLabels.java and
http://archive.corewebprogramming.com/Chapter14/browser/Browser.java

Similar Messages

  • How to create dom treeof html page with java

    hi, all
    i met with a problem how to create dom tree of html page wih jave, that is, given a html page, how to create a dom tree of this page with java?
    thanks in advance.
    regards
    richard

    but i m using this code to create node in html file
    HTMLLIElement li = (HTMLLIElement)appHTML.createElement("LI");
    Text txt = appHTML.createTextNode(name);
    li.appendChild(txt);
    appHTML.getElementById("name").appendChild(li);
    this will display all name value which is coming from database,
    and i want to assign a hyperlink to it,
    I have id with name also so I thought that using id i will
    create javascript like
    function popup(id)
         if(id==1)
              var n1 = window.open("../list/name1.html");
         if(id==2)
              var n1 = window.open("../list/name2.html");
    this way i want to popup particular file if i can pass id value in this function
    so want hyperlink like
    name

  • How to create hyperlink in Html page using Java

    Hello every one
    I want to know that how can I create a hyperlink in Html page using java ?
    Let for example
    I have code like this and i want to give hyperlink to it using java.
    rember that i am creating node using this id="name" which give me multiple value. and i want to assign diff link to each name..?
    <tr>
    <td ><span id="name"></span>
    </tr>

    but i m using this code to create node in html file
    HTMLLIElement li = (HTMLLIElement)appHTML.createElement("LI");
    Text txt = appHTML.createTextNode(name);
    li.appendChild(txt);
    appHTML.getElementById("name").appendChild(li);
    this will display all name value which is coming from database,
    and i want to assign a hyperlink to it,
    I have id with name also so I thought that using id i will
    create javascript like
    function popup(id)
         if(id==1)
              var n1 = window.open("../list/name1.html");
         if(id==2)
              var n1 = window.open("../list/name2.html");
    this way i want to popup particular file if i can pass id value in this function
    so want hyperlink like
    name

  • To show a html page from java application

    hi everyone,
    I am trying to show a html page through java application. What i tried is Runtime.getRuntime().exec("start url"); this shows it opens default browser. It works fine for win Nt but does not work on win98 or linux.
    Is there any other way of achieving the same?
    can anyone help me in this regard. I am in urgent need of it. any reply will appreciate.

    I hope this works.
    String urlName = "http://forum.java.sun.com";
    String browser = "iexplore "; //EXE file name --> for iexplore.exe
    Runtime.getRuntime().exec(browser+urlName);

  • How To Call HTML Page Through Java Swing Page  ???....

    Hi All ;
    Please Can You Tell Me How To Call HTML Page Through Java Swing Page ....
    Regards ;

    Hi,
    you can use HTML fragments on a panel.
    http://java.sun.com/docs/books/tutorial/uiswing/components/html.html
    However, to integrate a browser you need 3rd party software like IceBrowser
    If you Google for: HTML Swing
    then you find many more hints
    Frank

  • Get parameters from html page from java application standalone ...

    Hi all,
    I work in one solution that i have values in Html Page and i want get the parameters values from html and cath they in java application standalone.
    The Html page is in same host than de java application.
    I want know if this is possible. I wnat know if without HttpServlet i can get the parameters from Html Page pure.
    Thanks in Advance for the ideas,
    Antonio.

    Hi Abdul,
    The problem is my client want one solution where i have one page simple page Html and one application java standalone. This application runs in one machine, but we don't have web server. So the question is: Is possible without web server i can get the parameters values that is inside the html page from java application. I remember you that the application java is one .jar that run's with one command line from crontab "java -jar teste.jar".

  • Print Html page Using Java

    I need to print Html Page into my printer, how can I do this. Any help will be appreciated.
    Wil

    File > Print.
    See: http://java.sun.com/javase/6/docs/technotes/guides/jps/spec/printing2d.fm.html
    And:
    http://java.sun.com/j2se/1.4.2/docs/guide/jps/index.html
    And google "Java JPS"

  • How do i send an html page in java mail

    hi everyone, i have an problem while sending html page in my java mail application.Actually it's sending the html page correctly but the thing is it doesn't display the gif files . why so ? can anyone help me. i think its b'coz of the path problem.
    My requirement is like this :
    I would like to send an html page to some [email protected] from my local system . for that i have written one mail application which will build an html page which is also having some gif files. And these gif files are located in my local system. when i sent to some xyz user it's not displaying the gif files . How should i give the path for that gif files. pls help me regarding this. This is Urgent.
    Thanx in advance.
    by
    jjjavac

    hi , here with i have attached my program which will work fine . What u have to do is u have to specify ur smtp host address. from address and to address. And if u want to embedd the gif file u have to specify the gif file name. It will work only in outlook and hotmail. if u have anyother doubt let me know.
    import java.io.*;
    import java.util.Properties;
    import java.util.Date;
    import javax.mail.*;
    import javax.activation.*;
    import javax.mail.internet.*;
    import java.sql.*;
    import java.text.*;
    * @author Jeevan
    public class EmbeddingGif {
         StringBuffer sb = new StringBuffer();
         String line;
    public static void main(String[] argv) {
              new EmbeddingGif (argv);
    public EmbeddingGif (String[] argv) {
              String to, subject = null, from = "[email protected]",
              cc = null, bcc = null, url = null;
    //     String mailhost = null;
              String mailhost = "10.1.0.106";                    // SMTP host address
              String mailer = "SendHtmlMail";
              String protocol = "imap", host = null, user = "jeevan", password = "jeevan";
              String record = "g:/rbs/web-inf/classes/emailstore";     // name of folder in which to record mail
              boolean debug = false;
              BufferedReader in = null;
              int optind;
         for (optind = 0; optind < argv.length; optind++) {
         if (argv[optind].equals("-T")) {
              protocol = argv[++optind];
         } else if (argv[optind].equals("-H")) {
              host = argv[++optind];
         } else if (argv[optind].equals("-U")) {
              user = argv[++optind];
         } else if (argv[optind].equals("-P")) {
              password = argv[++optind];
         } else if (argv[optind].equals("-M")) {
              mailhost = argv[++optind];
         } else if (argv[optind].equals("-f")) {
              record = argv[++optind];
         } else if (argv[optind].equals("-s")) {
              subject = argv[++optind];
         } else if (argv[optind].equals("-o")) { // originator
              from = argv[++optind];
         } else if (argv[optind].equals("-c")) {
              cc = argv[++optind];
         } else if (argv[optind].equals("-b")) {
              bcc = argv[++optind];
         } else if (argv[optind].equals("-L")) {
              url = argv[++optind];
         } else if (argv[optind].equals("-d")) {
              debug = true;
         } else if (argv[optind].equals("--")) {
              optind++;
              break;
         } else if (argv[optind].startsWith("-")) {
              System.out.println(
    "Usage: SendHtmlMail [[-L store-url] | [-T prot] [-H host] [-U user] [-P passwd]]");
              System.out.println(
    "\t[-s subject] [-o from-address] [-c cc-addresses] [-b bcc-addresses]");
              System.out.println(
    "\t[-f record-mailbox] [-M transport-host] [-d] [address]");
              System.exit(1);
         } else {
              break;
         try {
         if (optind < argv.length) {
              // XXX - concatenate all remaining arguments
              to = argv[optind];
              System.out.println("To: " + to);
         } else {
              System.out.print("To: ");
              System.out.flush();
    //          to = in.readLine();
              to = "[email protected]";
         if (subject == null) {
              System.out.print("Subject: ");
              System.out.flush();
    //          subject = in.readLine();
              subject = "New Bill @ " + new Date ();
         } else {
              System.out.println("Subject: " + subject);
         Properties props = System.getProperties();
         // XXX - could use Session.getTransport() and Transport.connect()
         // XXX - assume we're using SMTP
              System.out.println("mailhost :"+mailhost);
              System.out.println("from :"+from);
              System.out.println("to :"+to);
              System.out.println("cc :"+cc);
              System.out.println("subject :"+subject);
              System.out.println("bcc :"+bcc);
              System.out.println("url :"+url);
         if (mailhost != null)
              props.put("mail.smtp.host", mailhost);
         // Get a Session object
         Session session = Session.getDefaultInstance (props, null);
         if (debug)
              session.setDebug (true);
         // construct the message
         Message msg = new MimeMessage(session);
         if (from != null)
              msg.setFrom(new InternetAddress(from));
         else
              msg.setFrom();
         msg.setRecipients(Message.RecipientType.TO,
                             InternetAddress.parse(to, false));
         if (cc != null)
              msg.setRecipients(Message.RecipientType.CC,
                             InternetAddress.parse(cc, false));
         if (bcc != null)
              msg.setRecipients(Message.RecipientType.BCC,
                             InternetAddress.parse(bcc, false));
         msg.setSubject(subject);
         collect(in, msg);
    //     msg.setHeader("X-Mailer", mailer);
    //     msg.setSentDate(new Date());
         // send the thing off
    //     Transport.send(msg);
    //     System.out.println("\nMail was sent successfully.");
         } catch (Exception e) {
         e.printStackTrace();
    public void collect(BufferedReader in, Message msg)     throws MessagingException, IOException {
                        BodyPart bp1=new MimeBodyPart();
                        String html="<H1>Hello from Jeevan</H1>";
                        html=html+"<img src=cid:mickey>";
                        bp1.setContent(html,"text/html");
                        MimeMultipart mp=new MimeMultipart("related");
                        mp.setSubType("related");
                        mp.addBodyPart(bp1);
                        BodyPart bp2=new MimeBodyPart();
                        DataSource source=new FileDataSource("fss.gif");
                        bp2.setDataHandler(new DataHandler(source));
                        bp2.setHeader("discrete-type","image");
                        bp2.setHeader("Content-ID","mickey");
                        mp.addBodyPart(bp2);
                        msg.setContent(mp);
                        Transport.send(msg);
         System.out.println("\nMail was sent successfully.");
    //                    msg.setDataHandler(new DataHandler(     new ByteArrayDataSource(sb.toString(), "text/html")));                                        

  • Reading an HTML page in Java

    I have done some server-side java coding before but nothing quite like this. I want to parse and HTML and extract information from it to process and create a new HTML page. This sounds like it should be easy enough, I just don't know where to start. Can anyone give me a pointed to the correct package/class(es) to research?
    If you are curious to know what I am planning on doing, read on. I am part of a Yahoo NFL Picks competition and I think it would greatly benefit from having a "What If?" scenario analyzer. Currently it does not. However, I can access each member's public picks page, extract their predictions, compare against my own predictions and then enter in results for games yet to be played. There are 46 members so I would need to read in 46 HTML pages, collect the predictions and then process the information. I'm pretty god at figuring out how to use classes, etc., I am just a little unsure of where to start looking.
    TIA, Max

    i know you could use JEditorPane
    here a code i found somewhere, already try it, its works:
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import javax.swing.event.*;
    import java.net.*;
    import javax.swing.text.*;
    public class Browser extends JFrame {
         Browser() {
              getContentPane().setLayout (new BorderLayout (5, 5));
              final JEditorPane jt = new JEditorPane();
              final JTextField input =
              new JTextField("http://java.sun.com");
              // make read-only
              jt.setEditable(false);
              // follow links
              jt.addHyperlinkListener(new HyperlinkListener () {
                   public void hyperlinkUpdate(
                   final HyperlinkEvent e) {
                        if (e.getEventType() ==
                             HyperlinkEvent.EventType.ACTIVATED) {
                                  SwingUtilities.invokeLater(new Runnable() {
                                       public void run() {
                                            // Save original
                                            Document doc = jt.getDocument();
                                            try {
                                                 URL url = e.getURL();
                                                 jt.setPage(url);
                                                 input.setText (url.toString());
                                            } catch (IOException io) {
                                                 JOptionPane.showMessageDialog (
                                                 Browser.this, "Can't follow link",
                                                 "Invalid Input",
                                                 JOptionPane.ERROR_MESSAGE);
                                                 jt.setDocument (doc);
              JScrollPane pane = new JScrollPane();
              pane.setBorder (
              BorderFactory.createLoweredBevelBorder());
              pane.getViewport().add(jt);
              getContentPane().add(pane, BorderLayout.CENTER);
              input.addActionListener (new ActionListener() {
                   public void actionPerformed (ActionEvent e) {
                        try {
                             jt.setPage (input.getText());
                        } catch (IOException ex) {
                             JOptionPane.showMessageDialog (
                             Browser.this, "Invalid URL",
                             "Invalid Input",
                             JOptionPane.ERROR_MESSAGE);
              getContentPane().add (input, BorderLayout.SOUTH);
         public static void main(String args[])
              Browser bro = new Browser();
              bro.setSize(500,500);
              bro.setVisible(true);
    }hope that help

  • Opening an Html page from java code

    Hi
    I have created an application and in order to complete it i need to configure help file with it. Now i have created a menubar in which help button is present.
    My requirement is that clicking the help button should display the help file which is in the form of an html file in a new window just as in any other application.
    Can anybody help me on this issue? Your help would ge really appreciated :)
    Thanks

    My requirement is that clicking the help button should display the help file which is in the form of an html file in a new window just as in any other application.Do you want to open a new "Browser"? is this a hard and fast requirement? If not why don't you use javahelp instead.
    For more details refer : http://java.sun.com/developer/technicalArticles/J2SE/Desktop/javahelp/index.html

  • How connect an HTML page to a running Java Application?

    Hi,
    Exists a way to connect an HTML page to a running Java Application?
    the idea is, If we use SWT, the Browser widget have an instance of IE/Firefox attached to it, and we load local HTML pages inside, then i wish to have a way to bridge Java Application from HTML page. Then with that we can do follow JScript:
    var javaApp = document.getJavaApplication(); //here is the trick
    //below is like we do today with applets
    var person = container.create("myapp.Person");
    person.setName("Test");
    container.save(person);its great if we can Have an attribute for object tag or anything to conect HTML page to Java Application.

    I think that the better idea is to create a new mime type for that, maybe "application/x-java-connect-to-local-jvm", and use embed tag, to connect via plugin to a running JavaApp
    example:
    <embed type="application/x-java-connect-to-local-jvm" width="20" height="20" mainClass="mypackage.AppName"><br>
    <script>
    var javaApp = document.embeds[0];
    function createPerson()
      var person = javaApp.getNew("mypackage.Person");
      person.setName("test");
      javaApp.save(person);
    }The width and height, isnt necessary, but the view can be used to show red if connection failed and green for sucessfull connections, or maybe embed tag can have src to images for sucessfull and unsucessfull states.
    That's the idea, there is a way to extend Java Plugin to achieve that?
    any tip or idea or to achieve that, are welcome.
    Thanks

  • How to read the code of html page

    Hi,
    I want to know how to read the code of html page through Java? And if anyone know the link of full implementation of Page Rank Algorithm in Java.
    Please let me know. I have to do the project on that topic.
    Regard
    Vivek

    Vivek_NITT wrote:
    I want to know how to read the code of html page through Java? Get the input stream from an HttpUrlConnection. Read from it like from any other stream.
    And if anyone know the link of full implementation of Page Rank Algorithm in Java.Which one?

  • Insert JAVA3D CODE into a HTML PAGE

    My java 3d code is working perfectly with javac and java command. I can see the result of my game in the appletviewer
    But when I want to insert the code into a html page,it dosen t work
    the java applet remain grey....
    Can someone tell me why and someone can tell me how to solve it
    Could you give me an example of HTML page using java 3D code with mulitple classes

    I don't know Java3D, but I know a little applets. :)
    Are you sure your browser understands the 3D API ?
    applets work with AWT and JDK1.1, (it's your browser than run your applet and not your jdk 1.3 or 1.4), so peraphs you should download a plug-in to run Java3D in your browser ?
    for example, if you want to use swing, you have to download a plug-in in your browser.
    and another problem is that different browsers work differently with a same applet : for example, IE 6.0 don't run than IE 4.0 or Netscape 3.0
    it's the internet's way of life... :)
    Good luck,
    David
    PS : sorry for my english, I'm from Paris ! :)

  • Running IE but with a html page of mine instead of default

    HI - I would like to know a better way to load up my html page using java. So far my execute statement is:
    Runtime.getRuntime().exec("C:\\Program Files\\Internet Explorer\\IExplorer.exe" + "My Page.html");
    If I don't include My Page.html IE will load up, but if I add My Page.html an IOException is caught. I want IE to load up with My Page.html, so My Page.html is the first page I see. Thanks
    Seigot

    Your problem is:
    Runtime.getRuntime().exec("C:\\Program Files\\Internet Explorer\\IExplorer.exe" + "My Page.html");
    will actually become
    Runtime.getRuntime().exec("C:\\Program Files\\Internet Explorer\\IExplorer.exeMy Page.html");
    so what is
    C:\Program Files\Internet Explorer\IExplorer.exeMy Page.html
    Of course it fails, there is a space missing.
    --lichu

  • Adding link to html page

    How do I add a link to html page through java code?
    If I want to see some text in the code as a link to some web page,then please let me know the changes I'll have to make in ordre to get the desired result.

    Hi,
    According to http://help.sap.com/javadocs/NW73EHP1/SPS14/CE/wdr/com.sap.wdr/index.html there are only two types of scopes APPLICATION_SCOPE  and TASK_SCOPE.
    My guess is that they both rely on browser cache somehow.
    Aviad

Maybe you are looking for