java怎样通过代码选取打印机的不同纸盒进行打印,两个纸盒都是B5,只不过空白纸样式不一样。
https://blog.csdn.net/xuehyunyu/article/details/77196475
//定义打印机
InkBox inkbox=null;
Paper paper=null;
Printer printer =new Printer();
//使用黑白墨盒在A4纸上打印
inkbox=new GrayInkBox();
paper=new A4Paper();
printer.setInkBox(inkbox);
printer.srtParper(paper);
printer.print();
//使用彩色墨盒在B5纸上打印
inkbox=new ColorInkBox();
paper=new B5Paper();
printer.setInkBox(inkbox);
printer.srtParper(paper);
printer.print();
//使用彩色墨盒在A4纸上打印
paper=new A4Paper();
printer.srtParper(paper);
printer.print();