import java.awt.*;
import javax.swing.*;
class Draw extends JComponent {
public void paint(Graphics g) {
Graphics2D g2 = (Graphics2D) g;
GradientPaint gp = new GradientPaint(0,0,Color.BLUE,250,250,Color.RED);
// g2.setColor(Color.MAGENTA);
// g2.fillRect(0,0,150,150);
g2.setPaint(gp);
g2.fillRoundRect(20,20,250,250,50,50);
// g2.fillRect(20,20,250,250);
}
}
class GFrame extends JFrame {
public GFrame() {
CreateFrame();
add(new Draw());
}
void CreateFrame() {
setTitle("Graphics");
setSize(310,330);
setLocationRelativeTo(null);
setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setLayout(new BorderLayout());
setVisible(true);
}
}
public class GradientEx{
public static void main(String[] args) {
new GFrame();
}
}
'■ 공부 > JAVA' 카테고리의 다른 글
[JAVA] DragListener (0) | 2024.02.12 |
---|---|
[JAVA] 소켓통신 : 학점 반환하기 (0) | 2024.01.30 |
[JAVA] 소켓통신 : 채팅프로그램 (0) | 2024.01.26 |
[JAVA] File 클래스 : cmd 구현하기 (0) | 2024.01.25 |
[JAVA] MainFrame 소스 (0) | 2024.01.24 |