?
Solved

JDialog based dialogs with problems related using JasperReports

Posted on 2006-06-10
25
Medium Priority
?
2,311 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 10
  • 7
  • 6
  • +1
25 Comments
 
LVL 14

Expert Comment

by:hoomanv
ID: 16877413
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
ID: 16877720
yes, because I need set up some controls, like textfield, checkboxes, etc.

So! how can I do
0
 
LVL 14

Expert Comment

by:hoomanv
ID: 16877912
can you set it to non-modal ?
Dialog.setModal(false)
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 26

Expert Comment

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

Expert Comment

by:Mayank S
ID: 16880246
>> 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
ID: 16885326
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:Mayank S
ID: 16886015
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
ID: 16887023
mayankeagle, can you put a bit of code about it?
0
 
LVL 26

Expert Comment

by:ksivananth
ID: 16887155
set the JDialog as the parent for the Jasper report viewer.
0
 

Author Comment

by:accarvajal
ID: 16889626
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
ID: 16889669
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:Mayank S
ID: 16891765
>> can you put a bit of code about it?

yourJDialog.setModal ( false ) ;
0
 

Author Comment

by:accarvajal
ID: 16897464
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:Mayank S
ID: 16899879
>> m_dlgContenedor.dispose(); // JDialog Container

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

Expert Comment

by:ksivananth
ID: 16900138
>>JasperViewer (JFrame)

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

Author Comment

by:accarvajal
ID: 16902621
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
ID: 16902671
Please, look at this for API documentation:

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

Expert Comment

by:Mayank S
ID: 16909593
>>  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
ID: 16912357
>> 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:Mayank S
ID: 16912389
>> 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 800 total points
ID: 16912612
try this,

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

Author Comment

by:accarvajal
ID: 16914867
>> 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:Mayank S
ID: 16917636
Try calling validate () after calling setModal ()
0
 
LVL 26

Expert Comment

by:ksivananth
ID: 16922254
did u try the code I posted?
0
 

Author Comment

by:accarvajal
ID: 16923967
I'll try today or tomorrow
0

Featured Post

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month14 days, 10 hours left to enroll

771 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