|
HelpFrame |
|
1 package gate.gui; 2 3 import javax.swing.*; 4 import javax.swing.text.*; 5 import javax.swing.text.html.*; 6 import java.awt.*; 7 import java.util.*; 8 import java.io.*; 9 import java.net.URL; 10 import java.awt.event.*; 11 import javax.swing.event.*; 12 import java.beans.*; 13 14 import gate.swing.*; 15 import gate.event.*; 16 17 /** 18 * A frame used by Gate to display Help information. 19 * It is a basic HTML browser. 20 */ 21 public class HelpFrame extends JFrame implements StatusListener { 22 23 public HelpFrame(){ 24 super(); 25 initLocalData(); 26 initGuiComponents(); 27 initListeners(); 28 } 29 30 protected void initLocalData(){ 31 } 32 33 protected void initGuiComponents(){ 34 getContentPane().setLayout(new BorderLayout()); 35 textPane = new XJEditorPane(); 36 textPane.setEditable(false); 37 getContentPane().add(new JScrollPane(textPane), BorderLayout.CENTER); 38 39 toolBar = new JToolBar(); 40 toolBar.add(textPane.getBackAction()); 41 toolBar.add(textPane.getForwardAction()); 42 43 getContentPane().add(toolBar, BorderLayout.NORTH); 44 45 Box southBox = Box.createHorizontalBox(); 46 southBox.add(new JLabel(" ")); 47 status = new JLabel(); 48 southBox.add(status); 49 getContentPane().add(southBox, BorderLayout.SOUTH); 50 51 } 52 53 protected void initListeners(){ 54 textPane.addPropertyChangeListener(new PropertyChangeListener(){ 55 public void propertyChange(PropertyChangeEvent e) { 56 if(e.getPropertyName().equals("document")){ 57 String title = (String)textPane.getDocument(). 58 getProperty("title"); 59 setTitle((title == null) ? 60 "Gate help browser" : 61 title + " - Gate help browser"); 62 } 63 } 64 }); 65 66 textPane.addStatusListener(this); 67 } 68 69 public void setPage(URL newPage) throws IOException{ 70 textPane.setPage(newPage); 71 String title = (String)textPane.getDocument(). 72 getProperty(Document.TitleProperty); 73 setTitle((title == null) ? 74 "Gate help browser" : 75 title + " - Gate help browser"); 76 } 77 78 XJEditorPane textPane; 79 JToolBar toolBar; 80 JLabel status; 81 public void statusChanged(String e) { 82 status.setText(e); 83 } 84 }
|
HelpFrame |
|