Электронная библиотека книг Александра Фролова и Григория Фролова.
Shop2You.ru Создайте свой интернет-магазин
Библиотека
Братьев
Фроловых
[Назад]

Исходный текст программы ConsImage.java

Оглавление

Назад

// ==========================================
// ConsImage.java
//(C) Alexandr Frolov, 1998
// E-mail: frolov@glasnet.ru
// Web:    http://www.glasnet.ru/~frolov 
// ==========================================

import java.io.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;

public class ConsImage
{
  public static void main(String args[])
  {
    FrameWindow frame;
    frame = 
      new FrameWindow("Image Viewer");
    frame.setVisible(true);
  }
}

// =======================================
// Class FrameWindow
// =======================================
class FrameWindow extends Frame
  implements WindowListener
{
  Image img;
      
  // ============================================
  // FrameWindow
  // ============================================
  public FrameWindow(String szTitle)
  {
    super(szTitle);
    setSize(400, 300);
    
    this.addWindowListener(this);
    
    Properties p = System.getProperties();
    
    String szFilePath = 
      p.getProperty("user.dir") +  
      File.separator + "cdroms.jpg";
    
    img = Toolkit.getDefaultToolkit().getImage(
      szFilePath);
  }
  
  // ===========================================
  // paint
  // ===========================================
  public void paint(Graphics g)
  {
    g.drawImage(img, 10, 30, this);
    g.drawString("CDROMS.JPG", 15, 50);  
  }  

  // ============================================
  // windowClosing
  // ============================================
  public void windowClosing(WindowEvent e)
  {
    setVisible(false);
    System.exit(0);
  }
  
  public void windowOpened(WindowEvent e) {}
  public void windowClosed(WindowEvent e) {}
  public void windowIconified(WindowEvent e) {}
  public void windowDeiconified(WindowEvent e) {}
  public void windowActivated(WindowEvent e) {}
  public void windowDeactivated(WindowEvent e) {}
}

[Назад]