Code tagged with swing

HelloWorld with Swing

Posted by Chad Humphries over 2 years ago
// Creates a HelloWorld using Swing. The code uses the class JOptionPane to create 
// a Input dialog that read a value, then shows a message dialog that show a message 
// with the value.

public class HelloJavaJOP {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		 
		String nome = JOptionPane.showInputDialog("Digite seu nome");
		String mensagem = null; 
		
		if (nome !=  null && !nome.equals("")) {
			mensagem = "Bem-vindo ao mundo Java, " + nome + "!";
		} else {
			mensagem = "Bem-vindo ao mundo Java, USUARIO";
		}
		
		JOptionPane.showMessageDialog(null, mensagem);	
	}
}
Language Java / Tagged with swing