Jump to content

Simple text presentation with swing.

- - - - -

  • Please log in to reply
No replies to this topic

#1
Turk4n

Turk4n

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 3,847 posts
Here you go, no need to explain done it for people who just needs it...
import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

public class Jhello extends JFrame implements ActionListener {

	

	/**

	 * 

	 */

	private static final long serialVersionUID = 1L;

	JTextField answer = new JTextField(25);

	JLabel welcoming = new JLabel();

	

	public Jhello () {

		setLayout(new FlowLayout());

		add(new JLabel("What is your name? ", JLabel.CENTER));

		add(answer);

		add(welcoming);

		welcoming.setHorizontalAlignment(JLabel.CENTER);

		answer.addActionListener(this);

		setSize(350, 105);

		setVisible(true);

		setDefaultCloseOperation(EXIT_ON_CLOSE);

	}

	public static void main (String[] arg) {

		new Jhello();

	}

	public void actionPerformed(ActionEvent e) {

		String namne = answer.getText();

		welcoming.setText("Welcome " + namne + "!");

	}

}


Posted Image




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users