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的更多相关文章

  1. LightOJ 1285 - Drawing Simple Polygon (几何,极角排序)

    1285 - Drawing Simple Polygon   PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: ...

  2. Html5: Drawing with text

    <!DOCTYPE html> <html> <head> <meta name="viewport" content="wid ...

  3. e586. Drawing Simple Shapes

    There are two ways to draw basic shapes like circles, ovals, lines, arcs, squares, rectangles, round ...

  4. reactjs simple text editor

    import React, { Component } from 'react' import PubSub from 'pubsub' import GlobalVars from 'globalV ...

  5. 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 ...

  6. LightOj1285 - Drawing Simple Polygon(连接多边形各点)

    题目链接:http://lightoj.com/volume_showproblem.php?problem=1285 题意:给你一些点,然后把它们用一条线把它们连起来,构成一个多边形,不能有相交,必 ...

  7. e577. Enabling Antialiasing

    // See e575 The Quintessential Drawing Program public void paint(Graphics g) { // Retrieve the graph ...

  8. html5 canvas simple drawing

    var c = canvas.getContext("2d");//get canvas 2d context canvas including a proposed 3D con ...

  9. [OpenCV] Samples 01: drawing

    基本的几何图形,标注功能. commondLineParser的使用参见:http://blog.csdn.net/u010305560/article/details/8941365 #includ ...

随机推荐

  1. Chipscope使用

    作者:桂. 时间:2017-08-07  06:47:31 链接:http://www.cnblogs.com/xingshansi/p/7297482.html 前言 Chipscope在FPGA调 ...

  2. cocos2dx 3.3将坐标由父空间转化到局部空间

    设在node的父空间内有一点p,要求其转化到node局部空间后的坐标p_local,代码如下: node->getNodeToParentTransform();//in order node- ...

  3. Java的spi介绍和简单应用

    1.什么是java的spi SPI 全称为 (Service Provider Interface) ,是JDK内置的一种服务提供发现机制. 目前有不少框架用它来做服务的扩展发现, 简单来说,它就是一 ...

  4. js下拉框二级关联菜单效果代码具体实现

    这篇文章介绍了js下拉框二级关联菜单效果代码具体实现,有需要的朋友可以参考一下 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transit ...

  5. 【Android】3.1 创建本章示例项目

    分类:C#.Android.VS2015.百度地图应用: 创建日期:2016-02-04 注意:本节是在完成了 3.0节介绍的预备知识的基础上继续实现的. 示例1--显示地图并为后续内容做准备 1.运 ...

  6. Python的模块调用

    目前运维的Python脚本,是用于同步数据的,分别有n个不同的脚本同步不同的数据,而不同的脚本连接的数据库是一致的,每个脚本都重复写这个数据库连接信息. 这导致测试时,从生产环境切换到测试环境时,需多 ...

  7. RabbitMQ(二):mandatory标志的作用

    本文转自:http://m.blog.csdn.net/article/details?id=54311277 在生产者通过channel的basicPublish方法发布消息时,通常有几个参数需要设 ...

  8. js获取checkbox值的方法

    js获取checkbox值的方法.分享给大家供大家参考.具体实现方法如下:<html> <head> <meta http-equiv="Content-Typ ...

  9. 从sql中image类型字段中导出图片

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.I ...

  10. 【WPF】ComboBoxItem的禁用

    需求:下拉列表ComboBox中,要求部分Item不可用.效果是鼠标一上去后不获得焦点,且无法点击. 前台XAML界面: <!-- 下拉列表:省份 --> <ComboBox Gri ...