Source Code : FormLayout: Spanning Example 7
Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com.
Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com.
Click Here or search from google with Libraries Name you get jar file related it
FormLayout: Spanning Example 7

/*
Code revised from Desktop Java Live:
http://www.sourcebeat.com/downloads/
*/
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import com.jgoodies.forms.debug.FormDebugPanel;
import com.jgoodies.forms.layout.CellConstraints;
import com.jgoodies.forms.layout.FormLayout;
public class FormLayoutExample7 extends JPanel {
public FormLayoutExample7() {
super(new BorderLayout());
FormDebugPanel panel = new FormDebugPanel();
FormLayout formLayout =
new FormLayout("fill:100px, fill:100px, fill:100px", "fill:100px, fill:100px");
panel.setLayout(formLayout);
CellConstraints c = new CellConstraints();
panel.add(createLabel("Comp1"), c.xywh(1, 1, 1, 2));
panel.add(createLabel("Comp2"), c.xywh(2, 1, 2, 1));
panel.add(createLabel("Comp3"), c.xy(2, 2));
panel.add(createLabel("Comp4"), c.xy(3, 2));
add(panel);
}
public JLabel createLabel(String text, int prefWidth, int prefHeight) {
JLabel label = createLabel(text);
label.setPreferredSize(new Dimension(prefWidth, prefHeight));
return label;
}
public JLabel createLabel(String text) {
JLabel label = new JLabel(text);
label.setBackground(Color.lightGray);
label.setBorder(BorderFactory.createLineBorder(Color.black));
label.setOpaque(true);
label.setHorizontalTextPosition(JLabel.CENTER);
label.setVerticalTextPosition(JLabel.CENTER);
return label;
}
public static void main(String[] a){
JFrame f = new JFrame("FormLayout: Spanning Example 7");
f.setDefaultCloseOperation(2);
f.add(new FormLayoutExample7());
f.pack();
f.setVisible(true);
}
}
Thank with us