Viewing Html file..
hello, again.. i have this program named WebStrider.java
that works as a simple browser.. now i have a file named
simple.html found on my pc at d:\strider\. my question is
how can i make my program able to view the said .html file?
what code should i add to make this happen? thanks,..
here is my code..
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
publicclass Papyrusextends JFrame{
Viewer viewer;
JTextField txtfld;
JButton button, config;
Icon icon;
JPanel companel;
public Papyrus(){
super("Let's write on Papyrus!");
Container c = getContentPane();
companel =new JPanel();
companel.setLayout(new GridLayout(4,1));
viewer =new Viewer();
txtfld =new JTextField();
button =new JButton("SEND");
//button.nNemonic(S);
//on = new ImageIcon(guestbook_logo.png);
config =new JButton("Configuration");
companel.add(txtfld, BorderLayout.SOUTH);
companel.add(button, BorderLayout.SOUTH);
companel.add(config, BorderLayout.SOUTH);
c.add(viewer, BorderLayout.CENTER);
c.add(companel, BorderLayout.SOUTH);
setSize(500, 400);
show();
}
publicstaticvoid main(String[] args){
Papyrus app =new Papyrus();
app.addWindowListener(
new WindowAdapter(){
publicvoid windowClosing(WindowEvent e){
System.exit(0);
}
}
);
}
class Viewerextends JPanelimplements ActionListener{
JEditorPane content;
JTextField addressbar;
JPanel panel;
public Viewer(){
panel =new JPanel();
panel.setLayout(new GridLayout(2,1));
addressbar =new JTextField(20);
addressbar.addActionListener(this);
content =new JEditorPane();
content.addHyperlinkListener(
new HyperlinkListener(){
publicvoid hyperlinkUpdate(HyperlinkEvent e){
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
getThePage(e.getURL().toString());
}
}
);
panel.add(addressbar, BorderLayout.NORTH);
panel.add(new JScrollPane(content), BorderLayout.CENTER);
add(panel, BorderLayout.CENTER);
}
publicvoid actionPerformed(ActionEvent e){
getThePage(e.getActionCommand());
}
publicvoid getThePage(String urladdress){
//setCursor.getPredefinedCursor();
try{
content.setPage(urladdress);
}
catch(IOException io){
JOptionPane.showMessageDialog(null,"ERROR VIEWING PAGE");
}
}
}

