java – 如何在填充矩形内绘制String?
作者:互联网
我只是想在一个充满黑色的矩形中显示我的String.谢谢您的帮助!
解决方法:
这个给你:
public class MyPanel extends JPanel{
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.drawRect(10/*x*/, 10/*y*/, 80/*width*/, 30/*hight*/);
g.drawString("TextToDraw", 25/*x*/, 25/*y*/);
}
}
标签:java,drawrect,paintcomponent,drawstring 来源: https://codeday.me/bug/20190721/1494768.html