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 ...
随机推荐
- Scanner类nextInt方法的使用注意点
一.先看一段正常的代码 1. 一段用Scanner捕获键盘输入的代码: Scanner sc = new Scanner(System.in); // 先读取键盘输入的字符串 System.out.p ...
- Cocos2d-X开发中国象棋《二》project文件概述
我在上一篇博客中介绍了象棋的功能.在接下来的博客中将向大家介绍使用Cocos2d-X怎样一步一步开发中国象棋 开发工具: Cocos2d-X2.2.3 VS2012 项目的文件夹: Classes:存 ...
- 转 MySQL中的共享锁与排他锁
原文链接在MySQL中的行级锁,表级锁,页级锁中介绍过,行级锁是Mysql中锁定粒度最细的一种锁,行级锁能大大减少数据库操作的冲突.行级锁分为共享锁和排他锁两种,本文将详细介绍共享锁及排他锁的概念.使 ...
- shell 批量查看job 配置
如查看构建失败发送情况 进入job 目录,查找以DailyBuild开头的job的配置文件 grep '<hudson.plugins.emailext.plugins.trigger.Fail ...
- jenkins 发送邮件失败
jenkins 配置发送邮件,发送测试邮件,邮件发送失败: Failed to send out e-mail javax.mail.MessagingException: Could not con ...
- REST技术第三步 @BeanParam的使用
我简介下rest中@BeanParam的使用 我们来做一个计算加法的服务. 提供两个參数a和b,计算出a+b. 參数都在URL里 就是类似这样的效果. 这次用上@BeanParam 首先写个POJO来 ...
- hdoj 1698 Just a Hook 【线段树 区间更新】
题目大意:有一段链子.初始的时候是铜的(价值为1),n代表有n段(1~n),输入a, b, c三个数分别表示将从a到b的链子的价值改为c, 最后问你经过多次改变之后的总价值. 策略:这道题是简单的线段 ...
- oop klass
https://www.infoq.com/articles/Introduction-to-HotSpot 借助HotSpot SA来一窥PermGen上的对象 找出栈上的指针/引用 虚拟机随谈(一 ...
- (HttpURLConnection)强制转化
HTTP的请求详解在我的博客中已经讲解过: http://blog.csdn.net/xiazdong/article/details/7215296 我在http://blog.csdn.net/x ...
- hive 定时加载分区
#!/bin/bash #每天定时位外部表加载分区 #服务器当天的时间 #加载环境变量 source /etc/profile; #如果没有指定日期用当前日期如果指定的日期使用指定的日期 echo ' ...