当前位置: 首页>>代码示例>>Java>>正文


Java Graphics.drawRect方法代码示例

本文整理汇总了Java中javax.microedition.lcdui.Graphics.drawRect方法的典型用法代码示例。如果您正苦于以下问题:Java Graphics.drawRect方法的具体用法?Java Graphics.drawRect怎么用?Java Graphics.drawRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.microedition.lcdui.Graphics的用法示例。


在下文中一共展示了Graphics.drawRect方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: paint

import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
protected void paint(Graphics g) {
	// Get the canvas dimensions
	clipX = g.getClipHeight();
	clipY = g.getClipWidth();
	// Clear screen with white color
	g.setColor(255, 255, 255);
	g.fillRect(0, 0, clipX, clipY);

	// Draw the squares in red
	g.setColor(255, 0, 0);
	Enumeration en = mySquares.elements();
	while (en.hasMoreElements()) {
		Square sq = (Square) en.nextElement();
		g.fillRect(sq.posX, sq.posY, 4, 4);
	}
	// Draw the rectangle in black
	g.setColor(0, 0, 0);
	g.fillRect(myRectPosX, myRectPosY, myRectWidth, myRectHeight);

	// Draw the edges of the Rectangle Gesture Interactive Zone in green
	g.setColor(0, 255, 0);
	g.drawRect(myGestureZonePosX, myGestureZonePosY, myGestureZoneWidth,
			myGestureZoneHeight);
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:25,代码来源:GAFAView.java

示例2: paint

import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
public void paint(Graphics g) {
  int width = getWidth();
  int height = getHeight();

  // Draw a green border around the VideoControl.
  g.setColor(0x00ff00);
  g.drawRect(0, 0, width - 1, height - 1);
  g.drawRect(1, 1, width - 3, height - 3);
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:10,代码来源:CameraCanvas.java

示例3: paint

import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
/**
   * Draws the item.
   * 
   * @param g Graphics context.
   * @param viewX Top-left x-coordinate of the current view area (grid coordinates, not screen) 
   * @param viewY Top-left y-coordinate of the current view area (grid coordinates, not screen)
   */
  public void paint(Graphics g, int viewX, int viewY){
if (Log.TEST) Log.note("[GridItem#paint]-->");
  	// Calculate actual drawing coordinates from the view coordinates
int translatedX = x - viewX;
  	int translatedY = y - viewY;
  	
      // First draw the underlying rectangle, and get color for text drawing
      if (selected) {
          g.setColor(display.getColor(Display.COLOR_HIGHLIGHTED_BACKGROUND));
          // Draw highlighted background
          g.fillRect(translatedX, translatedY, width, height);
          g.setColor(display.getColor(Display.COLOR_HIGHLIGHTED_BORDER));
          // Draw border
          g.drawRect(translatedX, translatedY, width, height);
          // Set color for text drawing
          g.setColor(display.getColor(Display.COLOR_HIGHLIGHTED_FOREGROUND));
      } else {
      	//g.setColor(display.getColor(Display.COLOR_BORDER));
      	//g.setColor(display.getColor(Display.COLOR_HIGHLIGHTED_FOREGROUND));
              g.setColor(~display.getColor(Display.COLOR_BACKGROUND));

      	// Draw border
      	g.drawRect(translatedX, translatedY, width, height);
      	// Set color for text drawing
          g.setColor(display.getColor(Display.COLOR_FOREGROUND));
      }
      
      drawContents(g, translatedX + V_PAD, translatedY + H_PAD,
      		width - 2 * H_PAD, height - 2 * V_PAD);
      }
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:38,代码来源:GridItem.java

示例4: paint

import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
/**
 * Paint the state. Should be called from Button's paint method.
 */
public void paint(Graphics gfx, String text) {
    gfx.drawImage(
            background,
            owner.getWidth() / 2, owner.getHeight() / 2,
            Graphics.VCENTER | Graphics.HCENTER);
    gfx.setColor(0x000000);
    gfx.drawRect(0, 0, owner.getWidth() - 1, owner.getHeight() - 1);
    gfx.setColor(this.labelColor);
    gfx.drawString(
            text,
            owner.getWidth() / 2, (owner.getHeight() / 3) * 2,
            Graphics.BASELINE | Graphics.HCENTER);
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:17,代码来源:Button.java


注:本文中的javax.microedition.lcdui.Graphics.drawRect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。