import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.Locale;
import java.util.ResourceBundle;
import java.util.ResourceBundle.*;

public class ResourceDemo extends JFrame {
    
    protected ResourceBundle bundle;
    
    public ResourceDemo() {
	Container cp = getContentPane();
	cp.setLayout(new GridLayout(2,0));
	//Locale locale = Locale.getDefault();
	//resourceContents = ResourceBundle.getBundle("MyResources",locale);
	bundle = ResourceBundle.getBundle("MyResources");
	try 
	    {
		JPanel thePanel = (JPanel)bundle.getObject("Everything");
		setContentPane(thePanel);
	    }
	catch (Exception e) {   // "Everything" not defined...
	    String helloWorldString = bundle.getString("helloWorldString");
	    cp.add(new JLabel(helloWorldString));
	    JButton byeButton = new JButton(bundle.getString("goodbyeWorldString"));
	    cp.add(byeButton);
	    byeButton.addActionListener(new ActionListener() {
		    public void actionPerformed(ActionEvent e) {
			System.exit(0);
		    }});
	}
    }
    
    public static void main(String[] args) {
	ResourceDemo f = new ResourceDemo();
	f.setSize(300,300);
	f.setVisible(true);
	f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }

}
