KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > multiview > test > BookTreePanel


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 /*
20  * BookTreePanel.java
21  *
22  * Created on May 26, 2005, 5:51 PM
23  */

24
25 package org.netbeans.modules.xml.multiview.test;
26
27 import org.netbeans.modules.xml.multiview.test.bookmodel.Book;
28 import org.netbeans.modules.xml.multiview.ui.TreePanel;
29 import org.netbeans.modules.xml.multiview.ui.TreeNode;
30 /**
31  *
32  * @author mkuchtiak
33  */

34 public class BookTreePanel extends javax.swing.JPanel JavaDoc implements TreePanel {
35
36     /** Creates new form BookTreePanel */
37     public BookTreePanel() {
38         initComponents();
39     }
40     
41     public void setModel(TreeNode node) {
42         Book book = ((BookTreePanelMVElement.BookNode)node).getBook();
43         titleTF.setText(book.getTitle());
44         priceTF.setText(book.getPrice());
45         paperbackBox.setSelected(book.isPaperback());
46         String JavaDoc instock = book.getAttributeValue("instock");
47         instockBox.setSelected("yes".equals(instock));
48     }
49     
50     /** This method is called from within the constructor to
51      * initialize the form.
52      * WARNING: Do NOT modify this code. The content of this method is
53      * always regenerated by the Form Editor.
54      */

55     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
56
private void initComponents() {
57         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
58
59         titleLabel = new javax.swing.JLabel JavaDoc();
60         titleTF = new javax.swing.JTextField JavaDoc();
61         priceLabel = new javax.swing.JLabel JavaDoc();
62         priceTF = new javax.swing.JTextField JavaDoc();
63         paperbackBox = new javax.swing.JCheckBox JavaDoc();
64         instockBox = new javax.swing.JCheckBox JavaDoc();
65         filler = new javax.swing.JPanel JavaDoc();
66
67         setLayout(new java.awt.GridBagLayout JavaDoc());
68
69         titleLabel.setText("Title:");
70         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
71         gridBagConstraints.gridx = 0;
72         gridBagConstraints.gridy = 0;
73         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
74         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 5, 0, 0);
75         add(titleLabel, gridBagConstraints);
76
77         titleTF.setColumns(40);
78         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
79         gridBagConstraints.gridx = 1;
80         gridBagConstraints.gridy = 0;
81         gridBagConstraints.gridwidth = 3;
82         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
83         gridBagConstraints.weightx = 2.0;
84         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 0, 0, 0);
85         add(titleTF, gridBagConstraints);
86
87         priceLabel.setText("Price:");
88         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
89         gridBagConstraints.gridx = 0;
90         gridBagConstraints.gridy = 1;
91         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
92         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 5, 5, 0);
93         add(priceLabel, gridBagConstraints);
94
95         priceTF.setColumns(30);
96         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
97         gridBagConstraints.gridx = 1;
98         gridBagConstraints.gridy = 1;
99         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
100         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 5, 0);
101         add(priceTF, gridBagConstraints);
102
103         paperbackBox.setText("Paperback");
104         paperbackBox.setHorizontalTextPosition(javax.swing.SwingConstants.LEADING);
105         paperbackBox.setOpaque(false);
106         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
107         gridBagConstraints.gridx = 2;
108         gridBagConstraints.gridy = 1;
109         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
110         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 10, 5, 0);
111         add(paperbackBox, gridBagConstraints);
112
113         instockBox.setText("In Stock");
114         instockBox.setActionCommand("instock");
115         instockBox.setHorizontalTextPosition(javax.swing.SwingConstants.LEADING);
116         instockBox.setOpaque(false);
117         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
118         gridBagConstraints.gridx = 3;
119         gridBagConstraints.gridy = 1;
120         gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
121         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 10, 5, 0);
122         add(instockBox, gridBagConstraints);
123
124         filler.setOpaque(false);
125         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
126         gridBagConstraints.gridx = 4;
127         gridBagConstraints.gridy = 0;
128         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
129         gridBagConstraints.weightx = 1.0;
130         add(filler, gridBagConstraints);
131
132     }
133     // </editor-fold>//GEN-END:initComponents
134

135     
136     // Variables declaration - do not modify//GEN-BEGIN:variables
137
private javax.swing.JPanel JavaDoc filler;
138     private javax.swing.JCheckBox JavaDoc instockBox;
139     private javax.swing.JCheckBox JavaDoc paperbackBox;
140     private javax.swing.JLabel JavaDoc priceLabel;
141     private javax.swing.JTextField JavaDoc priceTF;
142     private javax.swing.JLabel JavaDoc titleLabel;
143     private javax.swing.JTextField JavaDoc titleTF;
144     // End of variables declaration//GEN-END:variables
145

146 }
147
Popular Tags