desktop/desktop-sample/src/main/java/cz/xelfi/quoridor/desktop/sample/KukTopComponent.java
branchdesktop
changeset 257 03762a20a808
child 260 8ebffb5aa10e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/desktop/desktop-sample/src/main/java/cz/xelfi/quoridor/desktop/sample/KukTopComponent.java	Sat Sep 11 21:01:31 2010 +0200
     1.3 @@ -0,0 +1,99 @@
     1.4 +/*
     1.5 + * To change this template, choose Tools | Templates
     1.6 + * and open the template in the editor.
     1.7 + */
     1.8 +package cz.xelfi.quoridor.desktop.sample;
     1.9 +
    1.10 +import org.openide.util.NbBundle;
    1.11 +import org.openide.windows.TopComponent;
    1.12 +//import org.openide.util.ImageUtilities;
    1.13 +import org.netbeans.api.settings.ConvertAsProperties;
    1.14 +
    1.15 +/**
    1.16 + * Top component which displays something.
    1.17 + */
    1.18 +@ConvertAsProperties(dtd = "-//cz.xelfi.quoridor.desktop.sample//Kuk//EN",
    1.19 +autostore = false)
    1.20 +public final class KukTopComponent extends TopComponent {
    1.21 +
    1.22 +    /** path to the icon used by the component and its open action */
    1.23 +//    static final String ICON_PATH = "SET/PATH/TO/ICON/HERE";
    1.24 +    private static final String PREFERRED_ID = "KukTopComponent";
    1.25 +
    1.26 +    public KukTopComponent() {
    1.27 +        initComponents();
    1.28 +        
    1.29 +        setName(NbBundle.getMessage(KukTopComponent.class, "CTL_KukTopComponent"));
    1.30 +        setToolTipText(NbBundle.getMessage(KukTopComponent.class, "HINT_KukTopComponent"));
    1.31 +//        setIcon(ImageUtilities.loadImage(ICON_PATH, true));
    1.32 +
    1.33 +    }
    1.34 +
    1.35 +    /** This method is called from within the constructor to
    1.36 +     * initialize the form.
    1.37 +     * WARNING: Do NOT modify this code. The content of this method is
    1.38 +     * always regenerated by the Form Editor.
    1.39 +     */
    1.40 +    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    1.41 +    private void initComponents() {
    1.42 +
    1.43 +        boardPane1 = new cz.xelfi.quoridor.visidor.BoardPane();
    1.44 +
    1.45 +        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
    1.46 +        this.setLayout(layout);
    1.47 +        layout.setHorizontalGroup(
    1.48 +            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    1.49 +            .addGap(0, 450, Short.MAX_VALUE)
    1.50 +            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    1.51 +                .addGroup(layout.createSequentialGroup()
    1.52 +                    .addGap(0, 0, Short.MAX_VALUE)
    1.53 +                    .addComponent(boardPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    1.54 +                    .addGap(0, 0, Short.MAX_VALUE)))
    1.55 +        );
    1.56 +        layout.setVerticalGroup(
    1.57 +            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    1.58 +            .addGap(0, 450, Short.MAX_VALUE)
    1.59 +            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    1.60 +                .addGroup(layout.createSequentialGroup()
    1.61 +                    .addGap(0, 0, Short.MAX_VALUE)
    1.62 +                    .addComponent(boardPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    1.63 +                    .addGap(0, 0, Short.MAX_VALUE)))
    1.64 +        );
    1.65 +    }// </editor-fold>//GEN-END:initComponents
    1.66 +
    1.67 +    // Variables declaration - do not modify//GEN-BEGIN:variables
    1.68 +    private cz.xelfi.quoridor.visidor.BoardPane boardPane1;
    1.69 +    // End of variables declaration//GEN-END:variables
    1.70 +
    1.71 +    @Override
    1.72 +    public int getPersistenceType() {
    1.73 +        return TopComponent.PERSISTENCE_ALWAYS;
    1.74 +    }
    1.75 +
    1.76 +    @Override
    1.77 +    public void componentOpened() {
    1.78 +        // TODO add custom code on component opening
    1.79 +    }
    1.80 +
    1.81 +    @Override
    1.82 +    public void componentClosed() {
    1.83 +        // TODO add custom code on component closing
    1.84 +    }
    1.85 +
    1.86 +    void writeProperties(java.util.Properties p) {
    1.87 +        // better to version settings since initial version as advocated at
    1.88 +        // http://wiki.apidesign.org/wiki/PropertyFiles
    1.89 +        p.setProperty("version", "1.0");
    1.90 +        // TODO store your settings
    1.91 +    }
    1.92 +
    1.93 +    final void readProperties(java.util.Properties p) {
    1.94 +        String version = p.getProperty("version");
    1.95 +        // TODO read your settings according to their version
    1.96 +    }
    1.97 +
    1.98 +    @Override
    1.99 +    protected String preferredID() {
   1.100 +        return PREFERRED_ID;
   1.101 +    }
   1.102 +}