import java.awt.Container;
import java.awt.Dimension;
import java.awt.FlowLayout;
import javax.swing.JFrame;
import javax.swing.JTextField;
public class Main extends JFrame {
public Main() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(200, 200);
Container container = getContentPane();
container.setLayout(new FlowLayout(FlowLayout.LEFT));
JTextField textField = new JTextField(15);
textField.setPreferredSize(new Dimension(100, 20));
// Right justify the JTextField contents
textField.setHorizontalAlignment(JTextField.RIGHT);
container.add(textField);
}
public static void main(String[] args) {
new Main().setVisible(true);
}
}