🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #7675

URL Hell!!! Please Help...

#7675
From: Bernie
Date: Thu, 24 May 2001 21:41
100 lines
3476 bytes
The basic application listed below will load an html page from
disk into a JEditorPane after clicking the "Get Page" button.
The problem is, if I change the file named word.html, the
changes are not displayed in the JEditorPane.   If I change
the file word.html, what do I have to do have the updated
page loaded into the JEditorPane?

-Thanks




package viewurl;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.io.*;
import java.net.*;

public class Frame1 extends JFrame {
  JPanel contentPane;
  JScrollPane jScrollPane1 = new JScrollPane();
  JEditorPane jEditorPane1 = new JEditorPane();
  JButton jButton1 = new JButton();
  static String userDir = System.getProperty("user.dir");


  /**Construct the frame*/
  public Frame1() {
    enableEvents(AWTEvent.WINDOW_EVENT_MASK);
    try {
      jbInit();
    }
    catch(Exception e) {
      e.printStackTrace();
    }
  }
  /**Component initialization*/
  private void jbInit() throws Exception  {

//setIconImage(Toolkit.getDefaultToolkit().createImage(Frame1.class.getResource("[Your
Icon]")));
    contentPane = (JPanel) this.getContentPane();
    contentPane.setLayout(null);
    this.setSize(new Dimension(400, 300));
    this.setTitle("Frame Title");
    jScrollPane1.setBounds(new Rectangle(9, 9, 381, 234));
    jEditorPane1.setEditable(false);
    jEditorPane1.addHyperlinkListener(new
javax.swing.event.HyperlinkListener() {
      public void hyperlinkUpdate(HyperlinkEvent e) {
        jEditorPane1_hyperlinkUpdate(e);
      }
    });
    jButton1.setText("Get Page");
    jButton1.setBounds(new Rectangle(146, 256, 100, 27));
    jButton1.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
        jButton1_actionPerformed(e);
      }
    });
    contentPane.add(jScrollPane1, null);
    contentPane.add(jButton1, null);
    jScrollPane1.getViewport().add(jEditorPane1, null);
  }
  /**Overridden so we can exit when window is closed*/
  protected void processWindowEvent(WindowEvent e) {
    super.processWindowEvent(e);
    if (e.getID() == WindowEvent.WINDOW_CLOSING) {
      System.exit(0);
    }
  }



  void jEditorPane1_hyperlinkUpdate(HyperlinkEvent e) {

  }



  void jButton1_actionPerformed(ActionEvent e) {

    try {
      jEditorPane1.setPage("file:" + userDir + "/word.html");
      jEditorPane1.revalidate();
      jEditorPane1.repaint();
    }
    catch (IOException ex) {
      ex.printStackTrace(System.err);
    }

  }



}
Technical Details
Message-ID: <3B0D7FF7.3F03D890@att.net>
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!dnews

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,4fe5d4cf1e2c0d64,start
X-Google-Attributes: gidf74b3,public
X-Google-ArrivalTime: 2001-05-24 14:46:03 PST
Message-ID: <3B0D7FF7.3F03D890@att.net>
Date: Thu, 24 May 2001 17:41:11 -0400
From: Bernie <bfb@att.net>
X-Mailer: Mozilla 4.75 [en] (X11; U; Linux 2.2.16-22 i686)
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: borland.public.jbuilder.java.language
Subject: URL Hell!!! Please Help...
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 12.90.18.79
X-Trace: dnews 990740478 12.90.18.79 (24 May 2001 14:41:18 -0700)
Lines: 101
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!dnews