Java Doc for ExtendedGridLayout.java in  » Swing-Library » jEdit » org » gjt » sp » jedit » gui » 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 » jEdit » org.gjt.sp.jedit.gui 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.gjt.sp.jedit.gui.ExtendedGridLayout

ExtendedGridLayout
public class ExtendedGridLayout implements LayoutManager2(Code)
A layout manager that places components in a rectangular grid with variable cell sizes that supports colspans and rowspans.

The container is divided into rectangles, and each component is placed in a rectangular space defined by its colspan and rowspan. Each row is as large as the largest component in that row, and each column is as wide as the widest component in that column.

This behavior is similar to java.awt.GridLayout but it supports different row heights and column widths for each row/column.

For example, the following is a Dialog that lays out ten buttons exactly the same as in the example of the JavaDoc of java.awt.GridBagLayout with the difference of vertical and horizontal gaps that can be configured:



    1:import java.awt.Button;
    2:import java.awt.Dimension;
    3:
    4:import javax.swing.JDialog;
    5:
    6:import org.gjt.sp.jedit.gui.ExtendedGridLayout;
    7:import org.gjt.sp.jedit.gui.ExtendedGridLayoutConstraints;
    8:
    9:import static org.gjt.sp.jedit.gui.ExtendedGridLayoutConstraints.REMAINDER;
   10:
   11:public class ExampleDialog extends JDialog {
   12:    public ExampleDialog() {
   13:        super(null,"Example Dialog",true);
   14:        setLayout(new ExtendedGridLayout(5,5,new Insets(5,5,5,5)));
   15:        
   16:        add(makeButton("Button1"));
   17:        add(makeButton("Button2"));
   18:        add(makeButton("Button3"));
   19:        add(makeButton("Button4"));
   20:        Button button = makeButton("Button5");
   21:        add(button,new ExtendedGridLayoutConstraints(1,REMAINDER,1,button));
   22:        button = makeButton("Button6");
   23:        add(button,new ExtendedGridLayoutConstraints(2,3,1,button));
   24:        button = makeButton("Button7");
   25:        add(button,new ExtendedGridLayoutConstraints(2,button));
   26:        button = makeButton("Button8");
   27:        add(button,new ExtendedGridLayoutConstraints(3,1,2,button));
   28:        button = makeButton("Button9");
   29:        add(button,new ExtendedGridLayoutConstraints(3,3,1,button));
   30:        button = makeButton("Button10");
   31:        add(button,new ExtendedGridLayoutConstraints(4,REMAINDER,1,button));
   32:        
   33:        pack();
   34:        setLocationRelativeTo(null);
   35:        setVisible(true);
   36:    }
   37:    
   38:    private Button makeButton(String name) {
   39:        Button button = new Button(name);
   40:        button.setMaximumSize(new Dimension(Integer.MAX_VALUE,Integer.MAX_VALUE));
   41:        return button;
   42:    }
   43:}
 

If you use REMAINDER as colspan or rowspan then a component takes up the remaining space in that column or row. Any additional components in a row are ignored and not displayed. Additional components in a column are moved rightside. If a rowspan hits a colspan, the colspan ends and the rowspan takes precedence.

Components for which isVisible() == false are ignored. Because of this, components can be replaced "in-place" by adding two components next to each other, with different isVisible() values, and toggling the setVisible() values of both when we wish to swap the currently visible component with the one that is hidden.

If you want to reserve free space in a row inbetween components, add a javax.swing.Box.Filler to the layout if the free space is in the middle of a row, or just don't add components if the free space should be at the end of a row.

If a row is taller, or a column is wider than the maximumSize of a component, the component is resized to its maximum size and aligned according to its alignmentX and alignmentY values.

One instance of this class can be used to layout multiple containers at the same time.


author:
   Björn "Vampire" Kautler
version:
   1.0
See Also:   ExtendedGridLayoutConstraints
See Also:    java.awt.Component
See Also:    javax.swing.Box.Filler



Constructor Summary
public  ExtendedGridLayout(int hgap, int vgap, Insets distanceToBorders)
     Creates an extended grid layout manager with the specified horizontal and vertical gap, and the specified distance to the borders of the parent container.
public  ExtendedGridLayout()
     Creates an extended grid layout manager with zero horizontal and vertical gap, and zero distance to the borders of the parent container.

Method Summary
public  voidaddLayoutComponent(String name, Component component)
     If the layout manager uses a per-component string, adds the component component to the layout, associating it with the string specified by name.
public  voidaddLayoutComponent(Component component, Object constraints)
     Adds the specified component to the layout, using the specified constraints object.
public  floatgetLayoutAlignmentX(Container container)
     Returns the alignment along the X axis.
public  floatgetLayoutAlignmentY(Container container)
     Returns the alignment along the Y axis.
public  voidinvalidateLayout(Container container)
     Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.
public  voidlayoutContainer(Container parent)
     Lays out the specified container.
public  DimensionmaximumLayoutSize(Container parent)
     Calculates the maximum size dimensions for the specified container, given the components it contains.
public  DimensionminimumLayoutSize(Container parent)
     Calculates the minimum size dimensions for the specified container, given the components it contains.
public  DimensionpreferredLayoutSize(Container parent)
     Calculates the preferred size dimensions for the specified container, given the components it contains.
public  voidremoveLayoutComponent(Component component)
     Removes the specified component from the layout.
public  StringtoString()
     Returns a string representation of the object.


Constructor Detail
ExtendedGridLayout
public ExtendedGridLayout(int hgap, int vgap, Insets distanceToBorders)(Code)
Creates an extended grid layout manager with the specified horizontal and vertical gap, and the specified distance to the borders of the parent container.
Parameters:
  hgap - The horizontal space between two columns ()
Parameters:
  vgap - The vertical space between two rows ()
Parameters:
  distanceToBorders - The distances to the borders of the parent container
throws:
  IllegalArgumentException - if hgap
throws:
  IllegalArgumentException - if vgap



ExtendedGridLayout
public ExtendedGridLayout()(Code)
Creates an extended grid layout manager with zero horizontal and vertical gap, and zero distance to the borders of the parent container.




Method Detail
addLayoutComponent
public void addLayoutComponent(String name, Component component)(Code)
If the layout manager uses a per-component string, adds the component component to the layout, associating it with the string specified by name.
Parameters:
  name - The string to be associated with the component.Has to be null , so that default constraints are used.
Parameters:
  component - The component to be added
throws:
  IllegalArgumentException - if name is not null
See Also:   ExtendedGridLayout.addLayoutComponent(java.awt.Component,java.lang.Object)



addLayoutComponent
public void addLayoutComponent(Component component, Object constraints)(Code)
Adds the specified component to the layout, using the specified constraints object.
Parameters:
  component - The component to be added
Parameters:
  constraints - Where/how the component is added to the layout.
throws:
  IllegalArgumentException - if constraints is not an ExtendedGridLayoutConstraints object
throws:
  IllegalArgumentException - if constraints is a placeholder
throws:
  IllegalArgumentException - if constraints is not the right one for the component
See Also:   ExtendedGridLayoutConstraints



getLayoutAlignmentX
public float getLayoutAlignmentX(Container container)(Code)
Returns the alignment along the X axis. This specifies how the component would like to be aligned relative to other components. The value should be a number between 0 and 1 where 0 represents alignment along the origin, 1 is aligned the furthest away from the origin, 0.5 is centered, etc.
Parameters:
  container - The container for which the alignment should be returned java.awt.Component.CENTER_ALIGNMENT



getLayoutAlignmentY
public float getLayoutAlignmentY(Container container)(Code)
Returns the alignment along the Y axis. This specifies how the component would like to be aligned relative to other components. The value should be a number between 0 and 1 where 0 represents alignment along the origin, 1 is aligned the furthest away from the origin, 0.5 is centered, etc.
Parameters:
  container - The container for which the alignment should be returned java.awt.Component.CENTER_ALIGNMENT



invalidateLayout
public void invalidateLayout(Container container)(Code)
Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.
Parameters:
  container - The container for which the cached information should be discarded



layoutContainer
public void layoutContainer(Container parent)(Code)
Lays out the specified container.
Parameters:
  parent - The container to be laid out



maximumLayoutSize
public Dimension maximumLayoutSize(Container parent)(Code)
Calculates the maximum size dimensions for the specified container, given the components it contains.
Parameters:
  parent - The container to be laid out The maximum size for the container
See Also:   ExtendedGridLayout.minimumLayoutSize
See Also:   ExtendedGridLayout.preferredLayoutSize



minimumLayoutSize
public Dimension minimumLayoutSize(Container parent)(Code)
Calculates the minimum size dimensions for the specified container, given the components it contains.
Parameters:
  parent - The component to be laid out The minimum size for the container
See Also:   ExtendedGridLayout.maximumLayoutSize
See Also:   ExtendedGridLayout.preferredLayoutSize



preferredLayoutSize
public Dimension preferredLayoutSize(Container parent)(Code)
Calculates the preferred size dimensions for the specified container, given the components it contains.
Parameters:
  parent - The container to be laid out The preferred size for the container
See Also:   ExtendedGridLayout.maximumLayoutSize
See Also:   ExtendedGridLayout.minimumLayoutSize



removeLayoutComponent
public void removeLayoutComponent(Component component)(Code)
Removes the specified component from the layout.
Parameters:
  component - The component to be removed



toString
public String toString()(Code)
Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. a string representation of the object.



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.