• 大小: 1.53MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-08-12
  • 语言: Java
  • 标签: java  

资源简介

Java核心技术 卷I:基础知识(原书第10版)源代码总共12章

资源截图

代码片段和文件信息

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

/**
 * A program for viewing images.
 * @version 1.30 2014-02-27
 * @author Cay Horstmann
 */
public class ImageViewer
{
   public static void main(String[] args)
   {
      EventQueue.invokeLater(() -> {
         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(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(event -> System.exit(0));
   }
}

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

     文件     163184  2016-11-04 00:08  corejava\gutenberg\alice30.txt

     文件    2689721  2016-11-04 00:08  corejava\gutenberg\crsto10.txt

     文件      77418  2016-11-04 00:08  corejava\v1ch02\ImageViewer\cay.jpg

     文件       2720  2016-11-04 00:08  corejava\v1ch02\ImageViewer\duke.gif

     文件       1111  2017-09-24 15:46  corejava\v1ch02\ImageViewer\ImageViewer.class

     文件       1799  2016-11-04 00:08  corejava\v1ch02\ImageViewer\ImageViewer.java

     文件       2320  2017-09-24 15:46  corejava\v1ch02\ImageViewer\ImageViewerframe.class

     文件      21997  2016-11-04 00:08  corejava\v1ch02\ImageViewer\mug.png

     文件         79  2016-11-04 00:08  corejava\v1ch02\Roadapplet\makejar

     文件       1439  2017-09-24 15:49  corejava\v1ch02\Roadapplet\Road.class

     文件       2131  2017-09-24 15:49  corejava\v1ch02\Roadapplet\Roadapplet.class

     文件       3397  2016-11-04 00:08  corejava\v1ch02\Roadapplet\Roadapplet.html

     文件       3767  2016-11-04 00:08  corejava\v1ch02\Roadapplet\Roadapplet.jar

     文件       1235  2016-11-04 00:08  corejava\v1ch02\Roadapplet\Roadapplet.java

     文件         43  2016-11-04 00:08  corejava\v1ch02\Roadapplet\Roadapplet.mf

     文件       1508  2017-09-24 15:49  corejava\v1ch02\Roadapplet\RoadComponent.class

     文件       3034  2016-11-04 00:08  corejava\v1ch02\Roadapplet\RoadComponent.java

     文件        385  2016-11-04 00:08  corejava\v1ch02\Welcome\Welcome.java

     文件        908  2016-11-04 00:08  corejava\v1ch03\BigIntegerTest\BigIntegerTest.java

     文件       1567  2016-11-04 00:08  corejava\v1ch03\CompoundInterest\CompoundInterest.java

     文件        261  2016-11-04 00:08  corejava\v1ch03\FirstSample\FirstSample.java

     文件        578  2016-11-04 00:08  corejava\v1ch03\InputTest\InputTest.java

     文件        950  2017-09-26 16:55  corejava\v1ch03\LotteryArray\LotteryArray.class

     文件        987  2016-11-04 00:08  corejava\v1ch03\LotteryArray\LotteryArray.java

     文件       1259  2016-11-04 00:08  corejava\v1ch03\LotteryDrawing\LotteryDrawing.java

     文件        749  2016-11-04 00:08  corejava\v1ch03\LotteryOdds\LotteryOdds.java

     文件        999  2016-11-04 00:08  corejava\v1ch03\Retirement\Retirement.java

     文件       1102  2016-11-04 00:08  corejava\v1ch03\Retirement2\Retirement2.java

     文件       1015  2016-11-04 00:08  corejava\v1ch04\CalendarTest\CalendarTest.java

     文件       1087  2017-09-28 17:38  corejava\v1ch04\ConstructorTest\ConstructorTest.class

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

评论

共有 条评论