Folge dem Video um zu sehen, wie unsere Website als Web-App auf dem Startbildschirm installiert werden kann.
Anmerkung: Diese Funktion ist in einigen Browsern möglicherweise nicht verfügbar.
import java.awt.Component;
import javax.swing.JFrame;
import javax.swing.JProgressBar;
public class MyProgressBar {
static JFrame frame = new JFrame();
static JProgressBar progressBar = new JProgressBar();
MyProgressBar(boolean isIndeterminate, Component parent, boolean isAlwaysOnTop){
progressBar.setIndeterminate(isIndeterminate);
frame.add(progressBar);
frame.pack();
frame.setLocationRelativeTo(parent);
frame.setAlwaysOnTop(isAlwaysOnTop);
frame.setVisible(true);
}
public static void disableMyProgressBar(){
frame.setVisible(false);
}
}
btn_pbar_ja.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae) {
pbar.dispose();
new MyProgressBar(true,PrintM0100.my_dialog,true);
EventQueue.invokeLater( new Runnable()
{
public void run() {
createReport();
}
} );
EventQueue.invokeLater( new Runnable()
{
public void run() {
MyProgressBar.disableMyProgressBar();
}
} );
}
});
btn_pbar_ja.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae) {
pbar.dispose();
new MyProgressBar(true,PrintM0100.my_dialog,true);
new Thread() {
@Override public void run() {
setPriority( Thread.MIN_PRIORITY );
float filesize = 0;
while (filesize != MyFile.getFileSize(path_name) || filesize == 0) {
try { Thread.sleep(2000); }
catch (InterruptedException ex) {}
// das wir alle 2 sekunden ausgegeben.. also funktionieren tuts
System.out.println("****" + path_name);
System.out.println("****" + MyFile.getFileSize(path_name));
// aber die ProgressBar wird nicht neu gezeichnet!!
MyProgressBar.frame.validate();
MyProgressBar.frame.repaint();
filesize = MyFile.getFileSize(path_name);
}
}
}.start();
EventQueue.invokeLater( new Runnable()
{
public void run() {
createReport();
}
} );
EventQueue.invokeLater( new Runnable()
{
public void run() {
MyProgressBar.disableMyProgressBar();
}
} );
}
});
public class MyJRExportProgressMonitor implements JRExportProgressMonitor {
public void afterPageExport() {
System.out.println("PDF ist fertig");
}
}
JRPdfExporter exporter = new JRPdfExporter();
exporter.setParameter(JRExporterParameter.INPUT_FILE_NAME, filledReportFileName);
exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, pdfFileName);
exporter.setParameter(JRPdfExporterParameter.IS_COMPRESSED, Boolean.TRUE);
exporter.setParameter(JRExporterParameter.PROGRESS_MONITOR, new MyJRExportProgressMonitor());
exporter.exportReport();
// HTML erzeugen und anzeigen
private static void createHTML() {
path_name = MyParam.getPath_TEMP_REPORTS() + "\\Artikel_"+System.nanoTime()+".html";
try{
JRHtmlExporter exporter = new JRHtmlExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, path_name);
exporter.setParameter(JRExporterParameter.PROGRESS_MONITOR, new MyProgressBar(true,PrintM0100.my_dialog,true));
exporter.exportReport();
}catch(Exception ex){
JOptionPane.showMessageDialog(null, "EXCEPTION : JHSWView/createHTML \nFehler beim erstellen des HTML-Files");
}
showReport(path_name);
}
//RTF erzeugen und anzeigen
private static void createRTF() {
path_name = MyParam.getPath_TEMP_REPORTS() + "\\Artikel_"+System.nanoTime()+".rtf";
try{
JRRtfExporter exporter = new JRRtfExporter ();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, path_name);
exporter.setParameter(JRExporterParameter.PROGRESS_MONITOR, new MyProgressBar(true,PrintM0100.my_dialog,true));
exporter.exportReport();
}catch(Exception ex){
JOptionPane.showMessageDialog(null, "EXCEPTION : JHSWView/createRTF \nFehler beim erstellen des RTF-Files");
}
showReport(path_name);
}
btn_pbar_ja.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae) {
pbar.dispose();
new MyProgressBar(true,PrintM0100.my_dialog,true);
new Thread() {
@Override public void run() {
//setPriority( Thread.MIN_PRIORITY );
createReport();
}
}.start();
}
});
import java.awt.Component;
import javax.swing.JFrame;
import javax.swing.JProgressBar;
import javax.swing.JSlider;
import net.sf.jasperreports.engine.export.JRExportProgressMonitor;
public class MyProgressBar implements JRExportProgressMonitor {
static JFrame frame = new JFrame();
static JProgressBar progressBar = new JProgressBar();
static JSlider slider;
static int value = 0;
MyProgressBar(boolean isIndeterminate, Component parent, boolean isAlwaysOnTop){
progressBar.setIndeterminate(isIndeterminate);
frame.add(progressBar);
frame.pack();
frame.setLocationRelativeTo(parent);
frame.setAlwaysOnTop(isAlwaysOnTop);
frame.setVisible(true);
}
@Override
public void afterPageExport() {
frame.setVisible(false);
}
}
private static void createRTF() {
try{
JRRtfExporter exporter = new JRRtfExporter ();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, path_name);
exporter.setParameter(JRExporterParameter.PROGRESS_MONITOR, new MyProgressBar(true,PrintM0100.my_dialog,true));
exporter.exportReport();
}catch(Exception ex){
JOptionPane.showMessageDialog(null, "EXCEPTION : JHSWView/createRTF \nFehler beim erstellen des RTF-Files");
}
showReport(path_name);
// jetzt wird einfach hier die ProgressBar unsichtbar gemacht
MyProgressBar.frame.setVisible(false);
}