jide-oss icon indicating copy to clipboard operation
jide-oss copied to clipboard

JideTabbedPane in right-to-left component orientation

Open hakanai opened this issue 8 years ago • 0 comments

An Arabic user noticed that the tab close buttons were on the left of the tabs, but thought they should be on the right.

I'm not sure whether the user is right or not, so I'm passing the question upwards. JIDE currently puts them on the left because it's the reverse of where they would be for a left-to-right layout. But sometimes in right-to-left UIs, things are not reversed. I wasn't able to quickly find any literature describing the correct behaviour for tab close buttons, so all I have to go on is this one user's comment.

Test program:

import java.awt.BorderLayout;
import java.awt.ComponentOrientation;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.WindowConstants;

import com.jidesoft.swing.JideTabbedPane;

public class TestRtlTab implements Runnable {
    public static void main(String[] args) {
        System.setProperty("user.language", "ar");
        System.setProperty("user.country", "SA");

        SwingUtilities.invokeLater(new TestRtlTab());
    }

    @Override
    public void run() {
        showFrame("Left-to-Right", ComponentOrientation.LEFT_TO_RIGHT);
        showFrame("Right-to-Left", ComponentOrientation.RIGHT_TO_LEFT);
    }

    private void showFrame(String title, ComponentOrientation componentOrientation) {
        JideTabbedPane tabs = new JideTabbedPane();
        tabs.setShowCloseButtonOnTab(true);
        tabs.add("Tab 1", new JPanel());
        tabs.add("Tab 2", new JPanel());
        tabs.setComponentOrientation(componentOrientation);

        JPanel content = new JPanel();
        content.setLayout(new BorderLayout());
        content.add(tabs, BorderLayout.CENTER);
        content.setComponentOrientation(componentOrientation);

        JFrame frame = new JFrame(title);
        frame.setContentPane(content);
        frame.setComponentOrientation(componentOrientation);

        frame.pack();
        frame.setSize(500, 400);
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.setVisible(true);
    }
}

hakanai avatar Feb 21 '17 00:02 hakanai