Hi all,
I have a Swing GUI I am creating for my team at work that parses through logs for all sorts of information. One of the features is that they can submit a new error (or solution to an error). This opens up in a separate JFrame that is currently using a GridLayout (I just wanted to get it looking something like what I want in my initial attempt). It looks like this:
All of the JLabels on the left are actually inside of JPanel elements that have a FlowLayout with the FlowLayout.CENTER option set. This prevents them from being placed on the very left side of the frame (with no padding). The four rows with the labels and then JComboBoxes/JTextFields are inside of a GridLayout. This is what I want to change. What I would really like to do is to use a GridBagLayout so that I can have more control over the placement of the items.
I have tried reading this page:
http://java.sun.com/docs/books/tutorial/uiswing/layout/gridbag.html
and I have even looked at the examples in GridBadLayoutDemo.java and ContainerEventDemo.java but it still just isn't clear to me. I want to control the size of each component. I see that I need to specify the first JLabel at gridx=0 and gridy=0, but I don't understand the widthx and widthy stuff, which I believe is where my problem lies. Maybe not.
Basically, how can I specify one component to take up so many pixels, or columns, or some certain percentage of the whole line? For example, if there are 10 columns defined then I want the JLabel to take up the first three, pad some space, and then have the JComboBox take up the next 2 columns. But for the lines with JTextFields, I want the JLabel to take up the first 3 columns, and then have a small padded space, and the text fields take up the remainder of the width (with small padding on the right).
Can someone offer some sample contraints that would help me define something like that?