当前位置: 首页>>代码示例>>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;未经允许,请勿转载。