Listing 4: A locale-sensitive JLabel and the paint method of MLBasicLabelUI

// Create a locale-sensitive label which 
// has a MLBasicLabelUI delegate.
JLabel label = new JLabel();
label.setText("MyApplication.HelloString");

// Taken from MLBasicLabelUI.java 
// which inherits from BasicLabelUI.
public void paint(Graphics g, JComponent c)  {
  JLabel label = (JLabel)c;
  String text = MLUtils.getResourceString(label.getText());

  // Now do the real painting with text.
  ...
}
— End of Listing —