Example usage for java.awt FlowLayout LEFT

List of usage examples for java.awt FlowLayout LEFT

Introduction

In this page you can find the example usage for java.awt FlowLayout LEFT.

Prototype

int LEFT

To view the source code for java.awt FlowLayout LEFT.

Click Source Link

Document

This value indicates that each row of components should be left-justified.

Usage

From source file:Main.java

public Main() {
    super("Month Spinner");
    setSize(200, 100);/*  w  w w.  j  a  v a 2  s  .  com*/
    setDefaultCloseOperation(EXIT_ON_CLOSE);

    Container c = getContentPane();
    c.setLayout(new FlowLayout(FlowLayout.LEFT, 4, 4));

    c.add(new JLabel("Expiration Date:"));
    Date today = new Date();
    JSpinner s = new JSpinner(new SpinnerDateModel(today, null, null, Calendar.MONTH));
    JSpinner.DateEditor de = new JSpinner.DateEditor(s, "MM/yy");
    s.setEditor(de);
    c.add(s);

    setVisible(true);

    System.out.println(s.getPreviousValue());
}

From source file:Main.java

public Main() {
    super("Month Spinner");
    setSize(200, 100);/*from w  ww  .ja  va 2 s. com*/
    setDefaultCloseOperation(EXIT_ON_CLOSE);

    Container c = getContentPane();
    c.setLayout(new FlowLayout(FlowLayout.LEFT, 4, 4));

    c.add(new JLabel("Expiration Date:"));
    Date today = new Date();
    SpinnerDateModel model = new SpinnerDateModel(today, null, null, Calendar.MONTH);
    JSpinner s = new JSpinner();
    s.setModel(model);
    JSpinner.DateEditor de = new JSpinner.DateEditor(s, "MM/yy");
    s.setEditor(de);

    c.add(s);

    setVisible(true);
}

From source file:MainClass.java

public MainClass() {
    super("Month Spinner");
    setSize(200, 100);// ww w. ja v a 2  s  .  c  o m
    setDefaultCloseOperation(EXIT_ON_CLOSE);

    Container c = getContentPane();
    c.setLayout(new FlowLayout(FlowLayout.LEFT, 4, 4));

    c.add(new JLabel("Expiration Date:"));
    Date today = new Date();
    JSpinner s = new JSpinner(new SpinnerDateModel(today, null, null, Calendar.MONTH));
    JSpinner.DateEditor de = new JSpinner.DateEditor(s, "MM/yy");
    s.setEditor(de);
    c.add(s);

    setVisible(true);
}

From source file:Main.java

public Main() {
    super("Month Spinner");
    setSize(200, 100);//from w w w .ja v  a  2  s  . c  o  m
    setDefaultCloseOperation(EXIT_ON_CLOSE);

    Container c = getContentPane();
    c.setLayout(new FlowLayout(FlowLayout.LEFT, 4, 4));

    c.add(new JLabel("Expiration Date:"));
    Date today = new Date();
    JSpinner s = new JSpinner(new SpinnerDateModel(today, null, null, Calendar.MONTH));
    JSpinner.DateEditor de = new JSpinner.DateEditor(s, "MM/yy");
    s.setEditor(de);
    c.add(s);

    setVisible(true);

    try {
        s.commitEdit();
    } catch (ParseException e) {
        e.printStackTrace();
    }
}

From source file:Main.java

public Main() throws HeadlessException {
    setSize(200, 200);//  w  ww  .  j a v a2 s.  co m
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setLayout(new FlowLayout(FlowLayout.LEFT));

    DocumentFilter filter = new UppercaseDocumentFilter();

    JTextField firstName = new JTextField();
    firstName.setPreferredSize(new Dimension(100, 20));
    ((AbstractDocument) firstName.getDocument()).setDocumentFilter(filter);

    JTextField lastName = new JTextField();
    lastName.setPreferredSize(new Dimension(100, 20));
    ((AbstractDocument) lastName.getDocument()).setDocumentFilter(filter);

    add(firstName);
    add(lastName);
}

From source file:Main.java

public Main() {
    super();/*  w  w w .  j  a v a 2  s .c  o m*/
    Container pane = getContentPane();
    pane.setLayout(new FlowLayout(FlowLayout.LEFT));
    pane.add(new JLabel("This is a test"));
    pane.add(new JButton("of a FlowLayout"));
    pane.add(new JTextField(30));
    pane.add(new JTextArea("This is a JTextArea", 3, 10));
    pane.add(new JLabel("This is a FlowLayout test with a long string"));
}

From source file:FlowLayoutBehaviour.java

public FlowLayoutBehaviour() {
    super();//from  w w  w . j a v  a  2s  .c  o m
    Container pane = getContentPane();
    pane.setLayout(new FlowLayout(FlowLayout.LEFT));
    pane.add(new JLabel("This is a test"));
    pane.add(new JButton("of a FlowLayout"));
    pane.add(new JTextField(30));
    pane.add(new JTextArea("This is a JTextArea", 3, 10));
    pane.add(new JLabel("This is a FlowLayout test with a long string"));
}

From source file:MonthSpinner.java

public MonthSpinner() {
    super("Month Spinner");
    setSize(200, 100);//from  w  w w.j  a v  a  2s  .c o  m
    setDefaultCloseOperation(EXIT_ON_CLOSE);

    Container c = getContentPane();
    c.setLayout(new FlowLayout(FlowLayout.LEFT, 4, 4));

    c.add(new JLabel("Expiration Date:"));
    Date today = new Date();
    // Start the spinner today, but don't set a min or max date
    // The increment should be a month
    JSpinner s = new JSpinner(new SpinnerDateModel(today, null, null, Calendar.MONTH));
    JSpinner.DateEditor de = new JSpinner.DateEditor(s, "MM/yy");
    s.setEditor(de);
    c.add(s);

    setVisible(true);
}

From source file:ToolbarFrame2.java

public ToolbarFrame2() {
    setSize(450, 250);//from  w w w  .j a v a 2s .  co m

    ActionListener printListener = new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            System.out.println(ae.getActionCommand());
        }
    };

    // JPanel works similarly to Panel, so we'll use it
    JPanel toolbar = new JPanel();
    toolbar.setLayout(new FlowLayout(FlowLayout.LEFT));

    cutButton = new JButton("Cut");
    cutButton.addActionListener(printListener);
    toolbar.add(cutButton);

    copyButton = new JButton("Copy");
    copyButton.addActionListener(printListener);
    toolbar.add(copyButton);

    pasteButton = new JButton("Paste");
    pasteButton.addActionListener(printListener);
    toolbar.add(pasteButton);

    add(toolbar, BorderLayout.NORTH); // The new BorderLayout add

    JPanel lnfPanel = new JPanel();
    macButton = new JButton("Mac");
    macButton.addActionListener(printListener);
    lnfPanel.add(macButton);
    javaButton = new JButton("Metal");
    javaButton.addActionListener(printListener);
    lnfPanel.add(javaButton);
    motifButton = new JButton("Motif");
    motifButton.addActionListener(printListener);
    lnfPanel.add(motifButton);
    winButton = new JButton("Windows");
    winButton.addActionListener(printListener);
    lnfPanel.add(winButton);
    add(lnfPanel, BorderLayout.SOUTH);
}

From source file:ToolbarFrame1.java

public ToolbarFrame1() {
    super("Toolbar Example (AWT)");
    setSize(450, 250);//from w  w  w.  jav  a 2s  .co m
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });

    ActionListener printListener = new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            System.out.println(ae.getActionCommand());
        }
    };

    Panel toolbar = new Panel();
    toolbar.setLayout(new FlowLayout(FlowLayout.LEFT));

    cutButton = new Button("Cut");
    cutButton.addActionListener(printListener);
    toolbar.add(cutButton);

    copyButton = new Button("Copy");
    copyButton.addActionListener(printListener);
    toolbar.add(copyButton);

    pasteButton = new Button("Paste");
    pasteButton.addActionListener(printListener);
    toolbar.add(pasteButton);

    add(toolbar, BorderLayout.NORTH);
}