Selamat siang pemirsa setia :D
seperti posting sebelumnya,
kita mau ubah si jtextfield yang kotak2 jadi agak bulet
biar bagus gitu :D
Pertama bkin dlu Class TextFieldMakeOver namanya
trus copas deh :
package MakeOver;
import java.awt.Color;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;
public class TextFieldMakeOver extends JTextField {
public TextFieldMakeOver() {
setOpaque(false);
setForeground(Color.WHITE);
setCaretColor(Color.WHITE);
setBorder(new EmptyBorder(6, 6, 6, 6));
}
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D gd = (Graphics2D) g.create();
gd.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
gd.setPaint(new GradientPaint(0, 0, new Color(255, 255, 255, 120), 0, getHeight(), new Color(0, 0, 0, 0)));
gd.fillRoundRect(0, 0, getWidth(), getHeight(), 25, 25);
gd.setColor(Color.white);
gd.drawRoundRect(0, 0, getWidth() - 1, getHeight() - 1, 25, 25);
gd.dispose();
}
}
Cara kerjanya sama, COMPILE dulu projectnya, trus DRAG AND DROP si class TextFieldMakeOver
ke jFrame kamu :D
sekian dan terimakasih ^^
Tidak ada komentar:
Posting Komentar