<Swing Dev> Setting a component orientation in JRSUI
Artem Ananiev
artem.ananiev at oracle.com
Mon Feb 3 15:47:25 UTC 2014
Adding java-dev at apple alias to CC.
Artem
On 1/22/2014 7:23 PM, Alexander Scherbatiy wrote:
>
> Hello,
>
> Below is the code that shows that setting a component orientation for
> the JProgressBar in Aqua L&F does not work.
>
> My assumption was that the Direction should be properly set to the
> painter state in the AquaProgressBarUI like:
> -----------------------------
> public void paint(final Graphics g, final JComponent c) {
> ...
> painter.state.set(c.getComponentOrientation().isLeftToRight() ?
> Direction.RIGHT : Direction.LEFT);
> }
> -----------------------------
> but it does not work.
>
> The painter calls the JRSUI library to show components on Mac OS X.
>
> Is there any specification for the JRSUI library?
> What is the right way to set the component direction in the JRSUI.
>
> Thanks,
> Alexandr.
>
>
> ------------------ Code Sample ----------
> import java.awt.*;
> import java.awt.event.*;
> import javax.swing.*;
>
> public class JProgressBarOrientationTest {
>
> static boolean leftToRight = true;
>
> public static void main(String[] args) throws Exception {
>
> SwingUtilities.invokeLater(new Runnable() {
>
> @Override
> public void run() {
> JFrame frame = new JFrame();
> frame.setSize(300, 200);
>
> final JProgressBar progressBar = new JProgressBar(0, 100);
> progressBar.setValue(30);
> progressBar.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
>
> JButton button = new JButton("Change orientation");
> button.addActionListener(new ActionListener() {
>
> @Override
> public void actionPerformed(ActionEvent e) {
> leftToRight = !leftToRight;
> progressBar.setComponentOrientation(leftToRight ?
> ComponentOrientation.LEFT_TO_RIGHT : ComponentOrientation.RIGHT_TO_LEFT);
> }
> });
>
> JPanel panel = new JPanel(new BorderLayout());
> panel.add(progressBar, BorderLayout.CENTER);
> panel.add(button, BorderLayout.SOUTH);
> frame.getContentPane().add(panel);
> frame.setVisible(true);
> }
> });
> }
> }
> -------------------------------------
More information about the swing-dev
mailing list