當前位置: 首頁>>代碼示例>>Java>>正文


Java ComponentOrientation.RIGHT_TO_LEFT屬性代碼示例

本文整理匯總了Java中java.awt.ComponentOrientation.RIGHT_TO_LEFT屬性的典型用法代碼示例。如果您正苦於以下問題:Java ComponentOrientation.RIGHT_TO_LEFT屬性的具體用法?Java ComponentOrientation.RIGHT_TO_LEFT怎麽用?Java ComponentOrientation.RIGHT_TO_LEFT使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在java.awt.ComponentOrientation的用法示例。


在下文中一共展示了ComponentOrientation.RIGHT_TO_LEFT屬性的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: showFileChooser

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);

    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:21,代碼來源:JFileChooserOrientation.java

示例2: buildStepTitle

protected void buildStepTitle()
{
    ttlLabel = new JLabel(wizard.getStepDescription(wizard.getAllSteps()[0]));
    ttlLabel.setBorder(BorderFactory.createCompoundBorder(BorderFactory
        .createEmptyBorder(5, 5, 12, 5), BorderFactory.createMatteBorder(0, 0, 1, 0, UIManager
        .getColor("textText")))); // NOI18N
    ttlPanel = new JPanel()
    {
        private static final long serialVersionUID = 1L;
        public void doLayout()
        {
            Dimension d = ttlLabel.getPreferredSize();
            if (ttlLabel.getComponentOrientation() == ComponentOrientation.RIGHT_TO_LEFT)
            {
                ttlLabel.setBounds(getWidth() - d.width, 0, getWidth(), d.height);
            }
            else
            {
                ttlLabel.setBounds(0, 0, getWidth(), d.height);
            }
        }

        public Dimension getPreferredSize()
        {
            return ttlLabel.getPreferredSize();
        }
    };
    ttlPanel.add(ttlLabel);
    Font f = ttlLabel.getFont();
    if (f == null)
    {
        f = UIManager.getFont("controlFont"); // NOI18N
    }
    if (f != null)
    {
        f = f.deriveFont(Font.BOLD);
        ttlLabel.setFont(f);
    }

}
 
開發者ID:ajmath,項目名稱:VASSAL-src,代碼行數:40,代碼來源:WizardDisplayerImpl.java

示例3: getPosition

private int getPosition(int x, int width) {
    if (getComponentOrientation() == ComponentOrientation.RIGHT_TO_LEFT) {
        return width - x ;
    } else {
        return x;
    }
}
 
開發者ID:iMartinezMateu,項目名稱:openbravo-pos,代碼行數:7,代碼來源:JFlowPanel.java

示例4: getFirstVisibleIndex

/**
 * Returns the list index of the upper left or upper right corner of the
 * visible rectangle of this list, depending on the {@link
 * Component#getComponentOrientation} property.
 *
 * @return The index of the first visible list cell, or <code>-1</code>
 * if none is visible.
 */
public int getFirstVisibleIndex()
{
  ComponentOrientation or = getComponentOrientation();
  Rectangle r = getVisibleRect();
  if (or == ComponentOrientation.RIGHT_TO_LEFT)
    r.translate((int) r.getWidth() - 1, 0);
  return getUI().locationToIndex(this, r.getLocation());
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:16,代碼來源:JList.java

示例5: getCorner

public Component getCorner(String key)
{
  if (getComponentOrientation()
      == ComponentOrientation.LEFT_TO_RIGHT)
    {
      if (key == LOWER_LEADING_CORNER)
        key = LOWER_LEFT_CORNER;
      else if (key == LOWER_TRAILING_CORNER)
        key = LOWER_RIGHT_CORNER;
      else if (key == UPPER_LEADING_CORNER)
        key = UPPER_LEFT_CORNER;
      else if (key == UPPER_TRAILING_CORNER)
        key = UPPER_RIGHT_CORNER;
    }
  else if (getComponentOrientation()
           == ComponentOrientation.RIGHT_TO_LEFT)
    {
      if (key == LOWER_LEADING_CORNER)
        key = LOWER_RIGHT_CORNER;
      else if (key == LOWER_TRAILING_CORNER)
        key = LOWER_LEFT_CORNER;
      else if (key == UPPER_LEADING_CORNER)
        key = UPPER_RIGHT_CORNER;
      else if (key == UPPER_TRAILING_CORNER)
        key = UPPER_LEFT_CORNER;
    }

  if (key == LOWER_RIGHT_CORNER)
    return lowerRight;
  else if (key == UPPER_RIGHT_CORNER)
    return upperRight;
  else if (key == LOWER_LEFT_CORNER)
    return lowerLeft;
  else if (key == UPPER_LEFT_CORNER)
    return upperLeft;
  return null;
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:37,代碼來源:JScrollPane.java

示例6: placeDialog

/**
 * Finds the best location for the editor dialog for a given span of text.
 */
@Override
public void placeDialog(int start, int end) {
  if(popupWindow.isVisible() && pinnedButton.isSelected()) {
    // just resize
    Point where = popupWindow.getLocation();
    popupWindow.pack();
    if(where != null) {
      popupWindow.setLocation(where);
    }
  } else {
    // calculate position
    try {
      Rectangle startRect = owner.getTextComponent().modelToView(start);
      Rectangle endRect = owner.getTextComponent().modelToView(end);
      Point topLeft = owner.getTextComponent().getLocationOnScreen();
      int x = topLeft.x + startRect.x;
      int y = topLeft.y + endRect.y + endRect.height;
      // make sure the window doesn't start lower
      // than the end of the visible rectangle
      Rectangle visRect = owner.getTextComponent().getVisibleRect();
      int maxY = topLeft.y + visRect.y + visRect.height;
      // make sure window doesn't get off-screen
      popupWindow.pack();
      // responding to changed orientation
      if(currentOrientation == ComponentOrientation.RIGHT_TO_LEFT) {
        x = x - popupWindow.getSize().width;
        if(x < 0) x = 0;
      }
      Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
      boolean revalidate = false;
      if(popupWindow.getSize().width > screenSize.width) {
        popupWindow.setSize(screenSize.width, popupWindow.getSize().height);
        revalidate = true;
      }
      if(popupWindow.getSize().height > screenSize.height) {
        popupWindow.setSize(popupWindow.getSize().width, screenSize.height);
        revalidate = true;
      }
      if(revalidate) popupWindow.validate();
      // calculate max X
      int maxX = screenSize.width - popupWindow.getSize().width;
      // calculate max Y
      if(maxY + popupWindow.getSize().height > screenSize.height) {
        maxY = screenSize.height - popupWindow.getSize().height;
      }
      // correct position
      if(y > maxY) y = maxY;
      if(x > maxX) x = maxX;
      popupWindow.setLocation(x, y);
    } catch(BadLocationException ble) {
      // this should never occur
      throw new GateRuntimeException(ble);
    }
  }
  if(!popupWindow.isVisible()) popupWindow.setVisible(true);
}
 
開發者ID:GateNLP,項目名稱:gate-core,代碼行數:59,代碼來源:AnnotationEditor.java

示例7: changeOrientation

@Override
public void changeOrientation(ComponentOrientation orientation) {
  if(orientation == null) return;
  // remember the current orientation
  this.currentOrientation = orientation;
  // input map
  InputMap inputMap =
      ((JComponent)popupWindow.getContentPane())
          .getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
  Action solAction = actionMap.get("solAction");
  Action sorAction = actionMap.get("sorAction");
  Action eolAction = actionMap.get("eolAction");
  Action eorAction = actionMap.get("eorAction");
  if(orientation == ComponentOrientation.RIGHT_TO_LEFT) {
    // in right to left orientation
    // extending start offset is equal to extending end offset
    solButton.setAction(eorAction);
    solButton.setToolTipText(EOR_DESC);
    setShortCuts(inputMap, SOL_KEY_STROKES, "eorAction");
    solButton.setIcon(MainFrame.getIcon("extend-left"));
    // shrinking start offset is equal to shrinking end offset
    sorButton.setAction(eolAction);
    sorButton.setToolTipText(EOL_DESC);
    setShortCuts(inputMap, SOR_KEY_STROKES, "eolAction");
    sorButton.setIcon(MainFrame.getIcon("extend-right"));
    // shrinking end offset is equal to shrinking start offset
    eolButton.setAction(sorAction);
    eolButton.setToolTipText(SOR_DESC);
    setShortCuts(inputMap, EOL_KEY_STROKES, "sorAction");
    eolButton.setIcon(MainFrame.getIcon("extend-left"));
    // extending end offset is extending start offset
    eorButton.setAction(solAction);
    eorButton.setToolTipText(SOL_DESC);
    setShortCuts(inputMap, EOR_KEY_STROKES, "solAction");
    eorButton.setIcon(MainFrame.getIcon("extend-right"));
  } else {
    solButton.setAction(solAction);
    solButton.setToolTipText(SOL_DESC);
    setShortCuts(inputMap, SOL_KEY_STROKES, "solAction");
    solButton.setIcon(MainFrame.getIcon("extend-left"));
    sorButton.setAction(sorAction);
    sorButton.setToolTipText(SOR_DESC);
    setShortCuts(inputMap, SOR_KEY_STROKES, "sorAction");
    sorButton.setIcon(MainFrame.getIcon("extend-right"));
    eolButton.setAction(eolAction);
    eolButton.setToolTipText(EOL_DESC);
    setShortCuts(inputMap, EOL_KEY_STROKES, "eolAction");
    eolButton.setIcon(MainFrame.getIcon("extend-left"));
    eorButton.setAction(eorAction);
    eorButton.setToolTipText(EOR_DESC);
    setShortCuts(inputMap, EOR_KEY_STROKES, "eorAction");
    eorButton.setIcon(MainFrame.getIcon("extend-right"));
  }
}
 
開發者ID:GateNLP,項目名稱:gate-core,代碼行數:54,代碼來源:AnnotationEditor.java

示例8: getContents

protected Object[][] getContents() {
    return new Object[][] {
        { "Orientation", ComponentOrientation.RIGHT_TO_LEFT },
    };
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:5,代碼來源:TestBundle_iw.java

示例9: setCorner

public void setCorner(String key, Component c)
{
  if (getComponentOrientation()
      == ComponentOrientation.LEFT_TO_RIGHT)
    {
      if (key == LOWER_LEADING_CORNER)
        key = LOWER_LEFT_CORNER;
      else if (key == LOWER_TRAILING_CORNER)
        key = LOWER_RIGHT_CORNER;
      else if (key == UPPER_LEADING_CORNER)
        key = UPPER_LEFT_CORNER;
      else if (key == UPPER_TRAILING_CORNER)
        key = UPPER_RIGHT_CORNER;
    }
  else if (getComponentOrientation()
           == ComponentOrientation.RIGHT_TO_LEFT)
    {
      if (key == LOWER_LEADING_CORNER)
        key = LOWER_RIGHT_CORNER;
      else if (key == LOWER_TRAILING_CORNER)
        key = LOWER_LEFT_CORNER;
      else if (key == UPPER_LEADING_CORNER)
        key = UPPER_RIGHT_CORNER;
      else if (key == UPPER_TRAILING_CORNER)
        key = UPPER_LEFT_CORNER;
    }

  if (key == LOWER_RIGHT_CORNER)
    {
      removeNonNull(lowerRight);
      lowerRight = c;
      addNonNull(c, JScrollPane.LOWER_RIGHT_CORNER);
    }
  else if (key == UPPER_RIGHT_CORNER)
    {
      removeNonNull(upperRight);
      upperRight = c;
      addNonNull(c, JScrollPane.UPPER_RIGHT_CORNER);
    }
  else if (key == LOWER_LEFT_CORNER)
    {
      removeNonNull(lowerLeft);
      lowerLeft = c;
      addNonNull(c, JScrollPane.LOWER_LEFT_CORNER);
    }
  else if (key == UPPER_LEFT_CORNER)
    {
      removeNonNull(upperLeft);
      upperLeft = c;
      addNonNull(c, JScrollPane.UPPER_LEFT_CORNER);
    }
  else
    throw new IllegalArgumentException("unknown corner " + key);
  sync();
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:55,代碼來源:JScrollPane.java


注:本文中的java.awt.ComponentOrientation.RIGHT_TO_LEFT屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。