java.awt.ComponentOrientation Java Examples

The following examples show how to use java.awt.ComponentOrientation. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BasicTest.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
static void TestInvariants() {
    System.out.println("  TestInvariants {");

    Assert(ComponentOrientation.LEFT_TO_RIGHT.isLeftToRight(),
           "LEFT_TO_RIGHT.isLeftToRight()");

    Assert(ComponentOrientation.UNKNOWN.isLeftToRight(),
           "UNKNOWN.isLeftToRight()");

    Assert(!ComponentOrientation.RIGHT_TO_LEFT.isLeftToRight(),
           "!RIGHT_TO_LEFT.isLeftToRight()");

    Assert(ComponentOrientation.LEFT_TO_RIGHT.isHorizontal(),
           "LEFT_TO_RIGHT.isHorizontal()");

    Assert(ComponentOrientation.UNKNOWN.isHorizontal(),
           "UNKNOWN.isHorizontal()");

    Assert(ComponentOrientation.RIGHT_TO_LEFT.isHorizontal(),
           "RIGHT_TO_LEFT.isHorizontal()");

    System.out.println("  } Pass");
}
 
Example #2
Source File: TextualDocumentView.java    From gate-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Set the text orientation in the document.
 * 
 * @param orientation either left to right or right to left
 */
public void changeOrientation(ComponentOrientation orientation) {
  // set the orientation
  textView.setComponentOrientation(orientation);

  try {
    // disable the listener
    document.removeDocumentListener(gateDocListener);
    // this is required as eventhough orientation gets applied,
    // the screen is not updated unless a character input is
    // detected by the textView
    textView.insert("a", 0);
    textView.replaceRange("", 0, 1);
  }
  finally {
    // enabling the listener again
    document.addDocumentListener(gateDocListener);
  }


}
 
Example #3
Source File: ContainerFocusAutoTransferTest.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public TestFrame() {
    super("TestFrame");

    // The change of the orientation and the reverse order of
    // adding the buttons to the panel is because in Container.removeNotify()
    // the child components are removed in the reverse order.
    // We want that the focus owner (b0) would be removed first and
    // that the next traversable component would be b1.
    panel0.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
    panel0.add(b2);
    panel0.add(b1);
    panel0.add(b0);

    panel1.add(b3);
    panel1.add(b4);

    setLayout(new FlowLayout());
    add(panel0);
    add(panel1);
    pack();

    panel0.setBackground(Color.red);
    panel1.setBackground(Color.blue);
}
 
Example #4
Source File: AbstractWikiSettings.java    From wpcleaner with Apache License 2.0 6 votes vote down vote up
/**
 * @param language Language.
 * @param name Name.
 * @param hosts List of possible host names.
 * @param apiPath Path for the API, relative to the host URL.
 * @param indexPath Path for index.php, relative to the host URL.
 * @param code Code for the wiki.
 * @param codeCheckWiki CW code for the wiki.
 * @param orientation Text orientation.
 */
public AbstractWikiSettings(
    String language, String name,
    String[] hosts, String apiPath, String indexPath,
    String code, String codeCheckWiki,
    ComponentOrientation orientation) {
  this.language = language;
  this.name = name;
  this.hosts = hosts;
  this.apiPath = apiPath;
  String host = hosts[0];
  this.apiUrl = "http://" + host + apiPath;
  this.securedApiUrl = "https://" + host + apiPath;
  this.indexPath = indexPath;
  this.indexUrl = "http://" + host + indexPath;
  this.securedIndexUrl = "https://" + host + indexPath;
  this.code = code;
  this.codeCheckWiki = codeCheckWiki;
  this.orientation = orientation;
}
 
Example #5
Source File: ChangeComponentOrientation.java    From Hotel-Properties-Management-System with GNU General Public License v2.0 6 votes vote down vote up
public void changeOrientationOfJPanelToLeft() {
    
    thePanel.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
    Component panelComponents[] = thePanel.getComponents();
    
    for (int i = 0; i < panelComponents.length; i++) {
        
        if(panelComponents[i] instanceof JPanel) {
            JPanel panel = (JPanel) panelComponents[i];
            if(!panel.getComponentOrientation().isLeftToRight()) {
                panel.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
            }
        }
        
        if(panelComponents[i] instanceof JButton) {
            JButton button = (JButton) panelComponents[i];
            if(!button.getComponentOrientation().isLeftToRight()) {
                button.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
            }
        }
    }
}
 
Example #6
Source File: JFileChooserOrientation.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private static void showFileChooser() throws Exception {
    if (tryLookAndFeel(lookAndFeelComboBox.getSelectedItem().toString())) {

        openChooser = new JFileChooser();

        ComponentOrientation orientation
                = ComponentOrientation.UNKNOWN;

        switch (orientationComboBox.getSelectedItem().toString()) {
            case orientationLTR:
                orientation = ComponentOrientation.LEFT_TO_RIGHT;
                break;
            case orientationRTL:
                orientation = ComponentOrientation.RIGHT_TO_LEFT;
                break;
        }
        openChooser.setComponentOrientation(orientation);
        openChooser.showOpenDialog(frame);

    }
}
 
Example #7
Source File: Test6526631.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public void validateThird() {
    JViewport viewport = this.pane.getViewport();
    JScrollBar scroller = this.pane.getHorizontalScrollBar();
    if (!scroller.getComponentOrientation().equals(ComponentOrientation.RIGHT_TO_LEFT)) {
        throw new Error("unexpected component orientation");
    }
    int value = scroller.getValue();
    if (value != 0) {
        throw new Error("unexpected scroll value");
    }
    int extent = viewport.getExtentSize().width;
    if (extent != scroller.getVisibleAmount()) {
        throw new Error("unexpected visible amount");
    }
    int size = viewport.getViewSize().width;
    if (size != scroller.getMaximum()) {
        throw new Error("unexpected maximum");
    }
    int pos = size - extent - value;
    if (pos != viewport.getViewPosition().x) {
        throw new Error("unexpected position");
    }
}
 
Example #8
Source File: Test6526631.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
public void validateThird() {
    JViewport viewport = this.pane.getViewport();
    JScrollBar scroller = this.pane.getHorizontalScrollBar();
    if (!scroller.getComponentOrientation().equals(ComponentOrientation.RIGHT_TO_LEFT)) {
        throw new Error("unexpected component orientation");
    }
    int value = scroller.getValue();
    if (value != 0) {
        throw new Error("unexpected scroll value");
    }
    int extent = viewport.getExtentSize().width;
    if (extent != scroller.getVisibleAmount()) {
        throw new Error("unexpected visible amount");
    }
    int size = viewport.getViewSize().width;
    if (size != scroller.getMaximum()) {
        throw new Error("unexpected maximum");
    }
    int pos = size - extent - value;
    if (pos != viewport.getViewPosition().x) {
        throw new Error("unexpected position");
    }
}
 
Example #9
Source File: Test6526631.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public void validateThird() {
    JViewport viewport = this.pane.getViewport();
    JScrollBar scroller = this.pane.getHorizontalScrollBar();
    if (!scroller.getComponentOrientation().equals(ComponentOrientation.RIGHT_TO_LEFT)) {
        throw new Error("unexpected component orientation");
    }
    int value = scroller.getValue();
    if (value != 0) {
        throw new Error("unexpected scroll value");
    }
    int extent = viewport.getExtentSize().width;
    if (extent != scroller.getVisibleAmount()) {
        throw new Error("unexpected visible amount");
    }
    int size = viewport.getViewSize().width;
    if (size != scroller.getMaximum()) {
        throw new Error("unexpected maximum");
    }
    int pos = size - extent - value;
    if (pos != viewport.getViewPosition().x) {
        throw new Error("unexpected position");
    }
}
 
Example #10
Source File: ContainerFocusAutoTransferTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public TestFrame() {
    super("TestFrame");

    // The change of the orientation and the reverse order of
    // adding the buttons to the panel is because in Container.removeNotify()
    // the child components are removed in the reverse order.
    // We want that the focus owner (b0) would be removed first and
    // that the next traversable component would be b1.
    panel0.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
    panel0.add(b2);
    panel0.add(b1);
    panel0.add(b0);

    panel1.add(b3);
    panel1.add(b4);

    setLayout(new FlowLayout());
    add(panel0);
    add(panel1);
    pack();

    panel0.setBackground(Color.red);
    panel1.setBackground(Color.blue);
}
 
Example #11
Source File: WikiSkripta.java    From wpcleaner with Apache License 2.0 5 votes vote down vote up
/**
 * Default constructor.
 */
public WikiSkripta() {
  super(
      "cs", "WikiSkripta",
      new String[] {
          "www.wikiskripta.eu",
      },
      "/api.php", "/index.php",
      "wikiskripta", null,
      ComponentOrientation.LEFT_TO_RIGHT);
}
 
Example #12
Source File: Wikivoyage.java    From wpcleaner with Apache License 2.0 5 votes vote down vote up
/**
 * @param language Language.
 * @param name Name.
 * @param orientation Text orientation.
 */
public Wikivoyage(
    String language,
    String name,
    ComponentOrientation orientation) {
  super(
      language, name,
      new String[] {
          language + ".wikivoyage.org",
      },
      "/w/api.php", "/w/index.php",
      "voy:" + language, language + "wikivoyage",
      orientation);
}
 
Example #13
Source File: ComponentOperator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Maps {@code Component.getComponentOrientation()} through queue
 */
public ComponentOrientation getComponentOrientation() {
    return (runMapping(new MapAction<ComponentOrientation>("getComponentOrientation") {
        @Override
        public ComponentOrientation map() {
            return getSource().getComponentOrientation();
        }
    }));
}
 
Example #14
Source File: RuleParametersView.java    From hortonmachine with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Method for recalculating the component orientation for 
 * right-to-left Locales.
 * @param orientation the component orientation to be applied
 */
public void applyComponentOrientation( ComponentOrientation orientation )
{
   // Not yet implemented...
   // I18NUtils.applyComponentOrientation(this, orientation);
   super.applyComponentOrientation(orientation);
}
 
Example #15
Source File: TextSymbolizerView.java    From hortonmachine with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Method for recalculating the component orientation for 
 * right-to-left Locales.
 * @param orientation the component orientation to be applied
 */
public void applyComponentOrientation( ComponentOrientation orientation )
{
   // Not yet implemented...
   // I18NUtils.applyComponentOrientation(this, orientation);
   super.applyComponentOrientation(orientation);
}
 
Example #16
Source File: Wikisource.java    From wpcleaner with Apache License 2.0 5 votes vote down vote up
/**
 * @param language Language.
 * @param name Name.
 * @param orientation Text orientation.
 */
public Wikisource(
    String language,
    String name,
    ComponentOrientation orientation) {
  super(
      language, name,
      new String[] {
          language + ".wikisource.org",
      },
      "/w/api.php", "/w/index.php",
      "s:" + language, language + "wikisource",
      orientation);
}
 
Example #17
Source File: ChangeComponentOrientation.java    From Hotel-Properties-Management-System with GNU General Public License v2.0 5 votes vote down vote up
public void changeOrientationOfJMenubarToRight() {
      theMenuBar.applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
    for (int i = 0; i < theMenuBar.getComponentCount(); i++) {
        if (theMenuBar.getComponent(i).getComponentOrientation().isLeftToRight()) {
            theMenuBar.getComponent(i).applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
            theMenuBar.revalidate();
            theMenuBar.repaint();
        }
    }
}
 
Example #18
Source File: ChangeComponentOrientation.java    From Hotel-Properties-Management-System with GNU General Public License v2.0 5 votes vote down vote up
public void changeOrientationOfJFrameToLeft() {
    theFrame.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
    for (int i = 0; i < theFrame.getContentPane().getComponentCount(); i++) {
        if (!theFrame.getContentPane().getComponent(i).getComponentOrientation().isLeftToRight()) {
            theFrame.getContentPane().getComponent(i).setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
            theFrame.revalidate();
            theFrame.repaint();
        }
    }

}
 
Example #19
Source File: Waze.java    From wpcleaner with Apache License 2.0 5 votes vote down vote up
/**
 * Default constructor.
 */
public Waze() {
  super(
      "en", "Waze",
      new String[] {
          "wiki.waze.com",
      },
      "/wiki/api.php", "/wiki/index.php",
      "waze", null,
      ComponentOrientation.LEFT_TO_RIGHT);
}
 
Example #20
Source File: LogConsoleView.java    From hortonmachine with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Method for recalculating the component orientation for 
 * right-to-left Locales.
 * @param orientation the component orientation to be applied
 */
public void applyComponentOrientation( ComponentOrientation orientation )
{
   // Not yet implemented...
   // I18NUtils.applyComponentOrientation(this, orientation);
   super.applyComponentOrientation(orientation);
}
 
Example #21
Source File: BasicTest.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
static void TestLocale() {
    System.out.println("  TestLocale {");

    ComponentOrientation orient = ComponentOrientation.getOrientation(Locale.US);
    Assert(orient == ComponentOrientation.LEFT_TO_RIGHT, "US == LEFT_TO_RIGHT");

    orient = ComponentOrientation.getOrientation(new Locale("iw", ""));
    Assert(orient == ComponentOrientation.RIGHT_TO_LEFT, "iw == RIGHT_TO_LEFT");

    orient = ComponentOrientation.getOrientation(new Locale("ar", ""));
    Assert(orient == ComponentOrientation.RIGHT_TO_LEFT, "ar == RIGHT_TO_LEFT");

    System.out.println("  } Pass");
}
 
Example #22
Source File: FormBuilderView.java    From hortonmachine with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Method for recalculating the component orientation for 
 * right-to-left Locales.
 * @param orientation the component orientation to be applied
 */
public void applyComponentOrientation( ComponentOrientation orientation )
{
   // Not yet implemented...
   // I18NUtils.applyComponentOrientation(this, orientation);
   super.applyComponentOrientation(orientation);
}
 
Example #23
Source File: BasicTest.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
static void TestBundle() {
    System.out.println("  TestBundle {");

    // This will fall back to the default locale's bundle or root bundle
    ResourceBundle rb = ResourceBundle.getBundle("TestBundle",
                                                    new Locale("et", ""));
    if (rb.getLocale().getLanguage().equals(new Locale("iw").getLanguage())) {
        assertEquals(rb, ComponentOrientation.RIGHT_TO_LEFT, "et == RIGHT_TO_LEFT" );
    } else if (rb.getLocale().getLanguage() == "es") {
        assertEquals(rb, ComponentOrientation.LEFT_TO_RIGHT, "et == LEFT_TO_RIGHT" );
    } else {
        assertEquals(rb, ComponentOrientation.UNKNOWN, "et == UNKNOWN" );
    }

    // We have actual bundles for "es" and "iw", so it should just fetch
    // the orientation object out of them
    rb = ResourceBundle.getBundle("TestBundle",new Locale("es", ""));
    assertEquals(rb, ComponentOrientation.LEFT_TO_RIGHT, "es == LEFT_TO_RIGHT" );

    rb = ResourceBundle.getBundle("TestBundle", new Locale("iw", "IL"));
    assertEquals(rb, ComponentOrientation.RIGHT_TO_LEFT, "iw == RIGHT_TO_LEFT" );

    // This bundle has no orientation setting at all, so we should get
    // the system's default orientation for Arabic
    rb = ResourceBundle.getBundle("TestBundle1", new Locale("ar", ""));
    assertEquals(rb, ComponentOrientation.RIGHT_TO_LEFT, "ar == RIGHT_TO_LEFT" );

    System.out.println("  } Pass");
}
 
Example #24
Source File: SpatialtoolboxView.java    From hortonmachine with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Method for recalculating the component orientation for 
 * right-to-left Locales.
 * @param orientation the component orientation to be applied
 */
public void applyComponentOrientation( ComponentOrientation orientation )
{
   // Not yet implemented...
   // I18NUtils.applyComponentOrientation(this, orientation);
   super.applyComponentOrientation(orientation);
}
 
Example #25
Source File: RasterStyleView.java    From hortonmachine with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Method for recalculating the component orientation for 
 * right-to-left Locales.
 * @param orientation the component orientation to be applied
 */
public void applyComponentOrientation( ComponentOrientation orientation )
{
   // Not yet implemented...
   // I18NUtils.applyComponentOrientation(this, orientation);
   super.applyComponentOrientation(orientation);
}
 
Example #26
Source File: Test6526631.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public Test6526631(JFrame frame) {
    this.pane = new JScrollPane(new JTextArea(ROWS, COLS));
    this.pane.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
    this.frame = frame;
    this.frame.add(this.pane);
}
 
Example #27
Source File: LayoutComparator.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
void setComponentOrientation(ComponentOrientation orientation) {
    horizontal = orientation.isHorizontal();
    leftToRight = orientation.isLeftToRight();
}
 
Example #28
Source File: JMenu.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
public void setComponentOrientation(ComponentOrientation o) {
    super.setComponentOrientation(o);
    if ( popupMenu != null ) {
        popupMenu.setComponentOrientation(o);
    }
}
 
Example #29
Source File: TestBundle_es.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
protected Object[][] getContents() {
    return new Object[][] {
        { "Orientation", ComponentOrientation.LEFT_TO_RIGHT },
    };
}
 
Example #30
Source File: JMenu.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public void setComponentOrientation(ComponentOrientation o) {
    super.setComponentOrientation(o);
    if ( popupMenu != null ) {
        popupMenu.setComponentOrientation(o);
    }
}