in swing, layout components that has different heights

We have components that have different heights, we want to show them in a way that vertically there is as little space as possible (as shown in the picture), how can we do that using miglayout?

in swing, layout components that has different heights


I've used MigLayout quite a bit, I'm not sure there's a really nice way to do this. What you really want is to have 5 columns and use split on the y axis which you can't do unfortunately.

I see three approaches:

1) Use 5 jpanels, one for each column and just use flowy in MigLayout for each column

2) Setup a matrix and assign each component to a number of cells

p.add(component1, "cell 0 0 1 1");
p.add(component2, "cell 1 0 1 2");

etc.. This works if pretty well if you don't have a lot of different end points in each column

"span" might be a little cleaner here:

p.add(component1, "spany 1");
p.add(component2, "spany 2");
p.add(component3, "spany 1");
p.add(component4, "spany 3");
p.add(component5, "spany 1, wrap");

3) Use "nogrid" and just set size bounds on each component

Category:java Time:2011-07-20 Views:1

Related post

  • How do I neatly indent some components using Java Swing layouts 2011-01-08

    Using Swing, what is the best way to indent some components underneath a checkbox or radio button? I need to make something in the style of Firefox 3.6's Options->Privacy dialog where some checkboxes are indented under a "main" checkbox. I can use

  • swing layout: vertical flow 2010-12-20

    What LayoutManager should I use to achieve a transposed version of FlowLayout? Essentially, I want a vertical list which occupies multiple columns if it can't fit all of it's components within one column. +------------------------+ | item 1 | | item

  • JAVA Swing GUI Components howto RTL view? 2008-12-10

    How can i make my Java Swing GUI Components [Right To Left] for Arabic language from NetBeans Desktop Application? --------------Solutions------------- Don't you just have to use: Component.setComponentOrientation( ComponentOrientation.RIGHT_TO_LEFT

  • Which Swing layout(s) do you recommend? 2009-12-02

    There are 8 layout managers in the Java library alone, and then there's a bunch of 3rd party products as well. The other day, I tried to use SpringLayout and... well, it ain't working out for me. See my other question. So... if you have a Swing app t

  • Swing layout problem 2010-01-27

    Hello I'd like to get this swing layout inside a JPanel: JLabel - JTextField - JComboBox as the panel resizes I'd like the textField to expand but not the other two. Everything must remain in line. I tried grid bag layout but doesn't work... or I can

  • How to set height of one layout component to the same height of another component? 2011-01-13

    How can I set one layout components height to the same as another component: example: Can I set android:layout_height="@+id/info_box.height" or do something similar? I want the height of the ImageView to match that of my LinearLayout ImageView androi

  • How to debug Java Swing Layouts 2011-07-12

    There is one method which prints layout information for particulat components. I knew one method is there but I forgot the name. When you call that method for Swing component it displays layout information in detail for that component just like dumps

  • Mixing Swing GUI components and JOGL 2010-07-08

    How does one go about adding JButtons among various other Swing GUI components inside a JOGL canvas? Is it even possible? Is it practical? If it is not possible/practical/feasible how would you go about programming your own GUI components that work i

  • Java Swing - Translucent Components 2011-02-13

    I recently asked a question about translucent components causing odd artifacts from seemingly not updating properly. The answer I received caused the artifacts to go away, but at the cost of translucency. The solution was to- for every translucent co

  • GWT - How to layout components horizontally in a FlowPanel? 2011-02-15

    The GWT documentation recommends using a FlowPanel (float: left set on its children) as a replacement for the HorizontalPanel to layout components. But how to do this? --------------Solutions------------- Says so right in the docs: and to use the flo

  • Swing Layout: Prevent my components from moving around 2010-12-13

    I'm coming from a Opengl project and I need to be able to place elements on my screen and that they stay there. I'm creating an applet that is the same size as the original opengl project (800*480) and I want to be able to place a button 150*50 at th

  • Layout components in a Swing Panel/Frame as an aspect 2012-01-05

    I was looking to better the framework that we had built for our Swing application. I wanted to bring in Spring and introduce aspects. I am new to both Spring and aspects. I was wondering, is it good practice to say layout the components as an aspect?

  • java swing layout of two components 2011-10-21

    +--------------------------------------------+ | +-------+ +----------+| | | +---+ | | +-----+ || | | | A | | | | B | || | | +---+ | | +-----+ || | +-------+ +----------+| +--------------------------------------------+ ^ | | Center Background: I have

  • java swing - layout oddness when using different layout managers 2009-02-12

    Bit of oddness, seen if I do the following: import javax.swing.*; public class FunkyButtonLayout { public static void main(String[] args) { JFrame frame = new JFrame(""); JPanel j0 = new JPanel(); // j0 gets added to the root pane j0.setLayout(null);

  • Swing Overlapping components 2009-09-15

    I have two AWT components in a Frame, Panel A and Panel B. I would like panel A to be sized to the height width of the frame (and maintain that size on frame resize), but I would like panel B to overlap A. B will be at a fixed position (0,0 to make i

  • Swing GUI components too tighly packed 2009-10-23

    In the Java Swing app I made it seems to me that all the component are too tightly packed. In QT one can specify padding and margins for the layout. Is there something similar for swing? Here is a screen shot of my application that I thing is too tig

  • Java Swing layout issue 2010-02-12

    I added child panel to parent panel by using method 'parent.addTab(child)' and added one JLabel in the child panel but setBounds method is not working in child panel. This JLabel is getting showed at one fix location. setBounds is working fine in par

  • Swing layout - Using a grid while keeping component dimensions 2010-05-22

    I'd like to make a login bar for an application and I can't figure out how to organize a series of JLabels and JTextFields such that they are organized in a horizontal grid without these same components being resized to fit each cell. I also want to

  • Java Swing: Centering components 2011-01-06

    I'm working on a Swing UI in which I want to center multiple components (JDialogs and JFrames). I know that the following code will calculate the user's screen size, and from there, I can easily center a component: Dimension screenSize = Toolkit.getD

Copyright (C), All Rights Reserved.

processed in 0.437 (s). 13 q(s)