import java.awt.*; class LightComponent extends Component { int LocW, LocH; private Image image; private Dragster drag; MyPanel panel; boolean draggable; public LightComponent (Image image, MyPanel panel, int LocH, int LocW, boolean draggable) { this.image = image; drag = new Dragster(this); addMouseListener(drag); addMouseMotionListener(drag); this.panel = panel; this.LocH = LocH; this.LocW = LocW; this.draggable = draggable; } public void paint (Graphics g) { if (isVisible()) { g.drawImage (image, 0, 0, this); } else { /* do something, or nothing, if the component is not visible */ } } public Dimension getPreferredSize() { return new Dimension (image.getWidth(this), image.getHeight(this)); } /*===============================================================*/ /* ASSORTED ACCESSORS/MODIFIERS */ /* */ /* The following methods are particular to the shuffle */ /* puzzle program */ /*===============================================================*/ public boolean isDraggable() { return draggable;} public int getLocH() {return LocH;} public int getLocW() {return LocW;} public void setLocH(int LocH){ this.LocH=LocH;} public void setLocW(int LocW){ this.LocW=LocW;} public boolean validMove() { return panel.validateMove(getLocW(), getLocH()); } public int getBlankLocH() { return panel.getBlankLocH();} public int getBlankLocW() { return panel.getBlankLocW();} public void setBlankLocH(int BlankCellH) { panel.setBlankLocH(BlankCellH);} public void setBlankLocW(int BlankCellW) { panel.setBlankLocW(BlankCellW);} public MyPanel getPanel() { return panel; } }