一.AWT组件开发 1.AWT AWT是抽象窗口工具箱的缩写,它为编写图形用户界面提供了用户接口,通过这个接口就可以继承很多方法,省去了很多工作.AWT还能使应用程序更好地同用户进行交互. AWT中的容器是一种特殊的组件,他可以包含其他组件,即可以把组件方法容器中.Container类是用来存放其他组件的Component类的子类,Frame类又是Component的子类.Frame类用于创建具有标题栏和边界的窗口.这里通过继承Frame类来建立自己的界面. public class test
1. 组件与容器 容器就是窗口和面板,而组件为按钮.文本域.标签等(待续),二者的声明.设置很相似, 因此本文只做对于容器的详解.组件与容器的区别在于组件不能做容器,而部分容器可以兼顾组件和容器的特性 1.1 Frame(窗口) 属于容器,不可作为组件添加至其他容器中 声明 Frame frame = new Frame(); 基本方法 public void setBounds(int x, int y, int width, int height);//设置窗口的初始位置和大小,可参照电脑屏
import java.awt.AWTException; import java.awt.Robot; import java.awt.event.KeyEvent; public class TestRobot { Robot man; public static void main(String[] args) throws AWTException { new TestRobot(); } public TestRobot() throws AWTException { man = ne
最近碰到一个问题: 64位linux报错Could not initialize class java.awt.image.BufferedImage 在WIN平台下运行正常BufferedImage tag = new BufferedImage(this.width,this.height,BufferedImage.TYPE_USHORT_555_RGB); tag.getGraphics().drawImage(src,0,0,this.width,this.height
今天上午打印回单功能发布到测试环境,报了: class java.awt.HeadlessException : No X11 DISPLAY variable was set, but this program performed an operation which requires it. 异常,经查询发现网上解决方案不少,其中解决办法大致如下: export DISPLAY=:0.0 上面配置环境变量DIAPLAY,值为:0.0就解决了当前问题. 在这里要介绍下另一种方式 export