• 大小:
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2022-12-04
  • 语言: Java
  • 标签: 第九版  

资源简介

java核心技术第九版 高清完整PDF+源代码

资源截图

代码片段和文件信息

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.settitle(“ImageViewer“);
               frame.setDefaultCloseOperation(Jframe.EXIT_ON_CLOSE);
               frame.setVisible(true);
            }
         });
   }
}

/**
 * A frame with a label to show an image.
 */
class ImageViewerframe extends Jframe
{
   private JLabel label;
   private JFileChooser chooser;
   private static final int DEFAULT_WIDTH = 300;
   private static final int DEFAULT_HEIGHT = 400;

   public ImageViewerframe()
   {
      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);
            }
         });
   }
}

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

     文件     163184  2010-03-23 05:54  corejava\gutenberg\alice30.txt

     文件    2689721  2010-03-23 05:54  corejava\gutenberg\crsto10.txt

     文件   53728184  2014-09-22 23:21  corejava\Java核心技术·卷II·高级特征(第9版·英文版).pdf

     文件   12063550  2014-09-22 23:16  corejava\Java核心技术·卷I·高级特征(第9版·英文版).pdf

     文件      45724  2010-03-23 05:54  corejava\v1ch02\ImageViewer\Cay.gif

     文件       2208  2012-06-09 14:46  corejava\v1ch02\ImageViewer\ImageViewer.java

     文件      21997  2010-03-23 05:54  corejava\v1ch02\ImageViewer\mug.png

     文件      20132  2010-03-23 05:54  corejava\v1ch02\ImageViewer\Tower.gif

     文件        422  2012-06-09 14:46  corejava\v1ch02\Welcome\Welcome.java

     文件        141  2010-03-23 05:54  corejava\v1ch02\Welcomeapplet\java.policy.applet

     文件        535  2012-09-03 07:40  corejava\v1ch02\Welcomeapplet\Welcomeapplet.html

     文件       1590  2012-06-09 14:46  corejava\v1ch02\Welcomeapplet\Welcomeapplet.java

     文件        908  2012-06-09 14:46  corejava\v1ch03\BigIntegerTest\BigIntegerTest.java

     文件       1567  2012-06-09 14:46  corejava\v1ch03\CompoundInterest\CompoundInterest.java

     文件        261  2012-06-09 14:46  corejava\v1ch03\FirstSample\FirstSample.java

     文件        578  2012-06-09 14:46  corejava\v1ch03\InputTest\InputTest.java

     文件        987  2012-06-09 14:46  corejava\v1ch03\LotteryArray\LotteryArray.java

     文件       1259  2012-06-09 14:46  corejava\v1ch03\LotteryDrawing\LotteryDrawing.java

     文件        749  2012-06-09 14:46  corejava\v1ch03\LotteryOdds\LotteryOdds.java

     文件        999  2012-06-09 14:46  corejava\v1ch03\Retirement\Retirement.java

     文件       1102  2012-06-09 14:46  corejava\v1ch03\Retirement2\Retirement2.java

     文件       2045  2012-06-09 14:46  corejava\v1ch04\CalendarTest\CalendarTest.java

     文件       1704  2013-08-18 11:13  corejava\v1ch04\ConstructorTest\ConstructorTest.java

     文件       1499  2012-06-09 14:46  corejava\v1ch04\EmployeeTest\EmployeeTest.java

     文件        906  2010-05-14 08:03  corejava\v1ch04\PackageTest\com\horstmann\corejava\Employee.java

     文件        678  2012-09-03 09:08  corejava\v1ch04\PackageTest\PackageTest.java

     文件       2266  2012-06-09 14:46  corejava\v1ch04\ParamTest\ParamTest.java

     文件       1535  2012-06-09 14:46  corejava\v1ch04\StaticTest\StaticTest.java

     文件      23539  2012-05-05 09:38  corejava\v1ch05\.settings\org.eclipse.jdt.core.prefs

     文件         89  2012-05-05 07:35  corejava\v1ch05\.settings\org.eclipse.jdt.ui.prefs

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

评论

共有 条评论