driver.java
来自「Java程序设计(美) David D. Riley著 机械工业出版社 书籍配套」· Java 代码 · 共 36 行
JAVA
36 行
import java.io.*;import javax.swing.JFrame;/** Program to write to a new binary file, called example.obj (Figure 13.25) * This file stores a single AWindow object. * Author: David Riley * Date: January, 2005 */public class Driver { public Driver() { JFrame window; Oval dot; window = new JFrame("Persistant Objects"); window.setBounds(10, 10, 300, 200); window.setVisible(true); window.setLayout(null); dot = new Oval(125, 75, 50, 50); window.add(dot, 0); window.repaint(); try{ FileOutputStream outStream; ObjectOutputStream objStream; outStream = new FileOutputStream( "example.obj" ); objStream = new ObjectOutputStream( outStream ); objStream.writeObject( window ); objStream.writeObject( dot ); objStream.flush(); objStream.close(); } catch (IOException e) { System.out.println("ERROR writing." ); } }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?