Solved

JDialog based dialogs with problems related using JasperReports

Posted on 2006-06-10
25
2,223 Views
Last Modified: 2009-04-26
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
Comment
Question by:accarvajal
  • 10
  • 7
  • 6
  • +1
25 Comments
 
LVL 14

Expert Comment

by:hoomanv
Comment Utility
the dialog is in modal mode
When a modal dialog is visible, it blocks user input to all other windows in the program
0
 

Author Comment

by:accarvajal
Comment Utility
yes, because I need set up some controls, like textfield, checkboxes, etc.

So! how can I do
0
 
LVL 14

Expert Comment

by:hoomanv
Comment Utility
can you set it to non-modal ?
Dialog.setModal(false)
0
 
LVL 26

Expert Comment

by:ksivananth
Comment Utility
or you can extract the content panel from the jasper viewer and add to the dialog!
0
 
LVL 30

Expert Comment

by:mayankeagle
Comment Utility
>> 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
 

Author Comment

by:accarvajal
Comment Utility
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
 
LVL 30

Expert Comment

by:mayankeagle
Comment Utility
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
 

Author Comment

by:accarvajal
Comment Utility
mayankeagle, can you put a bit of code about it?
0
 
LVL 26

Expert Comment

by:ksivananth
Comment Utility
set the JDialog as the parent for the Jasper report viewer.
0
 

Author Comment

by:accarvajal
Comment Utility
Mayankeagle, reason JDialog does need to be active, is because JDialog is used for data maintenance, insert, update, delete and report
0
 
LVL 26

Expert Comment

by:ksivananth
Comment Utility
can you post the code which launches the report viewer and dialog so that we can correct if anything is wrong!
0
 
LVL 30

Expert Comment

by:mayankeagle
Comment Utility
>> can you put a bit of code about it?

yourJDialog.setModal ( false ) ;
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:accarvajal
Comment Utility
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
 
LVL 30

Expert Comment

by:mayankeagle
Comment Utility
>> m_dlgContenedor.dispose(); // JDialog Container

m_dlgContenedor.setModal ( false ) ; // JDialog Container
0
 
LVL 26

Expert Comment

by:ksivananth
Comment Utility
>>JasperViewer (JFrame)

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

Author Comment

by:accarvajal
Comment Utility
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
 

Author Comment

by:accarvajal
Comment Utility
Please, look at this for API documentation:

http://jasperreports.sourceforge.net/api/index.html
0
 
LVL 30

Expert Comment

by:mayankeagle
Comment Utility
>>  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
 

Author Comment

by:accarvajal
Comment Utility
>> 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
 
LVL 30

Expert Comment

by:mayankeagle
Comment Utility
>> 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
 
LVL 26

Accepted Solution

by:
ksivananth earned 200 total points
Comment Utility
try this,

JDialog dialog = new JDialog( m_dlgContenedor ) ;
dialog.setContentPane( jasperViewer.getContentPane() ) ;
dialog.setSize( jasperViewer.getSize() ) ;
dialog.setVisible( true ) ;
0
 

Author Comment

by:accarvajal
Comment Utility
>> 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
 
LVL 30

Expert Comment

by:mayankeagle
Comment Utility
Try calling validate () after calling setModal ()
0
 
LVL 26

Expert Comment

by:ksivananth
Comment Utility
did u try the code I posted?
0
 

Author Comment

by:accarvajal
Comment Utility
I'll try today or tomorrow
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now