1 2 /* 3 *Program to create a RedCross using only one triangle, while modifying a existing program. 4 */ 5 6 package npw; 7 8 import painter.SPainter; 9 import shapes.SRectangle; 10 11 import javax.swing.*; 12 import java.awt.*; 13 14 public class RedCross { 15 //The SOLUTION TO THE RedCross PROBLEM 16 17 private void paintTheImage(){ 18 //My New painter's name is cross1 19 SPainter cross1 = new SPainter("cross1",600,600); 20 //My rectangle's new name is cross 21 SRectangle cross = new SRectangle (500, 100); 22 //My painter dipped his brush 23 cross1.setColor(Color.RED); 24 cross1.paint(cross); 25 //Expand the width 26 cross.expand(0,400); 27 //Expand the Height 28 cross.shrink(400, 0); 29 //****NOTICE**** I need the Paint command a second time if not present it doesn't work. 30 31 cross1.paint(cross); 32 33 34 35 36 37 38 39 40 // cross.resetWidth(500);cross.resetHeight(100); 41 42 43 44 45 } 46 //REQUIRED INFRASTRUCTURE 47 public RedCross (){ 48 paintTheImage(); 49 } 50 public static void main (String[] args) { 51 SwingUtilities. invokeLater(new Runnable() { 52 public void run() { 53 new RedCross(); 54 } 55 }); 56 } 57 }