I hope the code below will be useful, just know two points:
1. You need to set the Locale generally in OS or
statically in your application ( which i did in this code)
2. Change the ComponentOrientation according to the language
orientation. Notice that you should do it for each frame created
in your application.
import java.awt.Toolkit;
import java.awt.Dimension;
import java.util.*;
import java.awt.*;
public class Application1 {
boolean packFrame = false;
/**
* Construct and show the application.
*/
public Application1() {
// 1. Set the locale
Locale persianLocal = new Locale("fa", "IR");
Locale.setDefault(persianLocal);
Frame1 frame = new Frame1();
// Validate frames that have preset sizes
// Pack frames that have useful preferred size info, e.g.
from their layout
if (packFrame) {
frame.pack();
} else {
frame.validate();
}
// Center the window
Dimension screenSize = Toolkit.getDefaultToolkit
().getScreenSize();
Dimension frameSize = frame.getSize();
if (frameSize.height > screenSize.height) {
frameSize.height = screenSize.height;
}
if (frameSize.width > screenSize.width) {
frameSize.width = screenSize.width;
}
frame.setLocation((screenSize.width - frameSize.width) / 2,
(screenSize.height - frameSize.height) / 2);
// 2. Change the ComponentOrientation
frame.applyComponentOrientation
(ComponentOrientation.RIGHT_TO_LEFT);
frame.setVisible(true);
}
public static void main(String[] args) {
new Application1();
}
}