Example usage for javax.swing JComponent setComponentOrientation

List of usage examples for javax.swing JComponent setComponentOrientation

Introduction

In this page you can find the example usage for javax.swing JComponent setComponentOrientation.

Prototype

public void setComponentOrientation(ComponentOrientation o) 

Source Link

Document

Sets the language-sensitive orientation that is to be used to order the elements or text within this component.

Usage

From source file:Main.java

public static void setFont(JComponent component, Font font, ComponentOrientation componentOrientation) {
    component.setFont(font);/*from   w w  w  .  j a  va2 s  . c om*/

    if (component instanceof JTextField) {
        component.setComponentOrientation(componentOrientation);
    }

    if (component instanceof JTextArea) {
        component.setComponentOrientation(componentOrientation);
    }

    if (component instanceof JTextPane) {
        component.setComponentOrientation(componentOrientation);
    }

    if (component instanceof JScrollPane) {
        for (Component cmp : component.getComponents()) {
            setFont((JComponent) cmp, font, componentOrientation);
        }
    }

    if (component instanceof JTree) {
        component.setComponentOrientation(componentOrientation);
    }

    if (component instanceof JComboBox) {
        component.setComponentOrientation(componentOrientation);
        JComboBox comboBox = (JComboBox) component;
        ((BasicComboBoxRenderer) comboBox.getRenderer()).setHorizontalAlignment(SwingConstants.RIGHT);
        ((BasicComboBoxRenderer) comboBox.getRenderer()).setAutoscrolls(true);
        comboBox.setMaximumRowCount(20);
    }

    /* if(component instanceof JLabel) {
     ((JLabel)component).setHorizontalTextPosition(SwingConstants.RIGHT);
     }*/

    if (component instanceof JPanel) {
        JPanel panel = (JPanel) component;
        if (panel.getBorder() != null && panel.getBorder() instanceof TitledBorder) {
            ((TitledBorder) panel.getBorder()).setTitleFont(font);
            panel.setComponentOrientation(componentOrientation);
        }
        for (Component cmp : component.getComponents()) {
            setFont((JComponent) cmp, font, componentOrientation);
        }
    }

    if (component instanceof JTabbedPane) {
        JTabbedPane tabbedPane = (JTabbedPane) component;
        int tabCount = tabbedPane.getTabCount();
        for (int i = 0; i < tabCount; i++) {
            setFont((JComponent) tabbedPane.getComponentAt(i), font, componentOrientation);
        }
    }
}

From source file:org.freeplane.view.swing.features.filepreview.AudioViewerFactory.java

public JComponent createViewer(final ExternalResource resource, final URI uri, int maximumWidth)
        throws MalformedURLException, IOException {
    String vlcPath = "C:\\Program Files\\VideoLAN\\VLC";
    NativeLibrary.addSearchPath("libvlc", vlcPath);
    System.setProperty("jna.library.path", vlcPath);

    final URI mediaPath = uri;

    JComponent jc = new JPanel();
    jc.setLayout(new GridLayout(3, 2, 5, 10));
    JLabel FileType = new JLabel("FILE TYPE: ");
    JLabel FileName = new JLabel("AUDIO FILE");

    JLabel Title = new JLabel("TITLE: ");
    tField = new TextField(20);
    tField.setEditable(true);/* www.  j a  v a 2  s  .  c  o  m*/
    //tField.setText(new Scanner(new File("fieldSave.txt")).useDelimiter("\\A").next());
    //   JLabel TitleData = new JLabel("________________________");

    JButton TitleButton = new JButton("Save Title");
    JButton playAudio = new JButton("Play Audio");

    jc.add(FileType);
    jc.add(FileName);
    jc.add(Title);
    jc.add(tField);
    //      jc.add(TitleData);
    jc.add(TitleButton);
    jc.add(playAudio);

    playAudio.addActionListener(new PlayAudio(mediaPath, vlcPath));
    TitleButton.addActionListener(new AddTitleData());

    jc.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);

    return jc;
}

From source file:org.freeplane.view.swing.features.filepreview.VideoViewerFactory.java

public JComponent createViewer(final ExternalResource resource, final URI uri, int maximumWidth)
        throws MalformedURLException, IOException {
    String vlcPath = "C:\\Program Files\\VideoLAN\\VLC";
    NativeLibrary.addSearchPath("libvlc", vlcPath);
    System.setProperty("jna.library.path", vlcPath);

    final URI mediaPath = uri;

    JComponent jc = new JPanel();
    jc.setLayout(new GridLayout(3, 2, 5, 10));
    JLabel FileType = new JLabel("FILE TYPE: ");
    JLabel FileName = new JLabel("VIDEO FILE");

    JLabel Title = new JLabel("TITLE: ");
    tField = new TextField(20);
    tField.setEditable(true);//from ww  w . j a  va  2  s.  c  om
    //tField.setText(new Scanner(new File("fieldSave.txt")).useDelimiter("\\A").next());

    //   JLabel TitleData = new JLabel("________________________");

    JButton TitleButton = new JButton("Save Title");
    JButton playVideo = new JButton("Play Video");

    jc.add(FileType);
    jc.add(FileName);
    jc.add(Title);
    jc.add(tField);
    //      jc.add(TitleData);
    jc.add(TitleButton);
    jc.add(playVideo);

    playVideo.addActionListener(new PlayAudio(mediaPath, vlcPath));
    TitleButton.addActionListener(new AddTitleData());

    tField.addActionListener(new AddTitleData());

    jc.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);

    return jc;
}