List of usage examples for java.awt FlowLayout LEFT
int LEFT
To view the source code for java.awt FlowLayout LEFT.
Click Source Link
From source file:CheckBoxState.java
public CheckBoxState() { setSize(300, 300);// w w w. j a v a 2 s . c o m setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setLayout(new FlowLayout(FlowLayout.LEFT)); JCheckBox checkBox = new JCheckBox("Check me!"); checkBox.setSelected(true); boolean selected = checkBox.isSelected(); if (selected) { System.out.println("Check box state is selected."); } else { System.out.println("Check box state is not selected."); } getContentPane().add(checkBox); }
From source file:Main.java
public Main() { setSize(300, 300);//w w w . j ava2 s. co m setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setLayout(new FlowLayout(FlowLayout.LEFT)); JCheckBox checkBox = new JCheckBox("Check me!"); checkBox.setSelected(true); // Set default icon for checkbox checkBox.setIcon(new ImageIcon("icon.png")); // Set selected icon when checkbox state is selected checkBox.setSelectedIcon(new ImageIcon("selectedIcon.png")); // Set disabled icon for checkbox checkBox.setDisabledIcon(new ImageIcon("disabledIcon.png")); // Set disabled-selected icon for checkbox checkBox.setDisabledSelectedIcon(new ImageIcon("disabledSelectedIcon.png")); // Set checkbox icon when checkbox is pressed checkBox.setPressedIcon(new ImageIcon("pressedIcon.png")); // Set icon when a mouse is over the checkbox checkBox.setRolloverIcon(new ImageIcon("rolloverIcon.png")); // Set icon when a mouse is over a selected checkbox checkBox.setRolloverSelectedIcon(new ImageIcon("rolloverSelectedIcon.png")); getContentPane().add(checkBox); }
From source file:JCheckBoxCustomIcon.java
public JCheckBoxCustomIcon() { setSize(300, 300);/* www.j a v a 2 s. c o m*/ setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setLayout(new FlowLayout(FlowLayout.LEFT)); JCheckBox checkBox = new JCheckBox("Check me!"); checkBox.setSelected(true); // Set default icon for checkbox checkBox.setIcon(new ImageIcon("icon.png")); // Set selected icon when checkbox state is selected checkBox.setSelectedIcon(new ImageIcon("selectedIcon.png")); // Set disabled icon for checkbox checkBox.setDisabledIcon(new ImageIcon("disabledIcon.png")); // Set disabled-selected icon for checkbox checkBox.setDisabledSelectedIcon(new ImageIcon("disabledSelectedIcon.png")); // Set checkbox icon when checkbox is pressed checkBox.setPressedIcon(new ImageIcon("pressedIcon.png")); // Set icon when a mouse is over the checkbox checkBox.setRolloverIcon(new ImageIcon("rolloverIcon.png")); // Set icon when a mouse is over a selected checkbox checkBox.setRolloverSelectedIcon(new ImageIcon("rolloverSelectedIcon.png")); getContentPane().add(checkBox); }
From source file:Main.java
public Main() throws HeadlessException { setSize(300, 300);//from w w w . j av a2 s . c o m setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setLayout(new FlowLayout(FlowLayout.LEFT)); Icon icon = new ImageIcon("a.png"); JLabel label1 = new JLabel("Full Name :", icon, JLabel.LEFT); JLabel label2 = new JLabel("Address :", JLabel.LEFT); label2.setIcon(new ImageIcon("b.png")); getContentPane().add(label1); getContentPane().add(label2); }
From source file:Main.java
public Main() { setSize(200, 100);/*from ww w . j a v a 2s . co m*/ setDefaultCloseOperation(EXIT_ON_CLOSE); setLayout(new FlowLayout(FlowLayout.LEFT, 4, 4)); 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); add(s); setVisible(true); }
From source file:Main.java
public Main() throws HeadlessException { setSize(400, 200);//ww w . j av a 2 s .c om setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setLayout(new FlowLayout(FlowLayout.LEFT)); JLabel usernameLabel = new JLabel("Username: "); JLabel passwordLabel = new JLabel("Password: "); JTextField usernameField = new JTextField(20); JPasswordField passwordField = new JPasswordField(20); usernameLabel.setDisplayedMnemonic(KeyEvent.VK_U); usernameLabel.setLabelFor(usernameField); passwordLabel.setDisplayedMnemonic(KeyEvent.VK_P); passwordLabel.setLabelFor(passwordField); getContentPane().add(usernameLabel); getContentPane().add(usernameField); getContentPane().add(passwordLabel); getContentPane().add(passwordField); }
From source file:Main.java
public Main() { setSize(200, 100);//from w w w.ja v a 2s.c om 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:Main.java
public Main() throws HeadlessException { setSize(200, 200);//from w w w . j a v a 2s . c om setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setLayout(new FlowLayout(FlowLayout.LEFT)); JLabel usernameLabel = new JLabel("Username: "); JTextField usernameTextField = new JTextField(); usernameTextField.setPreferredSize(new Dimension(100, 20)); add(usernameLabel); add(usernameTextField); usernameTextField.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent e) { JTextField textField = (JTextField) e.getSource(); String text = textField.getText(); textField.setText(text.toUpperCase()); } public void keyTyped(KeyEvent e) { } public void keyPressed(KeyEvent e) { } }); }
From source file:Main.java
public Main() { super("Month Spinner"); setSize(200, 100);/* w w w .j av 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 ww w.jav a2 s. c om*/ 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.getNextValue()); }