资源简介

JAVA核心技术-CoreJava(第八版)随书源码(上下卷全)

资源截图

代码片段和文件信息

import java.awt.EventQueue;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;

/**
 * A program for viewing images.
 * @version 1.22 2007-05-21
 * @author Cay Horstmann
 */
public class ImageViewer
{
   public static void main(String[] args)
   {
      EventQueue.invokeLater(new Runnable()
         {
            public void run()
            {
               Jframe frame = new ImageViewerframe();
               frame.setDefaultCloseOperation(Jframe.EXIT_ON_CLOSE);
               frame.setVisible(true);
            }
         });
   }
}

/**
 * A frame with a label to show an image.
 */
class ImageViewerframe extends Jframe
{
   public ImageViewerframe()
   {
      settitle(“ImageViewer“);
      setSize(DEFAULT_WIDTH DEFAULT_HEIGHT);

      // use a label to display the images
      label = new JLabel();
      add(label);

      // set up the file chooser
      chooser = new JFileChooser();
      chooser.setCurrentDirectory(new File(“.“));

      // set up the menu bar
      JMenuBar menuBar = new JMenuBar();
      setJMenuBar(menuBar);

      JMenu menu = new JMenu(“File“);
      menuBar.add(menu);

      JMenuItem openItem = new JMenuItem(“Open“);
      menu.add(openItem);
      openItem.addActionListener(new ActionListener()
         {
            public void actionPerformed(ActionEvent event)
            {
               // show file chooser dialog
               int result = chooser.showOpenDialog(null);

               // if file selected set it as icon of the label
               if (result == JFileChooser.APPROVE_OPTION)
               {
                  String name = chooser.getSelectedFile().getPath();
                  label.setIcon(new ImageIcon(name));
               }
            }
         });

      JMenuItem exitItem = new JMenuItem(“Exit“);
      menu.add(exitItem);
      exitItem.addActionListener(new ActionListener()
         {
            public void actionPerformed(ActionEvent event)
            {
               System.exit(0);
            }
         });
   }

   private JLabel label;
   private JFileChooser chooser;
   private static final int DEFAULT_WIDTH = 300;
   private static final int DEFAULT_HEIGHT = 400;
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件     163184  2007-04-07 09:35  corejava8\corejava8\gutenberg\alice30.txt

     文件    2689721  2007-04-07 09:35  corejava8\corejava8\gutenberg\crsto10.txt

     文件      45724  2000-10-04 14:08  corejava8\corejava8\v1ch02\ImageViewer\Cay.gif

     文件       2278  2008-02-26 21:15  corejava8\corejava8\v1ch02\ImageViewer\ImageViewer.java

     文件      21997  2002-06-19 12:09  corejava8\corejava8\v1ch02\ImageViewer\mug.png

     文件      20132  2000-10-04 14:08  corejava8\corejava8\v1ch02\ImageViewer\Tower.gif

     文件        440  2007-04-08 11:09  corejava8\corejava8\v1ch02\Welcome\Welcome.java

     文件        141  2007-06-13 07:36  corejava8\corejava8\v1ch02\Welcomeapplet\java.policy.applet

     文件        582  2004-09-06 14:57  corejava8\corejava8\v1ch02\Welcomeapplet\Welcomeapplet.html

     文件       1647  2007-06-13 07:38  corejava8\corejava8\v1ch02\Welcomeapplet\Welcomeapplet.java

     文件        941  2007-04-08 11:11  corejava8\corejava8\v1ch03\BigIntegerTest\BigIntegerTest.java

     文件       1624  2007-04-08 11:11  corejava8\corejava8\v1ch03\CompoundInterest\CompoundInterest.java

     文件        273  2007-04-08 11:20  corejava8\corejava8\v1ch03\FirstSample\FirstSample.java

     文件        603  2007-04-08 11:13  corejava8\corejava8\v1ch03\InputTest\InputTest.java

     文件       1026  2007-04-08 11:06  corejava8\corejava8\v1ch03\LotteryArray\LotteryArray.java

     文件       1305  2007-04-08 11:20  corejava8\corejava8\v1ch03\LotteryDrawing\LotteryDrawing.java

     文件        779  2007-04-08 11:07  corejava8\corejava8\v1ch03\LotteryOdds\LotteryOdds.java

     文件       1038  2007-04-08 11:14  corejava8\corejava8\v1ch03\Retirement\Retirement.java

     文件       1146  2007-04-08 11:15  corejava8\corejava8\v1ch03\Retirement2\Retirement2.java

     文件       2119  2007-04-07 21:28  corejava8\corejava8\v1ch04\CalendarTest\CalendarTest.java

     文件       1785  2007-04-08 11:20  corejava8\corejava8\v1ch04\ConstructorTest\ConstructorTest.java

     文件       1564  2007-04-08 11:16  corejava8\corejava8\v1ch04\EmployeeTest\EmployeeTest.java

     文件        954  2007-04-08 11:20  corejava8\corejava8\v1ch04\PackageTest\com\horstmann\corejava\Employee.java

     文件        717  2007-04-08 11:18  corejava8\corejava8\v1ch04\PackageTest\PackageTest.java

     文件       2355  2007-04-08 11:19  corejava8\corejava8\v1ch04\ParamTest\ParamTest.java

     文件       1609  2007-04-08 11:20  corejava8\corejava8\v1ch04\StaticTest\StaticTest.java

     文件       2388  2007-04-09 16:54  corejava8\corejava8\v1ch05\ArrayGrowTest\ArrayGrowTest.java

     文件       1549  2007-04-09 11:12  corejava8\corejava8\v1ch05\ArrayListTest\ArrayListTest.java

     文件        894  2007-04-09 16:19  corejava8\corejava8\v1ch05\EnumTest\EnumTest.java

     文件       3902  2007-04-09 11:12  corejava8\corejava8\v1ch05\EqualsTest\EqualsTest.java

............此处省略787个文件信息

评论

共有 条评论