Right justified JTextfield content

From CodeCodex

Revision as of 05:46, 7 January 2012 by Nostromo (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Implementations[edit]

Java[edit]

import javax.swing. *;
import java.awt.*;

public class Test extends JApplet {
  JTextField textfield;
  public void init() {
    getContentPane().setLayout(new FlowLayout());
    textfield = new JTextField(10);
    // Right-justify the text
    textfield.setHorizontalAlignment(JTextField.RIGHT);
    getContentPane().add(textfield);
    }
}