List of usage examples for java.awt FlowLayout FlowLayout
public FlowLayout(int align)
From source file:Main.java
public Main() throws HeadlessException { setSize(300, 300);// ww w .ja v a 2 s .c om 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() throws HeadlessException { setSize(400, 200);//from w ww .ja v a 2s. c o m 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() { this.setSize(400, 100); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setLayout(new FlowLayout(FlowLayout.CENTER)); JButton button = new JButton("Change Frame Color"); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Component component = (Component) e.getSource(); JFrame frame = (JFrame) SwingUtilities.getRoot(component); frame.setBackground(Color.RED); }/*from ww w . ja va 2s . c o m*/ }); this.getContentPane().add(button); }
From source file:Main.java
public Main() { this.setSize(400, 100); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setLayout(new FlowLayout(FlowLayout.CENTER)); JButton button = new JButton("Change Frame Color"); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Component component = (Component) e.getSource(); JFrame frame = (JFrame) SwingUtilities.getRoot(component); frame.getContentPane().setBackground(Color.RED); }/*from w w w. j a v a 2 s.com*/ }); this.getContentPane().add(button); }
From source file:Main.java
public Main() throws HeadlessException { setSize(300, 300);/*from ww w.ja va 2 s .c o m*/ setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); getContentPane().setLayout(new FlowLayout(FlowLayout.CENTER)); JButton disable = new JButton("DISABLE"); disable.setToolTipText("disabled."); disable.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { ToolTipManager.sharedInstance().setEnabled(false); } }); JButton enable = new JButton("ENABLE"); enable.setToolTipText("enabled."); enable.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { ToolTipManager.sharedInstance().setEnabled(true); } }); getContentPane().add(enable); getContentPane().add(disable); }
From source file:Main.java
public Main() throws HeadlessException { setSize(200, 200);//from w w w.jav a2 s . c o m 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() throws HeadlessException { setSize(200, 200);/* w ww .j a v a2s . c o 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();/*from w w w . j ava 2 s. c om*/ 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 2 s . co 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:Main.java
public Main() throws HeadlessException { this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); JButton button = new JButton("Close"); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(0);/*from ww w. ja v a 2 s. co m*/ } }); this.setLayout(new FlowLayout(FlowLayout.CENTER)); this.setSize(new Dimension(100, 100)); this.getContentPane().add(button); }