package genegui; import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.text.*; /** General purpose file editor used for editing model files. This is likely not to be used much anymore, but it's here for old timers who like to mess with the raw files. @author WJS */ public class FileEditor extends JInternalFrame { /** The content pane */ private JPanel MainPanel; /** The JTextPane used to edit the file */ private JTextPane TheTextPane; /** Simple constructor. @author WJS */ public FileEditor() { super("File Viewer",true,true,true,true); init(); } /** Less simple constructor. @param StyledDocument document - The document to be edited. @author WJS */ public FileEditor(StyledDocument document) { super("File Editor",true,true,true,true); init(); setTextDocument(document); } /** Initialize the editor. @author WJS */ private void init() { MainPanel = new JPanel(); MainPanel.setLayout(new BoxLayout(MainPanel,BoxLayout.Y_AXIS)); setContentPane(MainPanel); // Set up the text pane in a scroll pane TheTextPane = new JTextPane(); JScrollPane scrollPane = new JScrollPane(TheTextPane); MainPanel.add(scrollPane); // Add in a button for updating the file // JPanel p = new JPanel(); // p.setLayout(new BoxLayout(p,BoxLayout.X_AXIS)); // JPanel filler = new JPanel(); // filler.setOpaque(false); // p.add(filler); // // Make a button for dispatching any updates // JButton updateButton = new JButton("Update"); // updateButton.addActionListener(new ActionListener() { // public void actionPerformed(ActionEvent ae) { // // TODO make update happen // } // }); // p.add(updateButton); // MainPanel.add(p); setSize(600,600); setVisible(true); } /** Sets the content of the text window. @param StyledDocument document @author WJS */ private void setTextDocument(StyledDocument document) { TheTextPane.setStyledDocument(document); } }