Skip to main content

Problem with ProgressMonitor

1 reply [Last post]
mu88
Offline
Joined: 2012-08-30

Good evening,

I've written a Java3D-application which implements a lot of functionalities, so I make use of Swing-Components like Menubars, Toolbars, etc. Unfortunately, Java3D uses a Canvas which is derived from AWT.
To display the progress of a procedure, I use a ProgressMonitor. This results in the attached image: the ProgressMonitor is visible, but you can't see it's content!
Am I right with the presumption that this is caused by the mixture of Swing and AWT?
Is there any solution?

Kind regards and thanks in advance!

AttachmentSize
Java3D_Bezier.jpg96.25 KB

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
mu88
Offline
Joined: 2012-08-30

Would anybody please try this code and tell me what he sees when clicking on "test"?

import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.ProgressMonitor;


public class MainFrame extends JFrame implements ActionListener
{
JMenuItem menu_item_test;

public MainFrame()
{
menu_item_test = new JMenuItem("Test");
        menu_item_test.addActionListener(this);
       
        JMenu menu_test = new JMenu("Test");
        menu_test.add(menu_item_test);
       
        JMenuBar menuBar = new JMenuBar();
        menuBar.add(menu_test);
        setJMenuBar(menuBar);
       
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
pack();
setVisible(true);
testProgressMonitor(null);
}

public static void main(String[] args)
{
new MainFrame();
}

public void actionPerformed(ActionEvent e)
{
if (e.getSource() == menu_item_test)
{
testProgressMonitor((Component)menu_item_test);
}
}

public void testProgressMonitor(Component parent)
{
int max = 200000;
ProgressMonitor progress_monitor = new ProgressMonitor(null, "", "", 0, max);
progress_monitor.setNote("Assigning Continuity");
        for (int i = 0; i < max; i++)
        {
        progress_monitor.setProgress(i);
        System.out.println(i);
        }
        progress_monitor.close();
}
}