ludc
2024-09-14 36c2449aec5b51e5ed4e5c6841154b746060e09a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package com.vci.client.ui.swing;
 
import java.awt.Color;
import java.awt.Graphics;
 
import javax.swing.JTextField;
 
/**
 * 继承JTextField,在此基础上增加红色标记,目的是提醒用户文本内容不能为空。
 * @author Administrator
 *
 */
public class KTextField extends JTextField{
  /**
     * 
     */
    private static final long serialVersionUID = 1L;
 
    public KTextField() {
        
    }
 
    public KTextField(int Width,int Height){
        setSize(Width,Height);
    }
    
    public void paint (Graphics g) {
        super.paint (g);
        g.setColor (Color.red);
        int text_XSize = this.getWidth ();
        int[] xSeq = new int[3];
        int[] ySeq = new int[3];
        xSeq[0] = text_XSize - 8;
        ySeq[0] = 1;
        xSeq[1] = text_XSize -1;
        ySeq[1] = 1;
        xSeq[2] = text_XSize -1;
        ySeq[2] = 8;
        g.fillPolygon (xSeq, ySeq, 3);
    }
}