java编程感悟01

时间:2023-03-09 08:39:14
java编程感悟01

很多职位都要求有极强的编程能力,在学习编程的过程中可能很累,可能想有新认识,你可以将编程看做通关模式,以此鼓励自己不断的学习。

jsp中注册时的验证码就需要javaSE的编程功底,如果这个会了,验证码就很简单了。现在想想,关于awt编程一点都不记得了

package main_java;
import javax.swing.JFrame;
public class DrawString extends JFrame {
private static final long serialVersionUID = 1L;
DrawString ds;
String title="the GUI program";
public DrawString() {}
public DrawString(String t) {
//setDefaultCloseOperation()是实例方法,应该由对象调用,而不是这样。
ds=new DrawString();
ds.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
ds.setBounds(0,0,400,300);
t=title;
ds.setTitle(t);
ds.setVisible(true);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
DrawString ds1=new DrawString("gg");
ds1.setVisible(true);
ds1.setSize(300, 600);
} }

这是一个编写很混乱的程序,在此只想说编程是设计,不是片段的随意叠加,要设计好一个程序,要掌握一些模板,再次基础上改进。同时还要注意加载类和加载对象的区别,在此过程中我考虑到了jvm编译的过程,可以说慢慢深入到底层的实现。

实现图片的旋转功能:

import java.awt.geom.AffineTransform;
AffineTransformOp op=new AffineTransformOp(AffineTransform.getScaleInstance(sx,sy),null);//定义转换方法;
BufferedImage bf=op.filter(bi,null);
// 转换后的图片缓存。
ImageIO.write(bf,"jpg",flie1);
//将图片写入缓存

图片装换都是这种模式,变化的是AffineTransform.getXxxInstance();