~ubuntu-branches/ubuntu/trusty/libjgoodies-forms-java/trusty

« back to all changes in this revision

Viewing changes to src/tutorial/com/jgoodies/forms/tutorial/building/DefaultFormBuilderExample.java

  • Committer: Bazaar Package Importer
  • Author(s): Varun Hiremath
  • Date: 2008-02-25 10:57:07 UTC
  • mfrom: (1.2.1 upstream) (2.1.2 hardy)
  • Revision ID: james.westby@ubuntu.com-20080225105707-pe51fdbcq1dt3vi6
Tags: 1.2.0-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (c) 2002-2004 JGoodies Karsten Lentzsch. All Rights Reserved.
 
2
 * Copyright (c) 2002-2008 JGoodies Karsten Lentzsch. All Rights Reserved.
3
3
 *
4
 
 * Redistribution and use in source and binary forms, with or without 
 
4
 * Redistribution and use in source and binary forms, with or without
5
5
 * modification, are permitted provided that the following conditions are met:
6
 
 * 
7
 
 *  o Redistributions of source code must retain the above copyright notice, 
8
 
 *    this list of conditions and the following disclaimer. 
9
 
 *     
10
 
 *  o Redistributions in binary form must reproduce the above copyright notice, 
11
 
 *    this list of conditions and the following disclaimer in the documentation 
12
 
 *    and/or other materials provided with the distribution. 
13
 
 *     
14
 
 *  o Neither the name of JGoodies Karsten Lentzsch nor the names of 
15
 
 *    its contributors may be used to endorse or promote products derived 
16
 
 *    from this software without specific prior written permission. 
17
 
 *     
18
 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
19
 
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
20
 
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
21
 
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 
22
 
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
23
 
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
24
 
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 
25
 
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
26
 
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
27
 
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 
28
 
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
 
6
 *
 
7
 *  o Redistributions of source code must retain the above copyright notice,
 
8
 *    this list of conditions and the following disclaimer.
 
9
 *
 
10
 *  o Redistributions in binary form must reproduce the above copyright notice,
 
11
 *    this list of conditions and the following disclaimer in the documentation
 
12
 *    and/or other materials provided with the distribution.
 
13
 *
 
14
 *  o Neither the name of JGoodies Karsten Lentzsch nor the names of
 
15
 *    its contributors may be used to endorse or promote products derived
 
16
 *    from this software without specific prior written permission.
 
17
 *
 
18
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 
19
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 
20
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 
21
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 
22
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 
23
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 
24
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 
25
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 
26
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
 
27
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 
28
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
29
 */
30
30
 
31
31
package com.jgoodies.forms.tutorial.building;
36
36
import com.jgoodies.forms.layout.FormLayout;
37
37
 
38
38
/**
39
 
 * Uses the FormLayout and the <code>DefaultFormBuilder</code>. 
40
 
 * Columns are specified before the panel is filled with components, 
41
 
 * rows are added dynamically. The builder is used to hold a cursor, 
42
 
 * to add rows dynamically, and to fill components. 
 
39
 * Uses the FormLayout and the <code>DefaultFormBuilder</code>.
 
40
 * Columns are specified before the panel is filled with components,
 
41
 * rows are added dynamically. The builder is used to hold a cursor,
 
42
 * to add rows dynamically, and to fill components.
43
43
 * The builder's convenience methods are used to add labels and separators.<p>
44
 
 *  
 
44
 *
45
45
 * This panel building style is recommended unless you have a more
46
 
 * powerful builder or don't want to add rows dynamically. 
47
 
 * See the {@link DynamicRowsExample} for an implementation that specifies 
48
 
 * rows before the panel is filled with components. 
 
46
 * powerful builder or don't want to add rows dynamically.
 
47
 * See the {@link DynamicRowsExample} for an implementation that specifies
 
48
 * rows before the panel is filled with components.
49
49
 *
50
50
 * @author  Karsten Lentzsch
51
 
 * @version $Revision: 1.8 $
52
 
 * 
 
51
 * @version $Revision: 1.18 $
 
52
 *
53
53
 * @see     DefaultFormBuilder
54
54
 * @see     PlainExample
55
55
 * @see     RowCounterExample
70
70
    private JTextField dField;
71
71
    private JComboBox  locationCombo;
72
72
    private JTextField kFactorField;
73
 
    
 
73
 
74
74
 
75
75
    public static void main(String[] args) {
76
76
        try {
77
 
            UIManager.setLookAndFeel("com.jgoodies.plaf.plastic.PlasticXPLookAndFeel");
 
77
            UIManager.setLookAndFeel("com.jgoodies.looks.plastic.PlasticXPLookAndFeel");
78
78
        } catch (Exception e) {
79
79
            // Likely PlasticXP is not in the class path; ignore.
80
80
        }
110
110
 
111
111
    /**
112
112
     * Creates and returns a combo box for the locations.
113
 
     * 
 
113
     *
114
114
     * @return a combo box for three locations
115
115
     */
116
116
    private JComboBox createLocationComboBox() {
125
125
    // Building ***************************************************************
126
126
 
127
127
    /**
128
 
     * Builds the flange editor panel. 
129
 
     * Columns are specified before components are added to the form, 
 
128
     * Builds the flange editor panel.
 
129
     * Columns are specified before components are added to the form,
130
130
     * rows are added dynamically using the {@link DefaultFormBuilder}.<p>
131
 
     * 
 
131
     *
132
132
     * The builder combines a step that is done again and again:
133
133
     * add a label, proceed to the next data column and add a component.
134
 
     * 
 
134
     *
135
135
     * @return the built panel
136
136
     */
137
137
    public JComponent buildPanel() {
138
138
        initComponents();
139
139
 
 
140
        // Column specs only, rows will be added dynamically.
140
141
        FormLayout layout = new FormLayout(
141
 
                "right:max(40dlu;pref), 3dlu, 70dlu, 7dlu, "
142
 
              + "right:max(40dlu;pref), 3dlu, 70dlu",
143
 
                "");
 
142
                "right:[40dlu,pref], 3dlu, 70dlu, 7dlu, "
 
143
              + "right:[40dlu,pref], 3dlu, 70dlu");
144
144
        DefaultFormBuilder builder = new DefaultFormBuilder(layout);
145
145
        builder.setDefaultDialogBorder();
146
146
 
150
150
        builder.append("&Identifier", identifierField);
151
151
        builder.nextLine();
152
152
 
153
 
        builder.append("PTI [kW]",   ptiField);          
154
 
        builder.append("Power [kW]", powerField);
 
153
        builder.append("PTI/kW",   ptiField);
 
154
        builder.append("Power/kW", powerField);
155
155
 
156
 
        builder.append("s [mm]",     sField);
 
156
        builder.append("s/mm",     sField);
157
157
        builder.nextLine();
158
158
 
159
159
 
160
160
        builder.appendSeparator("Diameters");
161
161
 
162
 
        builder.append("&da [mm]",   daField);          
163
 
        builder.append("di [mm]",    diField);
164
 
 
165
 
        builder.append("da2 [mm]",   da2Field);          
166
 
        builder.append("di2 [mm]",   di2Field);
167
 
 
168
 
        builder.append("R [mm]",     rField);          
169
 
        builder.append("D [mm]",     dField);
 
162
        builder.append("&da/mm",   daField);
 
163
        builder.append("di/mm",    diField);
 
164
 
 
165
        builder.append("da2/mm",   da2Field);
 
166
        builder.append("di2/mm",   di2Field);
 
167
 
 
168
        builder.append("R/mm",     rField);
 
169
        builder.append("D/mm",     dField);
170
170
 
171
171
 
172
172
        builder.appendSeparator("Criteria");
173
173
 
174
 
        builder.append("&Location",  locationCombo);   
 
174
        builder.append("&Location",  locationCombo);
175
175
        builder.append("k-factor",   kFactorField);
176
176
 
177
177
        return builder.getPanel();
178
178
    }
179
179
 
180
 
}
 
 
b'\\ No newline at end of file'
 
180
}