O'Reilly logo

Beginning Java 8 APIs, Extensions and Libraries Swing, JavaFX, JavaScript, JDBC and Network Programming APIs by Kishori Sharan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

groupLayout.setHorizontalGroup(groupLayout.createSequentialGroup()                                          .addComponent(b1)                                          .addGap(10)                                          .addComponent(b2));

There are three ways to add gaps between two components. They are based on the gap size and their ability to resize.

  • You can add a rigid gap between two components using the addGap(int gapSize).
  • You can add a flexible (spring-like) gap between two components, which has a minimum, a preferred, and a maximum size, using the addGap(int min, int pref, int max) method. To add a flexible gap with 5, 10, and 50 as the minimum, preferred, and maximum size respectively, you set up your horizontal group like so:

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required