Answer to Question #1366 in Java | JSP | JSF for Abhishek
2011-01-21T04:45:47-05:00
I want to know how to show an html page enabled with java script in a window application
1
2011-01-21T05:20:39-0500
Use a simple extension of the JInternalFrame class that contains a list objects. Here elements of the list represent HTML pages for a web site.import java.awt.*;import java.io.*;import java.awt.event.*;import javax.swing.*;public class PageFrame extends JInternalFrame implements ActionListener { SiteManager parent; String filename; JTextArea ta; public PageFrame(String name, SiteManager sm) { super ("Page: " + name, true, true, true, true ); parent = sm; setBounds(50,50,300,150); Container contentPane = getContentPane(); // Create a text area to display the contents of our file in // and stick it in a scrollable pane so we can see everything ta = new JTextArea(); JScrollPane jsp = new JScrollPane(ta); contentPane.add(jsp, BorderLayout.CENTER); JMenuBar jmb = new JMenuBar(); JMenu fileMenu = new JMenu("File"); JMenuItem saveItem = new JMenuItem("Save"); saveItem.addActionListener(this ); fileMenu.add(saveItem); jmb.add(fileMenu); setJMenuBar(jmb); filename = name; loadContent(); } public void actionPerformed(ActionEvent ae) { // Can only be the save menu saveContent(); } public void loadContent() { try { FileReader fr = new FileReader(filename); ta.read(fr, null ); fr.close(); } catch (Exception e) { System.err.println("Could not load page: " + filename); } } public void saveContent() { try { FileWriter fw = new FileWriter(filename); ta.write(fw); fw.close(); } catch (Exception e) { System.err.println("Could not save page: " + filename); } } public void cutText() { ta.cut(); } public void copyText() { ta.copy(); } public void pasteText() { ta.paste(); } }
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS !
Learn more about our help with Assignments:
Java JSP JSF
Comments
Leave a comment