`

Getting the Dimensions of Text:获取文本的长和宽

 
阅读更多

 

// From within the paint() method.

public void paint(Graphics g) {

Graphics2D g2d = (Graphics2D)g;

Font font = new Font("Serif", Font.PLAIN, 12);

FontMetrics fontMetrics = g2d.getFontMetrics();

int width = fontMetrics.stringWidth("aString");

int height = fontMetrics.getHeight();

}

// From within a component.

class MyComponent extends JComponent {

MyComponent() {

Font font = new Font("Serif", Font.PLAIN, 12);

FontMetrics fontMetrics = getFontMetrics(font);

int width = fontMetrics.stringWidth("aString");

int height = fontMetrics.getHeight();

}

}

分享到:
评论

相关推荐

    Getting started with Spring Framework: covers Spring 5(epub)

    The examples (consisting of 88 sample projects) that accompany this book are based on Spring 5.0.1 and Java 9. You can download the examples described in this book from the following GitHub project:...

    Delete:The Virtue of Forgetting

    《Delete:The Virtue of Forgetting》这本书是由Viktor Mayer-Schönberger所著,他是大数据时代的重要作者之一。本书深入探讨了在数字时代,遗忘的美德,即遗忘的重要性及其对于个人隐私和社会价值的贡献。随着...

    Getting Started with Varnish Cache: Accelerate Your Web Applications

    Getting Started with Varnish Cache: Accelerate Your Web Applications by Thijs Feryn English | 13 Mar. 2017 | ASIN: B06XP3D6Z2 | 253 Pages | AZW3 | 720.91 KB How long does it take for your website to ...

    Getting Started with Grunt: The JavaScript Task Runner

    A hands-on approach to mastering the fundamentals of Grunt Overview Gain insight on the core concepts of Grunt, Node.js and npm to get started with Grunt. Learn how to install, configure, run, and ...

    The Art of Unit Testing: with Examples in .NET

    Unit testing, done right, can mean the diff erence between a failed project and a successful one, between a maintainable code base and a code base that no one dares touch, and between getting home at ...

    The Scientist and Engineer's Guide to Digital Signal Processing

    1: The Breadth and Depth of DSP 2: Statistics, Probability and Noise 3: ADC and DAC 4: DSP Software 5: Linear Systems 6: Convolution 7: Properties of Convolution 8: The Discrete Fourier Transform 9: ...

    Albert-László Barabási的2018年新书《The Formula:the universal laws of success》

    "This is not just an important but an imperative project: to approach the problem of randomness and success using the state of the art scientific arsenal we have. Barabasi is the person." --Nassim ...

    Getting Things Done - The Art Of Stress-Free Productivity.pdf

    Getting Things Done - The Art Of Stress-Free Productivity.pdf

    getting_cleaning_data:获取和清理数据课程

    Getting_cleaning_data 将项目的数据下载并解压缩到R Stuio的工作目录中: ://d396qusza40orc.cloudfront.net/getdata/projectfiles/UCI HAR Dataset.zip该代码假定您拥有“ UCI”中所需的数据文件您的工作目录中的...

    getting_cleaning_data:获取和清理数据 - 课程项目

    获取清洁数据获取和清理数据 - 课程项目run_analysis.R 使用文件夹 UCI HAR Dataset 中的原始数据创建一个整洁的数据集(研究作者提供的原始数据的完整描述附在本文末尾) 解压后的完整文件夹“UCI HAR Dataset”...

    Getting-Cleaning-Data:获取和清理 Coursera 课程的数据存储库

    获取清理数据 该项目的目的是展示您收集、处理和清理数据集的能力。 目标是准备可用于以后分析的整洁数据。 目前所有数据科学中最令人兴奋的领域之一是可穿戴计算——例如参见本文。 Fitbit、Nike 和 Jawbone Up 等...

    Understanding Clinical Research: Behind the Statistics

    Two ways of stating the alternative hypothesis The two-tailed test The one-tailed test Hypothesis testing errors Type I and II errors Confidence in your results Introduction to confidence intervals ...

    Getting_Cleaning_Data:获取和清理数据

    这是“获取和清洁数据”课程的作业。 该项目的目的是从“使用智能手机数据集的人类活动识别”中创建一个新的整洁数据集。 完整的数据集应从以下URL下载: 指示: 下载数据集并将文件提取到“数据”目录下安装“ ...

    Getting_Data_Project:获取数据项目的回购

    获取_数据_项目获取数据项目R脚本的说明: 您可以在此存储库中找到的 R 脚本 (run_analysis.R) 生成如下整洁的数据集: 合并训练和测试数据集以创建一个数据集。 训练数据集可以在:train 目录(X_train.txt、...

    Getting_Cleaning_data:获取和清理数据

    获取数据的站点提供了完整的描述: 以下是该项目的数据: 在这个项目中,我们创建了一个名为 run_analysis.R 的 R 脚本,它执行以下操作。 合并训练集和测试集以创建一个数据集。 仅提取每个测量值的平均值和标准...

    getting-cleaning-data:获取和清理数据的基础

    Coursera“获取和清理数据”课程文件的存储库。 脚本的任务: 在UCI HAR数据集上执行以下步骤: 合并训练和测试集以创建一个数据集。 仅提取每次测量的均值和标准差的测量值。 使用描述性活动名称来命名数据...

    Getting-Cleaning-Data:获取和清理数据课程项目

    获取和清洗数据课程项目 ##简介该项目是约翰霍普金斯大学(John Hopkins University)数据科学跟踪课程“获取和清除数据”的一部分。 该存储库包含该项目的Codea和文档文件。 该项目的目的是演示收集,处理和清理...

    Getting the number of columns in report view获得列表视图的列

    "Getting the number of columns in report view"这个主题是关于如何获取列表视图中的列数,这对于界面设计、数据分析以及用户交互优化具有重要意义。下面我们将深入探讨这一话题。 首先,我们需要理解列表视图...

Global site tag (gtag.js) - Google Analytics