• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2357
  • Last Modified:

JDialog based dialogs with problems related using JasperReports

Hi!,
 
I developed a software using JFC/Swing java, and my main program is JFrame based, and every menu item executes a JDialog based class. My problem is when JDialog is loaded I press a button which executes JasperViewer to load a report, but I don't know why Jasper Frame is shown and is Locked. I can't use scroll bars nor buttons, nothing at all into jasperViewer. But when I close JDialog, JasperViewer works fine, is unlocked. I note there is certain conflict when into JDialog is going to execute a JFrame.
 
How can I do to use JasperViewer into a JDialog and It not be locked?

I put this question in Jasper Forum but not replies
 
 
thanks
0
accarvajal
Asked:
accarvajal
  • 10
  • 7
  • 6
  • +1
1 Solution
 
hoomanvCommented:
the dialog is in modal mode
When a modal dialog is visible, it blocks user input to all other windows in the program
0
 
accarvajalAuthor Commented:
yes, because I need set up some controls, like textfield, checkboxes, etc.

So! how can I do
0
 
hoomanvCommented:
can you set it to non-modal ?
Dialog.setModal(false)
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
ksivananthCommented:
or you can extract the content panel from the jasper viewer and add to the dialog!
0
 
Mayank SAssociate Director - Product EngineeringCommented:
>> My problem is when JDialog is loaded I press a button which executes JasperViewer to load a report

Is this button on the JDialog? Then you should probably close/ dispose () the JDialog on click of that button after displaying the report.
0
 
accarvajalAuthor Commented:
hoomanv, How can I do to let user input data on controls using non-modal?

Ksivananth, actually I don't know how to do it, I'm newby in jasper reports.

mayankeagle, in fact, now I'm doing that. I'm destroying JDialog before displaying the report. But, I would like not to have to destroy it. It's possible by using threads or another main program?
0
 
Mayank SAssociate Director - Product EngineeringCommented:
Since it is a modal JDialog - no. One thing you could do is make it non-modal after the button-click instead of disposing it, if you still want it to be open. Though I wonder why it still needs to be open.
0
 
accarvajalAuthor Commented:
mayankeagle, can you put a bit of code about it?
0
 
ksivananthCommented:
set the JDialog as the parent for the Jasper report viewer.
0
 
accarvajalAuthor Commented:
Mayankeagle, reason JDialog does need to be active, is because JDialog is used for data maintenance, insert, update, delete and report
0
 
ksivananthCommented:
can you post the code which launches the report viewer and dialog so that we can correct if anything is wrong!
0
 
Mayank SAssociate Director - Product EngineeringCommented:
>> can you put a bit of code about it?

yourJDialog.setModal ( false ) ;
0
 
accarvajalAuthor Commented:
here are a bit of code:

package FrameWork;

import java.util.*;
import java.util.List;
import java.sql.SQLException;
import java.sql.Savepoint;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.text.*;
import javax.swing.*;
import javax.swing.text.*;

import org.jdom.*;
import org.jdom.Document;
import org.jdom.Element;

import com.l2fprod.common.swing.*;
import com.l2fprod.common.swing.plaf.blue.BlueishButtonBarUI;
import com.l2fprod.common.propertysheet.*;
import com.toedter.calendar.*;
import com.toedter.components.JSpinField;
import org.jvnet.substance.*;
import org.jvnet.substance.painter.*;

import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.view.JasperViewer;

import FrameWork.JGrid;
import static FrameWork.Global.*;

public class Controladora extends JPanel implements ActionListener, FocusListener {
      static final long serialVersionUID = 0;
public Controladora(String attrPanelXML, String attrReporte, String attrToolBar, int iPagina) {
            super();
...
}

public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals("REPORTE")) {
   Reporte(); // To Report In Jasper
}

protected void Reporte() {
            m_paramReporte = new HashMap();
            m_dlgContenedor.dispose(); // JDialog Container
            
            try {
                  JasperPrint jasperPrint = JasperFillManager.fillReport(m_sArchivoReporte + ".jasper", m_paramReporte, m_BDConexion);
                  JasperViewer.viewReport(jasperPrint, false);
            } catch (JRException e) {
                  e.printStackTrace();
            }
      }

}
}

NOTE:

* Class controladora extends from JPanel
* This controladora class I add it into JDialog Class

in main program: DialogoPropiedades is a class exitends from JDialog

DialogoPropiedades dlg = new DialogoPropiedades(this, <Controladora pointer class>);

First: Main program is executed.

Second: When Menu Item is clicked, a DialogoPropiedades(JDialog) is constructed passing main class and Controladora(JPanel) class as parameters)

Third: DialogoPropiedades(JDialog) is set visible to true.

Forth: All components into JDialog are visible and available to input

Fifth: When Button for Report is pressed, JasperViewer is Executed and DIalogoPropiedades(JDialog) is disposed.

Sixth: When report finished. JasperViewer (JFrame) is destroyed at clicking X button and DialogPropiedades(JDialog) must be visible to continuing input data.


I hope this help!
0
 
Mayank SAssociate Director - Product EngineeringCommented:
>> m_dlgContenedor.dispose(); // JDialog Container

m_dlgContenedor.setModal ( false ) ; // JDialog Container
0
 
ksivananthCommented:
>>JasperViewer (JFrame)

is this constructor? if so what r the other params it takes?
0
 
accarvajalAuthor Commented:
mayankeagle:

>> m_dlgContenedor.setModal ( false ) ; // JDialog Container

Doesn't work. Only works fine when setDialog is into constructor. At least for me in this way worked. But still continues problem keeping Dialog non-modal.

ksivananth:

>> is this constructor? if so what r the other params it takes?

JasperViewer is a static-class, and only parameters it takes referes to JasperPrint to fill report, or XML parameter file, or String parameter file.
0
 
accarvajalAuthor Commented:
Please, look at this for API documentation:

http://jasperreports.sourceforge.net/api/index.html
0
 
Mayank SAssociate Director - Product EngineeringCommented:
>>  At least for me in this way worked. But still continues problem keeping Dialog non-modal.

Meaning it makes it non-modal after the button-click? That is what you wanted, right?
0
 
accarvajalAuthor Commented:
>> Meaning it makes it non-modal after the button-click? That is what you wanted, right?

What I wanted was, JDialog be modal, launches JasperViewer out of locking it and when finished, JDialog continues modal.

But, setting JDialog as non-modal since contruction, means it does work in non-modal way during life-runtime.

But, setting JDialog as non-modal since just before JasperViewer is launched, doesn't work and JDialog continues as modal and viewer is locked.
0
 
Mayank SAssociate Director - Product EngineeringCommented:
>> launches JasperViewer out of locking it and when finished, JDialog continues modal

Try setting it non-modal, then display the JasperViewer and then again set it modal, if that's what you need.
0
 
ksivananthCommented:
try this,

JDialog dialog = new JDialog( m_dlgContenedor ) ;
dialog.setContentPane( jasperViewer.getContentPane() ) ;
dialog.setSize( jasperViewer.getSize() ) ;
dialog.setVisible( true ) ;
0
 
accarvajalAuthor Commented:
>> Try setting it non-modal, then display the JasperViewer and then again set it modal, if that's what you need.

I tried it. Doesn't work, when I setModal(FALSE) JDialog doesn't change it and continues as modal.
0
 
Mayank SAssociate Director - Product EngineeringCommented:
Try calling validate () after calling setModal ()
0
 
ksivananthCommented:
did u try the code I posted?
0
 
accarvajalAuthor Commented:
I'll try today or tomorrow
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 10
  • 7
  • 6
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now