e591. Drawing Simple Text
See also e575 The Quintessential Drawing Program.
public void paint(Graphics g) {
// Set the desired font if different from default font
String family = "Serif";
int style = Font.PLAIN;
int size = 12;
Font font = new Font(family, style, size);
g.setFont(font); // Draw a string such that its base line is at x, y
int x = 10;
int y = 10;
g.drawString("aString", x, y); // Draw a string such that the top-left corner is at x, y
x = 10;
y = 30;
FontMetrics fontMetrics = g.getFontMetrics();
g.drawString("aString", x, y+fontMetrics.getAscent());
}
Related Examples |
e591. Drawing Simple Text的更多相关文章
- LightOJ 1285 - Drawing Simple Polygon (几何,极角排序)
1285 - Drawing Simple Polygon PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: ...
- Html5: Drawing with text
<!DOCTYPE html> <html> <head> <meta name="viewport" content="wid ...
- e586. Drawing Simple Shapes
There are two ways to draw basic shapes like circles, ovals, lines, arcs, squares, rectangles, round ...
- reactjs simple text editor
import React, { Component } from 'react' import PubSub from 'pubsub' import GlobalVars from 'globalV ...
- Drawing Simple Polygon(Create Simple Polygon from unordered points by angle sorting)
Keywords: 极角排序, Simple Polygon Generation Given set of points in the plane, your task is to draw a p ...
- LightOj1285 - Drawing Simple Polygon(连接多边形各点)
题目链接:http://lightoj.com/volume_showproblem.php?problem=1285 题意:给你一些点,然后把它们用一条线把它们连起来,构成一个多边形,不能有相交,必 ...
- e577. Enabling Antialiasing
// See e575 The Quintessential Drawing Program public void paint(Graphics g) { // Retrieve the graph ...
- html5 canvas simple drawing
var c = canvas.getContext("2d");//get canvas 2d context canvas including a proposed 3D con ...
- [OpenCV] Samples 01: drawing
基本的几何图形,标注功能. commondLineParser的使用参见:http://blog.csdn.net/u010305560/article/details/8941365 #includ ...
随机推荐
- [转]Microsoft Office 2010、Visio 2010、Project 2010官方中文版+有效激活方法
本文刊发的Office 2010.Project 2010O.Visio 2010:(1)均为“微软批量授权中心”原版光盘镜像:(2)均提供了32位(x86)和64位(x64)两种版本.为使大家了解各 ...
- django打印字典
- js检查页面上有无重复id的代码分享
用js代码检查一个页面上是否用重复的id. 方法一: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" ...
- 枚举操作的常用方法,包括获得枚举的value,name,description
public enum SendInfoStateEnum { [Description("等待提交")] 等待提交 = 1, [Description(& ...
- bazel-编译动态库
demo2_2 使用baze编译动态库 demo2_2目录树 ├── app │ ├── BUILD │ ├── func.cpp │ └── func.hpp ├── README.md └── W ...
- Ubuntu 安装谷歌拼音输入法
Ubuntu14.04内置的拼音输入法有一个bug,使得Live USB全拼无法使用. 安装Google拼音输入法步骤如下: 1. 打开Ubuntu软件中心 (Ubuntu Software Cent ...
- 每日英语:Does Evolution Want Us To Be Unhappy?
Samuel Johnson called it the vanity of human wishes, and Buddhists talk about the endless cycle of d ...
- PairRDD中算子foldByKey图解
foldByKey 函数原型: def foldByKey(zeroValue: V)(func: (V, V) => V): RDD[(K, V)] def foldByKey(zeroVal ...
- Java IP地址字符串与BigInteger的转换, 支持IPv6
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 3 ...
- fileupload的乱码解决
解决方法就是这段代码,其中item是fileupload中的FileItem String value = new String(item.getString().getBytes("ISO ...