asciifileoutframe.java

来自「ASCII图画分类: 图像处理 可以将鼠标画的图象转成ASCII的形式」· Java 代码 · 共 80 行

JAVA
80
字号
//AsciiFileOutFrame.java////hard-coded for exclusive use by AsciiDraw.  Very non-oo.//I'll let you make this entire app make use of generalized library componentspackage joeh.asciidraw;import java.awt.*;public class AsciiFileOutFrame extends Frame {   AsciiDrawPanel adp;   String sampleName = "output.txt";   	String mssgSTR = "Enter the filename:";    Label mssgLabel;    TextField fileNameField;   Checkbox genCode; public AsciiFileOutFrame(int xw, int yh, AsciiDrawPanel p)  {  super("Output file name");  this.resize(xw, yh);    adp = p;  this.setLayout(new BorderLayout(20,20));    mssgLabel = new Label(mssgSTR);  fileNameField = new TextField(sampleName);  fileNameField.setEditable(true);      Panel buttonPanel = new Panel();  buttonPanel.setLayout(new FlowLayout());  buttonPanel.add(new Button("cancel"));  buttonPanel.add(new Button("Save!"));  genCode = new Checkbox("Also attach Java code for the image");  buttonPanel.add(genCode);    this.add("North", mssgLabel);    this.add("Center", fileNameField);  this.add("South", buttonPanel);      fileNameField.selectAll();  fileNameField.requestFocus(); //start being able to type into TextField  }public boolean handleEvent(Event evt) {    switch(evt.id) {                case Event.WINDOW_DESTROY:   //they close the window!             	{              	   dispose();             	   return true;             	}               case Event.ACTION_EVENT:                 {                        if (evt.target instanceof Button)                            if ("Save!".equals(evt.arg))                                  {                                  adp.setDestFile(fileNameField.getText());                                				if (genCode.getState())				  adp.doSave(true, 2);				else				  adp.doSave(true, 1);                                dispose();                                return true;                             }                           if ("cancel".equals(evt.arg))                                  {                	                dispose();             	                return true;                             }		      }             }            return false;    }           }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?