本文整理了Java中javax.swing.JEditorPane.print()
方法的一些代码示例,展示了JEditorPane.print()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JEditorPane.print()
方法的具体详情如下:
包路径:javax.swing.JEditorPane
类名称:JEditorPane
方法名:print
暂无
代码示例来源:origin: stackoverflow.com
public class HTMLPrinter implements Printable{
private final JEditorPane printPane;
public HTMLPrinter(JEditorPane editorPane){
printPane = editorPane;
}
public int print(Graphics graphics, PageFormat pageFormat, int pageIndex){
if (pageIndex >= 1) return Printable.NO_SUCH_PAGE;
Graphics2D g2d = (Graphics2D)graphics;
g2d.setClip(0, 0, (int)pageFormat.getImageableWidth(), (int)pageFormat.getImageableHeight());
g2d.translate((int)pageFormat.getImageableX(), (int)pageFormat.getImageableY());
RepaintManager rm = RepaintManager.currentManager(printPane);
boolean doubleBuffer = rm.isDoubleBufferingEnabled();
rm.setDoubleBufferingEnabled(false);
printPane.setSize((int)pageFormat.getImageableWidth(), 1);
printPane.print(g2d);
rm.setDoubleBufferingEnabled(doubleBuffer);
return Printable.PAGE_EXISTS;
}
}
代码示例来源:origin: stackoverflow.com
JEditorPane text = new JEditorPane("file:///D:/abc.txt");
PrintService service = PrintServiceLookup.lookupDefaultPrintService();
text.print(null, null, false, service, null, false);
代码示例来源:origin: stackoverflow.com
JEditorPane text = new JEditorPane("file:///D:/abc.txt");
text.print(null, null, true, null, null, false);
代码示例来源:origin: stackoverflow.com
public static void main(String[] args) throws PrintException, IOException, PrinterException {
JEditorPane editorPane = new JEditorPane();
editorPane.setEditable(false);
URL urlToPage = new File("/home/me/Temp/page.html").toURI().toURL();
editorPane.setPage(urlToPage);
editorPane.print(null, null, false, PrintServiceLookup.lookupDefaultPrintService(), null, false);
}
代码示例来源:origin: igniterealtime/Spark
/**
* print(JEditorPane) prints a Document contained within a JEditorPane.
*
* @param jedPane the JEditorPane to print.
*/
public void print(JEditorPane jedPane) {
try {
jedPane.print();
}
catch(java.awt.print.PrinterException pe)
{
System.err.printf("Error: %s!\n",pe.toString());
}
}
代码示例来源:origin: stackoverflow.com
public static void print(File file) {
JFrame frame = new JFrame();
JEditorPane pane= new JEditorPane();
pane.setContentType("text/html");
try{
pane.setPage(file.toURI().toURL());
}catch (IOException ex){
System.out.println("MALFORMED ERROR!");
}
frame.add(pane);
frame.setSize(200,200);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
try{
pane.print(null, null, false, PrintServiceLookup.lookupDefaultPrintService(), null, false);
} catch (Exception e){
System.out.println("PRINT ERROR!");
}
}
代码示例来源:origin: stackoverflow.com
public class Example1 {
private static final int WIDTH = 1204;
private static final int HEIGHT = 768;
public static void main(String[] args) throws IOException {
// open HTML page
JEditorPane editorPane = new JEditorPane();
editorPane.setEditable(false);
URL urlToPage = new File("/home/me/Temp/cover.html").toURI().toURL();
editorPane.setPage(urlToPage);
editorPane.setSize(WIDTH, HEIGHT);
// render the page
BufferedImage renderedImage = new BufferedImage(640, 480, BufferedImage.TYPE_INT_RGB);
editorPane.print(renderedImage.getGraphics());
// write result to file
ImageIO.write(renderedImage, "PNG", new File("/home/me/Temp/hello-world.png"));
}
}
代码示例来源:origin: org.owasp.jbrofuzz/jbrofuzz
public void actionPerformed(final ActionEvent aEvent) {
try {
final boolean complete = helpPane.print();
if (!complete) {
Logger.log("User cancelled Printing", 1);
}
} catch (final PrinterException prException) {
Logger.log("A Printing Exception Occured", 4);
}
}
});
内容来源于网络,如有侵权,请联系作者删除!