1 package devisor2.grid.GUI.help; 2 3 import javax.swing.*; 4 import javax.swing.event.*; 5 import javax.swing.text.html.*; 6 import java.awt.*; 7 import java.awt.event.*; 8 9 import java.net.*; 10 import java.io.*; 11 12 import devisor2.grid.options.*; 13 14 /** 15 * This class is just a simple container to display the online version of 16 * the FAQ (which will be created by the tex2html tool. <br> 17 * 18 * @author Dominik Goeddeke (based on an implementation by Matthias Moeller) 19 * @version 0.9 20 */ 21 public class FAQFrame extends JFrame 22 { 23 /** 24 * reference to the ControlCenter 25 */ 26 private ControlCenter cc; 27 28 /** 29 * the Constructor just initialises a new FAQFrame and connects it 30 * to the html file of the manual 31 * 32 * @param String filename the absolut path (or relative path from 33 * devisorhome) to the html file 34 * @throws IOException if the specified file could not be loaded properly 35 */ FAQFrame(String filename)36 public FAQFrame(String filename) 37 throws IOException 38 { 39 // general stuff as usual 40 cc = ControlCenter.getMyself (); 41 // lay out GUI elements 42 initComponents (); 43 // Add HTML-file to be displayed 44 jEditorPane1.setEditorKit(new HTMLEditorKit()); 45 jEditorPane1.setPage(filename); 46 jEditorPane1.setBackground(Color.white); 47 jEditorPane1.setForeground(Color.black); 48 jEditorPane1.addHyperlinkListener(createHyperLinkListener()); 49 // all done 50 pack (); 51 } 52 53 /** 54 * lays out GUI elements 55 */ initComponents()56 private void initComponents () 57 { 58 jPanel1 = new JPanel (); 59 jButton1 = new JButton (); 60 jScrollPane1 = new JScrollPane (); 61 jEditorPane1 = new JEditorPane (); 62 setTitle ((String)cc.rb.getObject("GUI_help_FAQFrame_frametitle")); 63 jButton1.setText ((String)cc.rb.getObject("general_Ok")); 64 jButton1.addActionListener (new java.awt.event.ActionListener () { 65 public void actionPerformed (java.awt.event.ActionEvent evt) { 66 exitFrame (); 67 } 68 }); 69 70 jPanel1.add (jButton1); 71 72 getContentPane ().add (jPanel1, java.awt.BorderLayout.SOUTH); 73 74 jEditorPane1.setContentType ("text/html"); 75 jEditorPane1.setEditable(false); 76 jEditorPane1.setFont (new Font ("Default", 0, 12)); 77 78 jScrollPane1.setViewportView (jEditorPane1); 79 80 getContentPane ().add (jScrollPane1, java.awt.BorderLayout.CENTER); 81 } 82 83 /** 84 * just hides the frame 85 */ exitFrame()86 private void exitFrame() 87 { 88 this.hide(); 89 } 90 91 // attributes for quick reference to GUI elements 92 private JPanel jPanel1; 93 private JButton jButton1; 94 private JScrollPane jScrollPane1; 95 private JEditorPane jEditorPane1; 96 createHyperLinkListener()97 public HyperlinkListener createHyperLinkListener() 98 { 99 return new HyperlinkListener() 100 { 101 public void hyperlinkUpdate(HyperlinkEvent e) 102 { 103 if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { 104 if (e instanceof HTMLFrameHyperlinkEvent) { 105 ((HTMLDocument)jEditorPane1.getDocument()).processHTMLFrameHyperlinkEvent((HTMLFrameHyperlinkEvent)e); 106 } 107 else 108 { 109 try 110 { 111 jEditorPane1.setPage(e.getURL()); 112 } 113 catch (java.io.IOException ioe) 114 { 115 JOptionPane.showMessageDialog(null,ioe.getMessage(),(String)cc.rb.getObject("errors_messageboxheader"),JOptionPane.ERROR_MESSAGE); 116 } 117 } 118 } 119 } 120 }; 121 } 122 } 123 124 125