java JTextField美化Demo

时间:2023-05-01 01:32:04
【文件属性】:

文件名称:java JTextField美化Demo

文件大小:12KB

文件格式:RAR

更新时间:2023-05-01 01:32:04

java

实现圆角矩形边框,hint文字,主要代码: Graphics2D g2d=(Graphics2D) g; g2d.setStroke(new BasicStroke(2,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND)); g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,0.5f)); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.setColor(borderColor); g2d.drawRoundRect(0, 0, c.getWidth()-4,c.getHeight()-4, 20, 20); JTextField textField = (JTextField) c; if ("".equals(textField.getText())) { g2d.setColor(Color.BLACK); g2d.drawString("请输入文字...", 10, 18); }


【文件预览】:
Demo_App
----.project(384B)
----bin()
--------TextFieldEx$1.class(1KB)
--------BtnEx$3.class(2KB)
--------BtnEx.class(2KB)
--------BtnEx$5.class(715B)
--------BtnEx$4.class(1KB)
--------TextFieldEx.class(1KB)
--------BtnEx$2.class(2KB)
--------BtnEx$1.class(2KB)
--------TextFieldBorder.class(2KB)
--------MainClass.class(402B)
----.settings()
--------org.eclipse.jdt.core.prefs(598B)
----src()
--------MainClass.java(158B)
--------TextFieldBorder.java(1KB)
--------BtnEx.java(4KB)
--------TextFieldEx.java(2KB)
----.classpath(301B)

网友评论