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


Java Label.LEFT屬性代碼示例

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


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

示例1: drawTextInBounds

/**
 * Draws a text into a boundary. The text is clipped on the right border of the bounds.
 *
 * @param g The graphics context in which to draw
 * @param text The text to draw
 * @param x The x position of the boundary
 * @param y The y position of the boundary
 * @param width The width position of the boundary
 * @param height The height position of the boundary
 * @param alignment The alignment of the text: Label.LEFT or Label.CENTER
 * @param textDescent Text text descent
 */
public static void drawTextInBounds (final Graphics2D g, final String text, final int x, final int y, final int width, final int height, final int alignment, final int textDescent)
{
    if (text == null || text.length () == 0)
        return;
    final Dimension dim = getTextDims (g, text);
    g.clipRect (x, y, width, height);
    final int pos;
    switch (alignment)
    {
        case Label.LEFT:
            pos = x;
            break;

        case Label.CENTER:
        default:
            pos = x + (width - dim.width) / 2;
            break;
    }
    g.drawString (text, pos, y + height - (height - dim.height) / 2 - textDescent);
    g.setClip (null);
}
 
開發者ID:git-moss,項目名稱:Push2Display,代碼行數:33,代碼來源:AbstractGridElement.java

示例2: setAlignment

/**
 * Sets the horizontal alignment of the label. This is implemented to
 * set the alignment on the Swing label.
 *
 * @param alignment the horizontal alignment
 *
 * @see Label#LEFT
 * @see Label#RIGHT
 * @see Label#CENTER
 */
public void setAlignment(int alignment)
{
  JLabel swingLabel = (JLabel) swingComponent.getJComponent();
  switch (alignment)
    {
    case Label.RIGHT:
      swingLabel.setHorizontalAlignment(JLabel.RIGHT);
      break;
    case Label.CENTER:
      swingLabel.setHorizontalAlignment(JLabel.CENTER);
      break;
    case Label.LEFT:
    default:
      swingLabel.setHorizontalAlignment(JLabel.LEFT);
      break;
    }
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:27,代碼來源:SwingLabelPeer.java

示例3: getGtkAlignment

float getGtkAlignment (int alignment)
{
  switch (alignment)
    {
    case Label.LEFT:
      return 0.0f;
    case Label.CENTER:
      return 0.5f;
    case Label.RIGHT:
      return 1.0f;
    }

  return 0.0f;
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:14,代碼來源:GtkLabelPeer.java

示例4: initGUI

/**
 * Create the graphical user interface. This is AWT code.
 */
private void initGUI() {

    // all panels
    Panel pQuery       = new Panel();
    Panel pCommand     = new Panel();
    Panel pButton      = new Panel();
    Panel pRecent      = new Panel();
    Panel pResult      = new Panel();
    Panel pBorderWest  = new Panel();
    Panel pBorderEast  = new Panel();
    Panel pBorderSouth = new Panel();

    pQuery.setLayout(new BorderLayout());
    pCommand.setLayout(new BorderLayout());
    pButton.setLayout(new BorderLayout());
    pRecent.setLayout(new BorderLayout());
    pResult.setLayout(new BorderLayout());
    pBorderWest.setBackground(SystemColor.control);
    pBorderSouth.setBackground(SystemColor.control);
    pBorderEast.setBackground(SystemColor.control);

    // labels
    Label lblCommand = new Label(" Command", Label.LEFT);
    Label lblRecent  = new Label(" Recent", Label.LEFT);
    Label lblResult  = new Label(" Result", Label.LEFT);

    lblCommand.setBackground(SystemColor.control);
    lblRecent.setBackground(SystemColor.control);
    lblResult.setBackground(SystemColor.control);

    // buttons
    butExecute = new Button("Execute");
    butScript  = new Button("Script");
    butImport  = new Button("Import");

    pButton.add("South", butScript);
    pButton.add("Center", butExecute);
    pButton.add("North", butImport);

    // command - textarea
    Font fFont = new Font("Dialog", Font.PLAIN, 12);

    txtCommand = new TextArea(5, 40);

    txtCommand.setFont(fFont);

    // recent - choice
    choRecent = new Choice();

    // result - grid
    gResult = new Grid();

    // combine it
    setLayout(new BorderLayout());
    pRecent.add("Center", choRecent);
    pRecent.add("North", lblRecent);
    pCommand.add("North", lblCommand);
    pCommand.add("East", pButton);
    pCommand.add("Center", txtCommand);
    pCommand.add("South", pRecent);
    pResult.add("North", lblResult);
    pResult.add("Center", gResult);
    pQuery.add("North", pCommand);
    pQuery.add("Center", pResult);
    add("Center", pQuery);
    add("West", pBorderWest);
    add("East", pBorderEast);
    add("South", pBorderSouth);

    // [email protected] 20011210 - patch 450412 by [email protected]
    doLayout();
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:75,代碼來源:QueryTool.java


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