package helloworld;

import javax.swing.*;
import java.awt.*;
import java.io.*;
import java.awt.event.*;

public class GUIWorld extends JFrame {
	
	public GUIWorld()  {
		JButton label = new JButton(getText(),getGlobe());
		label.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				System.exit(0);
			}
		});
		getContentPane().add(label);
		pack();
		setLocation(100,100); 
		addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent e) {
				System.exit(0);
			}
		});
		
		show();
	}

	public ImageIcon getGlobe()  {
		return null;
	}

	public String getText()  {
		try {
			PipedOutputStream out = new PipedOutputStream();
			PipedInputStream in = new PipedInputStream(out);
			System.setOut(new PrintStream(out));
			BufferedReader reader = new BufferedReader(new InputStreamReader(in));
			String[] args = new String[0];
			HelloWorld.main(args);
			return reader.readLine(); }
		catch (IOException ex) {
			return "Error: Check your HelloWorld"; }
	}

	public static void main(String [] args)  {
		new GUIWorld();
	}

}
