Java Reference
In-Depth Information
Figure 10-21. Bean Builder and SpringLayout
Listing 10-5 offers source similar to what would be used to generate a screen like Figure 10-21.
Notice that you must use the content pane of the JFrame directly, as putConstraint() wants
that container, not the frame itself.
Listing 10-5. SpringLayout Example
import java.awt.*;
import javax.swing.*;
public class SpringSample {
public static void main(String args[]) {
Runnable runner = new Runnable() {
public void run() {
JFrame frame = new JFrame("SpringLayout");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container contentPane = frame.getContentPane();
SpringLayout layout = new SpringLayout();
contentPane.setLayout(layout);
Component left = new JLabel("Left");
Component right = new JTextField(15);
contentPane.add(left);
contentPane.add(right);
 
Search WWH ::




Custom Search