Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support RTL #350

Closed
Abu-Abdullah opened this issue Jul 7, 2021 · 10 comments
Closed

Support RTL #350

Abu-Abdullah opened this issue Jul 7, 2021 · 10 comments
Milestone

Comments

@Abu-Abdullah
Copy link

Hi,

i have an issue of having 'JOptionPane.showOptionDialog' RTL when the parentComponent is JInternalFrame/JDesktopPane, it is still displayed LTR.

just to mentioned it is working correctly using the metal or any internal LnF

@DevCharly
Copy link
Collaborator

DevCharly commented Jul 7, 2021

And it works if the parent is of another type?

Could you post a screenshot?

I can not reproduce it...

@Abu-Abdullah
Copy link
Author

please find:
FlatLaf
Capture

Metal
Capture1

JOptionPane seems to work fine when parent is JFrame. I'm still checking the case.

@Abu-Abdullah
Copy link
Author

sorry, the Text Area inside the JOptionPane has the issue

@DevCharly
Copy link
Collaborator

The first and last lines are right aligned. So it seems that the dialog/textarea width is too small and the text is wrapped...

@Abu-Abdullah
Copy link
Author

you are right, but how can we make the wrapped text RTL

@DevCharly
Copy link
Collaborator

how can we make the wrapped text RTL

Good question. I don't know...

Can you please give me some details on how you pass the text to the option pane.
Is it a single string? And does it contain line separators?
Or is it a special JTextArea or any other custom component?

@Abu-Abdullah
Copy link
Author

yes, im using in the message System.lineSeparator() to seperate the lines. no special components

@DevCharly
Copy link
Collaborator

The option pane has the ability to wrap longer lines.
This is disabled in most/all LaFs.
But in FlatLaf it is enabled and wraps at 80 characters per line.
Maybe this causes the problem.

Please try adding following to disable wrapping (after setting FlatLaf):

UIManager.put( "OptionPane.maxCharactersPerLine", 0 );

@Abu-Abdullah
Copy link
Author

thank you, this solved it

DevCharly added a commit that referenced this issue Jul 8, 2021
@DevCharly
Copy link
Collaborator

It turned out that this is a bug in JOptionPane. When wrapping longer text the option pane creates a label for each line and puts those labels into a vertical Box that uses BoxLayout.Y_AXIS. This aligns the labels always to the left. If option pane would use BoxLayout.PAGE_AXIS, then the labels would be aligned to the right in RTL or to the left in LTR.

Anyway, I've implemented a fix in FlatLaf.

@DevCharly DevCharly added this to the 1.4 milestone Jul 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants