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

DrawDlg

public class DrawDlg extends Dialog implements OkCancelDialog
Present the Draw dialog, and initiates the response to the server Does double duty as the Offer Abort dialog as well.

Fields Summary
ResourceBundle
res
Panel
dlgPanel
Button
yesButton
Button
noButton
Label
text1
Label
text2
Panel
centerPanel
Label
northSpace
Label
westSpace
Label
eastSpace
BorderLayout
dialogLayout
boolean
drawdlg
Panel
buttonBar
GridLayout
centerpanelLayout
ChessViewer
dlgParent
Constructors Summary
public DrawDlg(Frame parent, String name, ChessViewer theapp)

  
       
    super(parent,name,false);
    enableEvents(AWTEvent.WINDOW_EVENT_MASK);
    dlgParent = theapp;

    dlgParent.setModal(true);
    if (name.equals("OfferDraw")) {
      drawdlg = true;
      setTitle(res.getString("WANNA_DRAW_"));
    }
    else {
      setTitle(res.getString("WANNA_ABORT_"));
      drawdlg = false;
    }
    jbInit();
    add(dlgPanel);
    if (drawdlg)
      text1.setText(dlgParent.opponentName  + res.getString("HAS_OFFERED_YOU_A"));
    else
      text1.setText(dlgParent.opponentName  + res.getString("HAS_OFFERED_TO_ABORT"));
  
Methods Summary
public voidcancel(java.awt.event.ActionEvent evt)

    dlgParent.sendMsg("Refused","") ;
    dispose();
    dlgParent.setModal(false);
  
private voidjbInit()

    text1.setText(res.getString("HAS_OFFERED_YOU_A"));
    text2.setText(res.getString("DO_YOU_ACCEPT_"));
    dlgPanel.setLayout(dialogLayout);
    eastSpace.setText("  ");
    centerpanelLayout.setRows(3);
    centerpanelLayout.setColumns(1);
    westSpace.setText("  ");
    northSpace.setText("  ");
    dlgPanel.add(eastSpace,BorderLayout.EAST);
    dlgPanel.add(westSpace,BorderLayout.WEST);
    dlgPanel.add(northSpace,BorderLayout.NORTH);
    dlgPanel.add(centerPanel,BorderLayout.CENTER);
    centerPanel.setLayout(centerpanelLayout );
    centerPanel.add(text1 );
    centerPanel.add(text2);
    buttonBar.add(yesButton);
    yesButton.setLabel(res.getString("YES"));
    buttonBar.add(noButton );
    noButton.setLabel(res.getString("NO"));
    yesButton.addActionListener(new OkButtonListener(this));
    noButton.addActionListener(new CancelButtonListener(this));
    centerPanel.add(buttonBar);
  
public voidok(java.awt.event.ActionEvent evt)

    int i=1;

    if (drawdlg) {
      dlgParent.statusLine.setText(res.getString("GAME_DRAWN"));
      dlgParent.game.setComment(dlgParent.movecount,dlgParent.color,"1/2-1/2");
      dlgParent.sendMsg("AcceptDraw","1/2-1/2")   ;
      dlgParent.gameOver();
      dlgParent.setModal(false);
    }
    else {
      dlgParent.statusLine.setText(res.getString("GAME_ABORTED"));
      dlgParent.sendMsg("AcceptAbort","Aborted")   ;
    }
    dlgParent.gameOver();
    dlgParent.setModal(false);
    dispose();
  
protected voidprocessWindowEvent(java.awt.event.WindowEvent e)

    if (e.getID() == WindowEvent.WINDOW_CLOSING)
      cancel(null);
    super.processWindowEvent(e);