Article View: borland.public.jbuilder.java.language
Article #7686Re: URL Hell!!! Please Help...
From: Bernie
Date: Sat, 26 May 2001 15:46
Date: Sat, 26 May 2001 15:46
124 lines
4921 bytes
4921 bytes
I found the problem to be related to the fact that if the URL does not
change, the JEditorPane does not update. I simply used a counter
to add a number to the URL, to make the URL different each time.
-Bernie
Nabin Thomas wrote:
> T dont think you can do this directly.
> You need to check periodically and check whether the file hase changed since last load and
> reload the file.
>
> An optimal way will be to do this in activate event f the frame
>
> Bernie wrote:
>
> > 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);
> > }
> >
> > }
> >
> > }
>
> --
> ***********************************
> ***************************************************
> ******************* Web Card **********************
> ***************************************************
>
> Name : Nabin Thomas
>
> e-mail : nabinthomas@hotmail.com
>
> Web : http://nabin.terrashare.com
>
> Feel free to contact me thru e-mail or MSN Mssenger
> if required but DONOT SPAM
>
> ***************************************************
> ***********************************
Technical Details
Message-ID:
<3B0FCFD5.100EF078@att.net>Path:
arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!t-online.de!news1.dtag.de!news.stgl.sel.alcatel.de!news.stgl.sel.alcatel.de!dnewsReferences:
<3B0D7FF7.3F03D890@att.net> <3B0F3DBA.B17F25A1@hotmail.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,4fe5d4cf1e2c0d64 X-Google-Attributes: gidf74b3,public X-Google-ArrivalTime: 2001-05-26 09:14:07 PST Message-ID: <3B0FCFD5.100EF078@att.net> Date: Sat, 26 May 2001 11:46:29 -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: Re: URL Hell!!! Please Help... References: <3B0D7FF7.3F03D890@att.net> <3B0F3DBA.B17F25A1@hotmail.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 12.90.19.41 X-Trace: dnews 990891997 12.90.19.41 (26 May 2001 08:46:37 -0700) Lines: 125 Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!t-online.de!news1.dtag.de!news.stgl.sel.alcatel.de!news.stgl.sel.alcatel.de!dnews