1 package zirc.gui ; 2 3 import java.awt.* ; 4 import java.awt.image.* ; 5 import javax.swing.* ; 6 7 14 15 16 public class ImagePanel extends JPanel 17 { 18 private Image img ; 19 ImageObserver imgObserver ; 20 private GridLayout gridLayout1 = new GridLayout() ; 21 22 public ImagePanel(Image _img) 23 { 24 setMinimumSize(new Dimension(300, 100)) ; 25 setPreferredSize(new Dimension(300, 100)) ; 26 img = _img ; 27 } 28 29 public void paint(Graphics g) 30 { 31 g.drawImage(img, 0, 0, this) ; 32 } 33 34 public ImagePanel() 35 { 36 try 37 { 38 jbInit() ; 39 } 40 catch (Exception e) 41 { 42 e.printStackTrace() ; 43 } 44 } 45 46 private void jbInit() throws Exception 47 { 48 this.setBorder(BorderFactory.createLineBorder(Color.gray)) ; 49 this.setLayout(gridLayout1) ; 50 } 51 52 } 53 | Popular Tags |