SpringLayout.EAST : SpringLayout « javax.swing « Java by API






SpringLayout.EAST

import java.awt.Component;
import java.awt.Container;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.SpringLayout;

public class MainClass {

  public static void main(String[] a) {
    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("Name");
    Component right = new JTextField(15);

    contentPane.add(left);
    contentPane.add(right);

    layout.putConstraint(SpringLayout.WEST,  left, 10,
      SpringLayout.WEST,  contentPane);
    layout.putConstraint(SpringLayout.NORTH, left, 25,
      SpringLayout.NORTH, contentPane);
    layout.putConstraint(SpringLayout.NORTH, right, 25,
      SpringLayout.NORTH, contentPane);
    layout.putConstraint(SpringLayout.WEST, right, 20,
      SpringLayout.EAST, left);

    frame.setSize(300, 100);
    frame.setVisible(true);  }

}


           
       








Related examples in the same category

1.SpringLayout.NORTH
2.SpringLayout.WEST
3.SpringLayout.Constraints: setX(Spring x)
4.SpringLayout.Constraints: setY(Spring y)
5.SpringLayout: getConstraints(Component c)
6.SpringLayout: putConstraint(String e1, Component c1, Spring s, String e2, Component c2)