Hey guys, I'm having some problems with getting my app to display correctly with RTL (RIGHT_TO_LEFT) orienation. The two components giving me the biggest headache are JScrollPane and JFrame. Im using java 1.4 and setting applyComponentOrientation(ComponentOrienation.RIGHT_TO_LEFT) on all the components.
When I do an set orientation on my JScrollPane the scrollbars switch sides as their supposed to, but they view still starts out on the top left side. Since the orienation is RTL I want the horizontal scrollbar to be all the way to the right when the component becomes visual (top-right corner). I see in the API that JScrollPane has its own setComponentOrienation and this is supposed to effect the scrollbars but after trying it I still got the upper left corner.
The second issue is JFrame. I also set orienation on this component and looking at sun's documentation its supposed to be fully compatable with orienation. In all my examples I am still getting a frame with the title on the left and the min/max/close buttons on the right.
This is just a quick mock up of code that illustrates both my problems:
Can anybody help me with both or either of these components? Thanks in advance.
Kris McCuller
When I do an set orientation on my JScrollPane the scrollbars switch sides as their supposed to, but they view still starts out on the top left side. Since the orienation is RTL I want the horizontal scrollbar to be all the way to the right when the component becomes visual (top-right corner). I see in the API that JScrollPane has its own setComponentOrienation and this is supposed to effect the scrollbars but after trying it I still got the upper left corner.
The second issue is JFrame. I also set orienation on this component and looking at sun's documentation its supposed to be fully compatable with orienation. In all my examples I am still getting a frame with the title on the left and the min/max/close buttons on the right.
This is just a quick mock up of code that illustrates both my problems:
Code:
import javax.swing.*;
import java.awt.*;
import javax.swing.plaf.basic.BasicComboBoxRenderer;
public class OrTest extends JFrame {
public OrTest() {
super("Frame Title");
setSize(300,100);
setLocation(200,150);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel pane = new JPanel();
JScrollPane jsp = new JScrollPane();
JLabel lbl = new JLabel("This is a very long piece of text so that I can test JScrollPane's ability to do right to left orientation. The scroll bar should set the viewing area all the way to the right hand side of this label.");
applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
pane.applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
//jsp.applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
jsp.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
lbl.applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
pane.add(lbl);
jsp.setViewportView(pane);
setContentPane(jsp);
setVisible(true);
}
public static void main(String[] args) {
OrTest ot = new OrTest();
}
}
Can anybody help me with both or either of these components? Thanks in advance.
Kris McCuller