e.g. Calendar Search Help
You must enter a value before pressing Search
jgoodies_forms

Class: com.jgoodies.forms.tutorial.basics.BoundedSizesExample   ©

 OK to copy?
001 /*
002  * Copyright (c) 2002-2006 JGoodies Karsten Lentzsch. All Rights Reserved.
003  *
004  * Redistribution and use in source and binary forms, with or without 
005  * modification, are permitted provided that the following conditions are met:
006  * 
007  *  o Redistributions of source code must retain the above copyright notice, 
008  *    this list of conditions and the following disclaimer. 
009  *     
010  *  o Redistributions in binary form must reproduce the above copyright notice, 
011  *    this list of conditions and the following disclaimer in the documentation 
012  *    and/or other materials provided with the distribution. 
013  *     
014  *  o Neither the name of JGoodies Karsten Lentzsch nor the names of 
015  *    its contributors may be used to endorse or promote products derived 
016  *    from this software without specific prior written permission. 
017  *     
018  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
019  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
020  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
021  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 
022  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
023  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
024  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 
025  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
026  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
027  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 
028  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
029  */
030 
031 package com.jgoodies.forms.tutorial.basics;
032 
033 import javax.swing.*;
034 
035 import com.jgoodies.forms.builder.PanelBuilder;
036 import com.jgoodies.forms.layout.CellConstraints;
037 import com.jgoodies.forms.layout.FormLayout;
038 
039 /**
040  * Demonstrates the basic FormLayout sizes: constant, minimum, preferred.
041  *
042  * @author    Karsten Lentzsch
043  * @version $Revision: 1.13 $
044  */
045 public final class BoundedSizesExample {
046 
047     
048     public static void main(String[] args) {
049         try {
050             UIManager.setLookAndFeel("com.jgoodies.looks.plastic.PlasticXPLookAndFeel");
051         } catch (Exception e) {
052             // Likely PlasticXP is not in the class path; ignore.
053         }
054         JFrame frame = new JFrame();
055         frame.setTitle("Forms Tutorial :: Bounded Sizes");
056         frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
057         JComponent panel = new BoundedSizesExample().buildPanel();
058         frame.getContentPane().add(panel);
059         frame.pack();
060         frame.setVisible(true);
061     }
062 
063 
064     public JComponent buildPanel() {
Rate065         JTabbedPane tabbedPane = new JTabbedPane();
066         tabbedPane.putClientProperty("jgoodies.noContentBorder", Boolean.TRUE);
067 
068         tabbedPane.add("Jumping 1",  buildJumping1Panel());
069         tabbedPane.add("Jumping 2",  buildJumping2Panel());
070         tabbedPane.add("Stable 1",   buildStable1Panel());
071         tabbedPane.add("Stable 2",   buildStable2Panel());
072         return tabbedPane;
073     }
074     
075         
076     private JComponent buildJumping1Panel() {
077         FormLayout layout = new FormLayout( 
078                 "right:pref, 4dlu, max(35dlu;min), 2dlu, min, 2dlu, min, 2dlu, min, ",
079                 EDITOR_ROW_SPEC);
080         return buildEditorGeneralPanel(layout);
081     }
082     
083     private JComponent buildJumping2Panel() {
084         FormLayout layout = new FormLayout(
085                 "right:pref, 4dlu, max(35dlu;min), 2dlu, min, 2dlu, min, 2dlu, min, ",
086                 EDITOR_ROW_SPEC);
087         return buildEditorTransportPanel(layout);
088     }
089     
090     private JComponent buildStable1Panel() {
091         FormLayout layout = new FormLayout(
092                 "right:max(50dlu;pref), 4dlu, max(35dlu;min), 2dlu, min, 2dlu, min, 2dlu, min, ",
093                 EDITOR_ROW_SPEC);
094         return buildEditorGeneralPanel(layout);
095     }
096     
097     private JComponent buildStable2Panel() {
098         FormLayout layout = new FormLayout(
099                 "right:max(50dlu;pref), 4dlu, max(35dlu;min), 2dlu, min, 2dlu, min, 2dlu, min, ",
100                 EDITOR_ROW_SPEC);
101         return buildEditorTransportPanel(layout);
102     }
103     
104     private static final String EDITOR_ROW_SPEC =
105         "p, 3dlu, p, 3dlu, p, 3dlu, p";
106 
107 
108     /**
109      * Builds and answer the editor's general tab for the given layout.
110      * 
111      * @param layout   the layout to be used
112      * @return the editor's general panel
113      */
114     private JComponent buildEditorGeneralPanel(FormLayout layout) {
115         layout.setColumnGroups(new int[][] { { 3, 5, 7, 9 } });
116         PanelBuilder builder = new PanelBuilder(layout);
117             
118         builder.setDefaultDialogBorder();
119         CellConstraints cc = new CellConstraints();
120 
121         builder.addLabel("File number:",        cc.xy (1,  1));
122         builder.add(new JTextField(),           cc.xyw(3,  1, 7));
123         builder.addLabel("RFQ number:",         cc.xy (1,  3));
124         builder.add(new JTextField(),           cc.xyw(3,  3, 7));
125         builder.addLabel("Entry date:",         cc.xy (1,  5));
126         builder.add(new JTextField(),           cc.xy (3,  5));
127         builder.addLabel("Sales Person:",       cc.xy (1,  7));
128         builder.add(new JTextField(),           cc.xyw(3,  7, 7));
129         
130         return builder.getPanel();
131     }
132     
133     /**
134      * Builds and answer the editor's transport tab for the given layout.
135      * 
136      * @param layout   the layout to be used
137      * @return the editor's transport panel
138      */
139     private JComponent buildEditorTransportPanel(FormLayout layout) {
140         layout.setColumnGroups(new int[][] { { 3, 5, 7, 9 } });
141         PanelBuilder builder = new PanelBuilder(layout);
142             
143         builder.setDefaultDialogBorder();
144         CellConstraints cc = new CellConstraints();
145 
146         builder.addLabel("Shipper:",            cc.xy (1, 1));
147         builder.add(new JTextField(),           cc.xy (3, 1));
148         builder.add(new JTextField(),           cc.xyw(5, 1, 5));
149         builder.addLabel("Consignee:",          cc.xy (1, 3));
150         builder.add(new JTextField(),           cc.xy (3, 3));
151         builder.add(new JTextField(),           cc.xyw(5, 3, 5));
152         builder.addLabel("Departure:",          cc.xy (1, 5));
153         builder.add(new JTextField(),           cc.xy (3, 5));
154         builder.add(new JTextField(),           cc.xyw(5, 5, 5));
155         builder.addLabel("Destination:",        cc.xy (1, 7));
156         builder.add(new JTextField(),           cc.xy (3, 7));
157         builder.add(new JTextField(),           cc.xyw(5, 7, 5));
158         
159         return builder.getPanel();
160     }
161     
162     
163     
164     
165 }


            
All Examples in File:
Example
Line
Rating (found
useful by...)
65 0% of 0