FileDocCategorySizeDatePackage
ImportDlg.javaAPI DocExample4635Sat Sep 12 03:01:00 BST 1998borland.samples.apps.chess.client

ImportDlg

public class ImportDlg extends Dialog implements OkCancelDialog
Displays the Import/Export Dialog. The Import/Export dialog allows the current game to be copied in PGN(Portable game notation) format to the clipboard. From there, they could be saved and used in other programs that understand PGN. Also any PGN file may be copied into the dialogs text field and then displayed by the ChessViewer. *@see http://ourworld.compuserve.com/homepages/Manfred_Rosenboom/pgn_spec.htm or *@see ftp://chess.onenet.net/pub/chess/PGN/Standard

Fields Summary
ResourceBundle
res
Panel
dlgPanel
Button
cancelButton
Button
okButton
TextArea
game
BorderLayout
dialogLayout
Panel
innerPanel
BorderLayout
innerLayout
Label
instructions
Panel
buttonBar
Label
eastSpace
Label
westSpace
ChessViewer
dlgParent
Constructors Summary
public ImportDlg(ChessViewer dlgParent, String data)


       
    super(dlgParent.f,"",false);
    setTitle(res.getString("VERY_PRIMITIVE_PGN"));
    this.dlgParent = dlgParent;
    enableEvents(AWTEvent.WINDOW_EVENT_MASK);
    try {
      dlgParent.statusLine.setText(res.getString("COPY_TO_THE_CLIPBOARD"));
      dlgParent.setModal(true);
      game.setText(data);
      jbInit();
      add(dlgPanel);
      pack();
      setLocation(300,200);
    }
    catch (Exception e) {
      e.printStackTrace();
    }
  
Methods Summary
public voidcancel(java.awt.event.ActionEvent evt)
CancelButtonListener invokes this OkCancelDialog interface method

    try {
      dlgParent.statusLine.setText("");
      dispose();
      dlgParent.setModal(false);
    }
    catch (Exception e) {
      e.printStackTrace();
    }
  
private voidjbInit()

    dlgPanel.setLayout(dialogLayout);
    innerPanel.setLayout(innerLayout);
    game.selectAll();
    instructions.setText(res.getString("TO_IMPORT_PASTE_THE"));
    westSpace.setText(" "); //from the days before I learned how to use GridBagLayout <g>
    dlgPanel.add(innerPanel,BorderLayout.CENTER);
    instructions.setAlignment(Label.CENTER);
    innerPanel.add(instructions,BorderLayout.NORTH);
    buttonBar.add(okButton);
    okButton.setLabel(res.getString("IMPORT"));
    buttonBar.add(cancelButton);
    cancelButton.setLabel(res.getString("CANCEL"));
    okButton.addActionListener(new OkButtonListener(this));
    cancelButton.addActionListener(new CancelButtonListener(this));
    innerPanel.add(game,BorderLayout.CENTER);
    dlgPanel.add(eastSpace,BorderLayout.EAST);
    dlgPanel.add(westSpace,BorderLayout.WEST);
    innerPanel.add(buttonBar,BorderLayout.SOUTH);
  
public voidok(java.awt.event.ActionEvent evt)
OkButtonListener invokes this OkCancelDialog interface method

    try {
      dlgParent.importGame(game.getText());
      dispose();
      dlgParent.setModal(false);
    }
    catch (Exception e) {
       e.printStackTrace();
    }
  
protected voidprocessWindowEvent(java.awt.event.WindowEvent e)
So System close acts like cancel

    if (e.getID() == WindowEvent.WINDOW_CLOSING)
      cancel(null);
    else
      super.processWindowEvent(e);
  
public voidsetVisible(boolean isVisible)

    super.setVisible(isVisible);
    if (isVisible)
      game.requestFocus();