Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Problem in create right alignment form

  Asked By: Juana    Date: Jun 29    Category: Java    Views: 3924

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");

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) {
} else {

// Center the window
Dimension screenSize = Toolkit.getDefaultToolkit
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


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



1 Answer Found

Answer #1    Answered By: Flynn Jones     Answered On: Jun 29

change your <body> tag to <body dir="rtl"> . it may helps.

Didn't find what you were looking for? Find more on Problem in create right alignment form Or get search suggestion and latest updates.