Swing Rectangle example Rectangles To draw rectangles, we use the drawRect() method. To fill rectangles with the current color, we use the fillRect() method. package PRACTICEPROGRAM; import java.awt.Color; import java.awt.Graphics; import java.awt.Graphics2D; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.SwingUtilities; class DrawPanel extends JPanel { public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2d = (Graphics2D) g; g2d.setColor(new Color(212, 212, 212)); g2d.drawRect(10, 15, 90, 60); ...
FOR EVERY PROGRAMMER SOME SPECIAL PROGRAMS WITH THEORY.