Java Doc for PanelBuilder.java in  » Swing-Library » jgoodies-forms » com » jgoodies » forms » builder » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Swing Library » jgoodies forms » com.jgoodies.forms.builder 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.jgoodies.forms.builder.AbstractFormBuilder
      com.jgoodies.forms.builder.PanelBuilder

All known Subclasses:   com.jgoodies.forms.builder.ButtonBarBuilder,  com.jgoodies.forms.builder.ButtonStackBuilder,  com.jgoodies.forms.builder.AbstractI15dPanelBuilder,
PanelBuilder
public class PanelBuilder extends AbstractFormBuilder (Code)
An general purpose panel builder that uses the FormLayout to lay out JPanels. It provides convenience methods to set a default border and to add labels, titles and titled separators.

The PanelBuilder is the working horse for layouts when more specialized builders like the ButtonBarBuilder or DefaultFormBuilder are inappropriate.

The Forms tutorial includes several examples that present and compare different style to build with the PanelBuilder: static row numbers vs. row variable, explicit CellConstraints vs. builder cursor, static rows vs. dynamically added rows. Also, you may check out the Tips & Tricks section of the Forms HTML documentation.

The text arguments passed to the methods #addLabel, #addTitle, and #addSeparator can contain an optional mnemonic marker. The mnemonic and mnemonic index are indicated by a single ampersand (&). For example "&Save", or "Save &as". To use the ampersand itself duplicate it, for example "Look&&Feel".

Example:
This example creates a panel with 3 columns and 3 rows.

 FormLayout layout = new FormLayout(
 "right:pref, 6dlu, 50dlu, 4dlu, default",  // columns 
 "pref, 3dlu, pref, 3dlu, pref");           // rows
 PanelBuilder builder = new PanelBuilder(layout);
 CellConstraints cc = new CellConstraints();
 builder.addLabel("&Title",      cc.xy  (1, 1));
 builder.add(new JTextField(),   cc.xywh(3, 1, 3, 1));
 builder.addLabel("&Price",      cc.xy  (1, 3));
 builder.add(new JTextField(),   cc.xy  (3, 3));
 builder.addLabel("&Author",     cc.xy  (1, 5));
 builder.add(new JTextField(),   cc.xy  (3, 5));
 builder.add(new JButton("..."), cc.xy  (5, 5));
 return builder.getPanel();
 

author:
   Karsten Lentzsch
version:
   $Revision: 1.5 $
See Also:   com.jgoodies.forms.factories.ComponentFactory
See Also:   I15dPanelBuilder
See Also:   DefaultFormBuilder



Constructor Summary
public  PanelBuilder(FormLayout layout)
     Constructs a PanelBuilder for the given layout.
public  PanelBuilder(FormLayout layout, JPanel panel)
     Constructs a PanelBuilder for the given FormLayout and layout container.

Method Summary
final public  JLabeladd(JLabel label, CellConstraints labelConstraints, Component component, CellConstraints componentConstraints)
     Adds a label and component to the panel using the given cell constraints. Sets the given label as the component label using JLabel.setLabelFor(java.awt.Component) .

Note: The CellConstraints objects for the label and the component must be different.

final public  JLabeladdLabel(String textWithMnemonic)
    
final public  JLabeladdLabel(String textWithMnemonic, CellConstraints constraints)
    
final public  JLabeladdLabel(String textWithMnemonic, String encodedConstraints)
    
final public  JLabeladdLabel(String textWithMnemonic, CellConstraints labelConstraints, Component component, CellConstraints componentConstraints)
     Adds a label and component to the panel using the given cell constraints. Sets the given label as the component label using JLabel.setLabelFor(java.awt.Component) .

Note: The CellConstraints objects for the label and the component must be different.

final public  JComponentaddSeparator(String textWithMnemonic)
    
final public  JComponentaddSeparator(String textWithMnemonic, CellConstraints constraints)
    
final public  JComponentaddSeparator(String textWithMnemonic, String encodedConstraints)
    
final public  JComponentaddSeparator(String textWithMnemonic, int columnSpan)
    
final public  JLabeladdTitle(String textWithMnemonic)
    
final public  JLabeladdTitle(String textWithMnemonic, CellConstraints constraints)
    
final public  JLabeladdTitle(String textWithMnemonic, String encodedConstraints)
    
final public  ComponentFactorygetComponentFactory()
     Returns the builder's component factory.
final public  JPanelgetPanel()
     Returns the panel used to build the form.
final public  voidsetBackground(Color background)
     Sets the panel's background color.
final public  voidsetBorder(Border border)
     Sets the panel's border.
final public  voidsetComponentFactory(ComponentFactory newFactory)
     Sets a new component factory.
final public  voidsetDefaultDialogBorder()
     Sets the default dialog border.
final public  voidsetOpaque(boolean b)
     Sets the panel's opaque state.


Constructor Detail
PanelBuilder
public PanelBuilder(FormLayout layout)(Code)
Constructs a PanelBuilder for the given layout. Uses an instance of JPanel as layout container with the given layout as layout manager.
Parameters:
  layout - the FormLayout to use



PanelBuilder
public PanelBuilder(FormLayout layout, JPanel panel)(Code)
Constructs a PanelBuilder for the given FormLayout and layout container.
Parameters:
  layout - the FormLayout to use
Parameters:
  panel - the layout container to build on




Method Detail
add
final public JLabel add(JLabel label, CellConstraints labelConstraints, Component component, CellConstraints componentConstraints)(Code)
Adds a label and component to the panel using the given cell constraints. Sets the given label as the component label using JLabel.setLabelFor(java.awt.Component) .

Note: The CellConstraints objects for the label and the component must be different. Cell constraints are implicitly cloned by the FormLayout when added to the container. However, in this case you may be tempted to reuse a CellConstraints object in the same way as with many other builder methods that require a single CellConstraints parameter. The pitfall is that the methods CellConstraints.xy*(...) just set the coordinates but do not create a new instance. And so the second invocation of xy*(...) overrides the settings performed in the first invocation before the object is cloned by the FormLayout.

Wrong:

 CellConstraints cc = new CellConstraints();
 builder.add(
 nameLabel, 
 cc.xy(1, 7),         // will be modified by the code below
 nameField, 
 cc.xy(3, 7)          // sets the single instance to (3, 7)
 );
 
Correct:
 // Using a single CellConstraints instance and cloning
 CellConstraints cc = new CellConstraints();
 builder.add(
 nameLabel, 
 (CellConstraints) cc.xy(1, 7).clone(), // cloned before the next modification 
 nameField, 
 cc.xy(3, 7)                            // sets this instance to (3, 7)
 );
 // Using two CellConstraints instances 
 CellConstraints cc1 = new CellConstraints();
 CellConstraints cc2 = new CellConstraints();
 builder.add(
 nameLabel, 
 cc1.xy(1, 7),       // sets instance 1 to (1, 7)
 nameField, 
 cc2.xy(3, 7)        // sets instance 2 to (3, 7)
 );
 

Parameters:
  label - the label to add
Parameters:
  labelConstraints - the label's cell constraints
Parameters:
  component - the component to add
Parameters:
  componentConstraints - the component's cell constraints the added label
throws:
  IllegalArgumentException - if the same cell constraints instanceis used for the label and the component
See Also:   JLabel.setLabelFor(java.awt.Component)
See Also:   DefaultFormBuilder



addLabel
final public JLabel addLabel(String textWithMnemonic)(Code)
Adds a textual label to the form using the default constraints.

 addLabel("Name");       // No Mnemonic
 addLabel("N&ame");      // Mnemonic is 'a'
 addLabel("Save &as");   // Mnemonic is the second 'a'
 addLabel("Look&&Feel"); // No mnemonic, text is "look&feel"
 

Parameters:
  textWithMnemonic - the label's text - may contain an ampersand (&) to mark a mnemonic the new label
See Also:   ComponentFactory



addLabel
final public JLabel addLabel(String textWithMnemonic, CellConstraints constraints)(Code)
Adds a textual label to the form using the specified constraints.

 addLabel("Name",       cc.xy(1, 1)); // No Mnemonic
 addLabel("N&ame",      cc.xy(1, 1)); // Mnemonic is 'a'
 addLabel("Save &as",   cc.xy(1, 1)); // Mnemonic is the second 'a'
 addLabel("Look&&Feel", cc.xy(1, 1)); // No mnemonic, text is "look&feel"
 

Parameters:
  textWithMnemonic - the label's text - may contain an ampersand (&) to mark a mnemonic
Parameters:
  constraints - the label's cell constraints the new label
See Also:   ComponentFactory



addLabel
final public JLabel addLabel(String textWithMnemonic, String encodedConstraints)(Code)
Adds a textual label to the form using the specified constraints.

 addLabel("Name",       "1, 1"); // No Mnemonic
 addLabel("N&ame",      "1, 1"); // Mnemonic is 'a'
 addLabel("Save &as",   "1, 1"); // Mnemonic is the second 'a'
 addLabel("Look&&Feel", "1, 1"); // No mnemonic, text is "look&feel"
 

Parameters:
  textWithMnemonic - the label's text - may contain an ampersand (&) to mark a mnemonic
Parameters:
  encodedConstraints - a string representation for the constraints the new label
See Also:   ComponentFactory



addLabel
final public JLabel addLabel(String textWithMnemonic, CellConstraints labelConstraints, Component component, CellConstraints componentConstraints)(Code)
Adds a label and component to the panel using the given cell constraints. Sets the given label as the component label using JLabel.setLabelFor(java.awt.Component) .

Note: The CellConstraints objects for the label and the component must be different. Cell constraints are implicitly cloned by the FormLayout when added to the container. However, in this case you may be tempted to reuse a CellConstraints object in the same way as with many other builder methods that require a single CellConstraints parameter. The pitfall is that the methods CellConstraints.xy*(...) just set the coordinates but do not create a new instance. And so the second invocation of xy*(...) overrides the settings performed in the first invocation before the object is cloned by the FormLayout.

Wrong:

 builder.addLabel(
 "&Name:",            // Mnemonic is 'N'
 cc.xy(1, 7),         // will be modified by the code below
 nameField, 
 cc.xy(3, 7)          // sets the single instance to (3, 7)
 );
 
Correct:
 // Using a single CellConstraints instance and cloning
 CellConstraints cc = new CellConstraints();
 builder.addLabel(
 "&Name:", 
 (CellConstraints) cc.xy(1, 7).clone(), // cloned before the next modification 
 nameField, 
 cc.xy(3, 7)                            // sets this instance to (3, 7)
 );
 // Using two CellConstraints instances 
 CellConstraints cc1 = new CellConstraints();
 CellConstraints cc2 = new CellConstraints();
 builder.addLabel(
 "&Name:",           // Mnemonic is 'N'
 cc1.xy(1, 7),       // sets instance 1 to (1, 7)
 nameField, 
 cc2.xy(3, 7)        // sets instance 2 to (3, 7)
 );
 

Parameters:
  textWithMnemonic - the label's text - may contain an ampersand (&) to mark a mnemonic
Parameters:
  labelConstraints - the label's cell constraints
Parameters:
  component - the component to add
Parameters:
  componentConstraints - the component's cell constraints the added label
throws:
  IllegalArgumentException - if the same cell constraints instanceis used for the label and the component
See Also:   JLabel.setLabelFor(java.awt.Component)
See Also:   ComponentFactory
See Also:   DefaultFormBuilder



addSeparator
final public JComponent addSeparator(String textWithMnemonic)(Code)
Adds a titled separator to the form that spans all columns.

 addSeparator("Name");       // No Mnemonic
 addSeparator("N&ame");      // Mnemonic is 'a'
 addSeparator("Save &as");   // Mnemonic is the second 'a'
 addSeparator("Look&&Feel"); // No mnemonic, text is "look&feel"
 

Parameters:
  textWithMnemonic - the separator label's text - may contain an ampersand (&) to mark a mnemonic the added separator



addSeparator
final public JComponent addSeparator(String textWithMnemonic, CellConstraints constraints)(Code)
Adds a titled separator to the form using the specified constraints.

 addSeparator("Name",       cc.xy(1, 1)); // No Mnemonic
 addSeparator("N&ame",      cc.xy(1, 1)); // Mnemonic is 'a'
 addSeparator("Save &as",   cc.xy(1, 1)); // Mnemonic is the second 'a'
 addSeparator("Look&&Feel", cc.xy(1, 1)); // No mnemonic, text is "look&feel"
 

Parameters:
  textWithMnemonic - the separator label's text - may contain an ampersand (&) to mark a mnemonic
Parameters:
  constraints - the separator's cell constraints the added separator



addSeparator
final public JComponent addSeparator(String textWithMnemonic, String encodedConstraints)(Code)
Adds a titled separator to the form using the specified constraints.

 addSeparator("Name",       "1, 1"); // No Mnemonic
 addSeparator("N&ame",      "1, 1"); // Mnemonic is 'a'
 addSeparator("Save &as",   "1, 1"); // Mnemonic is the second 'a'
 addSeparator("Look&&Feel", "1, 1"); // No mnemonic, text is "look&feel"
 

Parameters:
  textWithMnemonic - the separator label's text - may contain an ampersand (&) to mark a mnemonic
Parameters:
  encodedConstraints - a string representation for the constraints the added separator



addSeparator
final public JComponent addSeparator(String textWithMnemonic, int columnSpan)(Code)
Adds a titled separator to the form that spans the specified columns.

 addSeparator("Name",       3); // No Mnemonic
 addSeparator("N&ame",      3); // Mnemonic is 'a'
 addSeparator("Save &as",   3); // Mnemonic is the second 'a'
 addSeparator("Look&&Feel", 3); // No mnemonic, text is "look&feel"
 

Parameters:
  textWithMnemonic - the separator label's text - may contain an ampersand (&) to mark a mnemonic
Parameters:
  columnSpan - the number of columns the separator spans the added separator



addTitle
final public JLabel addTitle(String textWithMnemonic)(Code)
Adds a title label to the form using the default constraints.

 addTitle("Name");       // No mnemonic
 addTitle("N&ame");      // Mnemonic is 'a'
 addTitle("Save &as");   // Mnemonic is the second 'a'
 addTitle("Look&&Feel"); // No mnemonic, text is Look&Feel
 

Parameters:
  textWithMnemonic - the title label's text - may contain an ampersand (&) to mark a mnemonic the added title label
See Also:   ComponentFactory



addTitle
final public JLabel addTitle(String textWithMnemonic, CellConstraints constraints)(Code)
Adds a title label to the form using the specified constraints.

 addTitle("Name",       cc.xy(1, 1)); // No mnemonic
 addTitle("N&ame",      cc.xy(1, 1)); // Mnemonic is 'a'
 addTitle("Save &as",   cc.xy(1, 1)); // Mnemonic is the second 'a'
 addTitle("Look&&Feel", cc.xy(1, 1)); // No mnemonic, text is Look&Feel
 

Parameters:
  textWithMnemonic - the title label's text - may contain an ampersand (&) to mark a mnemonic
Parameters:
  constraints - the separator's cell constraints the added title label
See Also:   ComponentFactory



addTitle
final public JLabel addTitle(String textWithMnemonic, String encodedConstraints)(Code)
Adds a title label to the form using the specified constraints.

 addTitle("Name",       "1, 1"); // No mnemonic
 addTitle("N&ame",      "1, 1"); // Mnemonic is 'a'
 addTitle("Save &as",   "1, 1"); // Mnemonic is the second 'a'
 addTitle("Look&&Feel", "1, 1"); // No mnemonic, text is Look&Feel
 

Parameters:
  textWithMnemonic - the title label's text - may contain an ampersand (&) to mark a mnemonic
Parameters:
  encodedConstraints - a string representation for the constraints the added title label
See Also:   ComponentFactory



getComponentFactory
final public ComponentFactory getComponentFactory()(Code)
Returns the builder's component factory. If no factory has been set before, it is lazily initialized using with an instance of com.jgoodies.forms.factories.DefaultComponentFactory . the component factory
See Also:   PanelBuilder.setComponentFactory(ComponentFactory)



getPanel
final public JPanel getPanel()(Code)
Returns the panel used to build the form. the panel used by this builder to build the form



setBackground
final public void setBackground(Color background)(Code)
Sets the panel's background color.
Parameters:
  background - the color to set as new background
See Also:   JComponent.setBackground(Color)
since:
   1.1



setBorder
final public void setBorder(Border border)(Code)
Sets the panel's border.
Parameters:
  border - the border to set
See Also:   JComponent.setBorder(Border)



setComponentFactory
final public void setComponentFactory(ComponentFactory newFactory)(Code)
Sets a new component factory.
Parameters:
  newFactory - the component factory to be set
See Also:   PanelBuilder.getComponentFactory()



setDefaultDialogBorder
final public void setDefaultDialogBorder()(Code)
Sets the default dialog border.
See Also:   Borders



setOpaque
final public void setOpaque(boolean b)(Code)
Sets the panel's opaque state.
Parameters:
  b - true for opaque, false for non-opaque
See Also:   JComponent.setOpaque(boolean)
since:
   1.1



Methods inherited from com.jgoodies.forms.builder.AbstractFormBuilder
final public Component add(Component component, CellConstraints cellConstraints)(Code)(Java Doc)
final public Component add(Component component, String encodedCellConstraints)(Code)(Java Doc)
final public Component add(Component component)(Code)(Java Doc)
final public void appendColumn(ColumnSpec columnSpec)(Code)(Java Doc)
final public void appendColumn(String encodedColumnSpec)(Code)(Java Doc)
final public void appendGlueColumn()(Code)(Java Doc)
final public void appendGlueRow()(Code)(Java Doc)
final public void appendLabelComponentsGapColumn()(Code)(Java Doc)
final public void appendParagraphGapRow()(Code)(Java Doc)
final public void appendRelatedComponentsGapColumn()(Code)(Java Doc)
final public void appendRelatedComponentsGapRow()(Code)(Java Doc)
final public void appendRow(RowSpec rowSpec)(Code)(Java Doc)
final public void appendRow(String encodedRowSpec)(Code)(Java Doc)
final public void appendUnrelatedComponentsGapColumn()(Code)(Java Doc)
final public void appendUnrelatedComponentsGapRow()(Code)(Java Doc)
final protected CellConstraints cellConstraints()(Code)(Java Doc)
final protected CellConstraints createLeftAdjustedConstraints(int columnSpan)(Code)(Java Doc)
final public int getColumn()(Code)(Java Doc)
final public int getColumnCount()(Code)(Java Doc)
final protected int getColumnIncrementSign()(Code)(Java Doc)
final public Container getContainer()(Code)(Java Doc)
final public FormLayout getLayout()(Code)(Java Doc)
protected int getLeadingColumn()(Code)(Java Doc)
final public int getRow()(Code)(Java Doc)
final public int getRowCount()(Code)(Java Doc)
final public boolean isLeftToRight()(Code)(Java Doc)
final public void nextColumn()(Code)(Java Doc)
final public void nextColumn(int columns)(Code)(Java Doc)
final public void nextLine()(Code)(Java Doc)
final public void nextLine(int lines)(Code)(Java Doc)
final public void nextRow()(Code)(Java Doc)
final public void nextRow(int rows)(Code)(Java Doc)
final public void setAlignment(CellConstraints.Alignment hAlign, CellConstraints.Alignment vAlign)(Code)(Java Doc)
final public void setBounds(int column, int row, int columnSpan, int rowSpan)(Code)(Java Doc)
final public void setColumn(int column)(Code)(Java Doc)
final public void setColumnSpan(int columnSpan)(Code)(Java Doc)
final public void setExtent(int columnSpan, int rowSpan)(Code)(Java Doc)
final public void setHAlignment(CellConstraints.Alignment alignment)(Code)(Java Doc)
final public void setLeftToRight(boolean b)(Code)(Java Doc)
final public void setOrigin(int column, int row)(Code)(Java Doc)
final public void setRow(int row)(Code)(Java Doc)
final public void setRowSpan(int rowSpan)(Code)(Java Doc)
final public void setVAlignment(CellConstraints.Alignment alignment)(Code)(Java Doc)

Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.