Skip to Content
0
Former Member
Feb 11, 2010 at 09:25 AM

Popups not centered when adding ReportViewerBean to JDialog

21 Views

This issue follows on from ReportViewerBean popup dialogs not located correctly

When running ReportViewerBean from a JDialog, the Export dialog and other popups locate top-left on the screen instead of being centered over the Panel. The code listing below illustrates a standalone JDialog but the requirement is for the JDialog (which contains the RVB) to be owned by a JFrame.

When a JFrame is used to contain the RVB instead of the dialog, it works as expected - all popup dialogs center.

      ReportViewerBean b = new ReportViewerBean();
      // ... bean config code
      JDialog d = new JDialog();
      //JFrame f = new JFrame(); // works
      d.setTitle("JRC Test");
      d.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
          System.exit(0);
        }
      });
      d.add(b, BorderLayout.CENTER);
      d.setSize(new Dimension(800, 500));
      d.setLocationRelativeTo(null);
      b.init();
      b.start();
      d.setVisible(true);