Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

jEditorPane drucken

Empfohlene Antworten

Veröffentlicht

Hallo ma wieder!

Bin grad am probieren eine mit HTML gefülltes EditorPane auszudrucken.

Eine normale jTextArea hab ich schon allein zum Ausdruck gebracht, aber hier scheiter ich. Meine vorgehensweise für die TextArea war so:

Ich hab ne Klasse Druck gebildet und die mit JTextArea erweitert.

import java.awt.print.*;

import java.awt.*;

import javax.swing.JTextArea;

public class Druck extends JTextArea implements Printable {

public int print(Graphics g, PageFormat pf, int pi) throws PrinterException

{

if(pi >= 1)

return Printable.NO_SUCH_PAGE;

Graphics2D g2d = (Graphics2D) g;

g2d.translate(pf.getHeight(),pf.getWidth());

paintComponent(g2d);

return Printable.PAGE_EXISTS;

}

}

Und dann mit nem Pjob die TextArea drucken lassen.

PrinterJob pjob = PrinterJob.getPrinterJob();

pjob.setPrintable(jTextArea1);

if(pjob.printDialog() == true)

{

try{

pjob.print();

}

catch(Exception except)

{

System.out.println("Fehler beim Drucken");

}

}

}

Leider geht das bei der EditorPane nicht.

Hier sagt er mir, dass bei pjob.setPrintable(jEditorPane1) er die Methode nicht findet.

Kann mir jemand helfen, am besten mit Source Code?

Die nächste Hürde wäre dann das ganze vorformatiert auf Din A 5 zu drucken.

Vielen Dank!

General Chang

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.