desktop/desktop-sample/src/main/java/cz/xelfi/quoridor/desktop/sample/KukTopComponent.java
branchdesktop
changeset 260 8ebffb5aa10e
parent 257 03762a20a808
child 261 cf7e6b8259e1
     1.1 --- a/desktop/desktop-sample/src/main/java/cz/xelfi/quoridor/desktop/sample/KukTopComponent.java	Sat Sep 11 21:01:31 2010 +0200
     1.2 +++ b/desktop/desktop-sample/src/main/java/cz/xelfi/quoridor/desktop/sample/KukTopComponent.java	Mon Sep 13 16:27:07 2010 +0200
     1.3 @@ -10,7 +10,7 @@
     1.4  import org.netbeans.api.settings.ConvertAsProperties;
     1.5  
     1.6  /**
     1.7 - * Top component which displays something.
     1.8 + * Top component which displays the board.
     1.9   */
    1.10  @ConvertAsProperties(dtd = "-//cz.xelfi.quoridor.desktop.sample//Kuk//EN",
    1.11  autostore = false)
    1.12 @@ -20,13 +20,20 @@
    1.13  //    static final String ICON_PATH = "SET/PATH/TO/ICON/HERE";
    1.14      private static final String PREFERRED_ID = "KukTopComponent";
    1.15  
    1.16 +    private String id;
    1.17 +
    1.18      public KukTopComponent() {
    1.19          initComponents();
    1.20          
    1.21          setName(NbBundle.getMessage(KukTopComponent.class, "CTL_KukTopComponent"));
    1.22          setToolTipText(NbBundle.getMessage(KukTopComponent.class, "HINT_KukTopComponent"));
    1.23  //        setIcon(ImageUtilities.loadImage(ICON_PATH, true));
    1.24 -
    1.25 +        
    1.26 +    }
    1.27 +    
    1.28 +    public void setGameId(String id) {
    1.29 +        this.id = id;
    1.30 +        boardPane1.setBoard(Quoridor.getDefault().getGame(id).getBoard());
    1.31      }
    1.32  
    1.33      /** This method is called from within the constructor to
    1.34 @@ -84,12 +91,17 @@
    1.35          // better to version settings since initial version as advocated at
    1.36          // http://wiki.apidesign.org/wiki/PropertyFiles
    1.37          p.setProperty("version", "1.0");
    1.38 -        // TODO store your settings
    1.39 +        if (id != null) {
    1.40 +            p.setProperty("id", id);
    1.41 +        }
    1.42      }
    1.43  
    1.44      final void readProperties(java.util.Properties p) {
    1.45          String version = p.getProperty("version");
    1.46 -        // TODO read your settings according to their version
    1.47 +        String myId = p.getProperty("id");
    1.48 +        if (myId != null) {
    1.49 +            setGameId(myId);
    1.50 +        }
    1.51      }
    1.52  
    1.53      @Override