Example #1
0
    @Override
    public void actionPerformed(ActionEvent e) {
      Frame frame = getFrame();
      JFileChooser chooser = new JFileChooser();
      int ret = chooser.showOpenDialog(frame);

      if (ret != JFileChooser.APPROVE_OPTION) {
        return;
      }

      File f = chooser.getSelectedFile();
      if (f.isFile() && f.canRead()) {
        Document oldDoc = getEditor().getDocument();
        if (oldDoc != null) {
          oldDoc.removeUndoableEditListener(undoHandler);
        }
        if (elementTreePanel != null) {
          elementTreePanel.setEditor(null);
        }
        getEditor().setDocument(new PlainDocument());
        frame.setTitle(f.getName());
        Thread loader = new FileLoader(f, editor.getDocument());
        loader.start();
      } else {
        JOptionPane.showMessageDialog(
            getFrame(),
            "Could not open file: " + f,
            "Error opening file",
            JOptionPane.ERROR_MESSAGE);
      }
    }
Example #2
0
    public void actionPerformed(ActionEvent e) {
      Frame frame = getFrame();
      JFileChooser chooser = new JFileChooser();
      int ret = chooser.showSaveDialog(frame);

      if (ret != JFileChooser.APPROVE_OPTION) {
        return;
      }

      File f = chooser.getSelectedFile();
      frame.setTitle(f.getName());
      Thread saver = new FileSaver(f, editor.getDocument());
      saver.start();
    }
 /**
  * main entrypoint - starts the part when it is run as an application
  *
  * @param args java.lang.String[]
  */
 public static void main(java.lang.String[] args) {
   try {
     Frame frame = new java.awt.Frame();
     AddressBookSelectionUI aAddressBookSelectionUI;
     aAddressBookSelectionUI = new AddressBookSelectionUI();
     frame.add("Center", aAddressBookSelectionUI);
     frame.setSize(aAddressBookSelectionUI.getSize());
     frame.addWindowListener(
         new java.awt.event.WindowAdapter() {
           public void windowClosing(java.awt.event.WindowEvent e) {
             System.exit(0);
           };
         });
     frame.setVisible(true);
   } catch (Throwable exception) {
     System.err.println("Exception occurred in main() of java.awt.Panel");
     exception.printStackTrace(System.out);
   }
 }
 /** Updates the UIs of all the known Frames. */
 private static void updateAllUIs() {
   // Check if the current UI is WindowsLookAndfeel and flush the XP style map.
   // Note: Change the package test if this class is moved to a different package.
   Class uiClass = UIManager.getLookAndFeel().getClass();
   if (uiClass.getPackage().equals(DesktopProperty.class.getPackage())) {
     XPStyle.invalidateStyle();
   }
   Frame appFrames[] = Frame.getFrames();
   for (int j = 0; j < appFrames.length; j++) {
     updateWindowUI(appFrames[j]);
   }
 }