Skip to main content

JXErrorPane

2 replies [Last post]
Spinnifex
Offline
Joined: 2011-03-29
Points: 0

Hello,

The error pane is not working for me.

I first tryed
showInternalFrame(java.lang.Throwable e)
inside an internal frame. Nothing happens...

Then I tryed
showFrame(java.lang.Throwable e)
inside the internal frame. A new frame opens but with bugs.
The close or whatever buttons got no text.
I only see two little round buttons... don't know what they mean.

Reading the Javadoc didn't help much.

Some strange code I found for ErrorInfo.
copied from the javadoc

String message = "An error occured on ${os.name} version ${os.version}";
    //auto creates the state map, populated with all System properties.
    //Sandboxed apps can't read System properties.
    ErrorInfo info = new ErrorInfo("Error", exception);
    message = info.substituteVariables(message);

    //prints out: "An error occured on Mac OS X version 10.4.7" on some systems
    log.info(message);

The strange this here is, that the method
substituteVariables is not listet in the method section ...

Any Ideas?

Regards,

Spinni

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
kschaefe
Offline
Joined: 2006-06-08
Points: 0

That doesn't appear to be the latest version of the ErrorInfo JavaDoc. I am not having any trouble bringing up a frame with the exception contents.

Can you post a small demo? Also, what OS and version of Java are you using?

Karl

Spinnifex
Offline
Joined: 2011-03-29
Points: 0

Hi Karl,

Sorry for the late reply...

Now I got a little demo, where you (maybe) can see what I mean.
I use WindowsXP SP3 with different Java Versions. The problem occured
with Java 1.6

Here ist the demo:
First the main-class

import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import tester.ui.MainFrame;

/**
*
* @author OhneAngabe
*/
public class Tester {

    private static void setLookAndFeel() {
        try {
            UIManager.setLookAndFeel( "com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel" );
            //UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() );
            //UIManager.setLookAndFeel( "com.sun.java.swing.plaf.metal.MetalLookAndFeel" );
        } catch (ClassNotFoundException cnfe) {
        } catch (InstantiationException ie) {
        } catch (IllegalAccessException iae) {
        } catch (UnsupportedLookAndFeelException uslfe) {
        }
    }

    /**
     * @param args the command line arguments
     */
    public static void main( String[] args ) {

        setLookAndFeel();

        SwingUtilities.invokeLater( new Runnable() {

            @Override
            public void run() {
                new MainFrame( "Test" );
            }
        } );
    }
}

and the the ui-class ( MainFrame.java )

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.logging.Level;
import javax.swing.JComponent;
import org.jdesktop.swingx.JXButton;
import org.jdesktop.swingx.JXErrorPane;
import org.jdesktop.swingx.JXFrame;
import org.jdesktop.swingx.error.ErrorInfo;

/**
*
* @author OhneAngabe
*/
public class MainFrame extends JXFrame implements ActionListener {
   
    private JXButton showErrorPaneB;
   
    public MainFrame( final String title ) {
        super( title, true );
       
        createMainFrame();
        setVisible( true );
    }
   
    private void createMainFrame() {
        setSize( 200, 200 );
        setLocationRelativeTo( null );
        setLayout( new BorderLayout() );
       
        showErrorPaneB = new JXButton( "Help" );
        showErrorPaneB.addActionListener( this );
       
        add( showErrorPaneB, BorderLayout.CENTER );
    }

    public static void showErrorDialog( final JComponent parentComponent,
            final String headerText, final String basicInfoText,
            final String detailedInfoText, final String cat,
            final Throwable reason )  {
        JXErrorPane errorPane = new JXErrorPane();

        ErrorInfo ei = new ErrorInfo( headerText, basicInfoText,
                detailedInfoText, cat, reason, Level.WARNING, null );

        errorPane.setErrorInfo( ei );

        JXErrorPane.showDialog( parentComponent, errorPane );
    }
   
    @Override
    public void actionPerformed( ActionEvent ae ) {
        if( ae.getSource() ==  showErrorPaneB ) {
            showErrorDialog( null, "Warning", "Some Error", "", "Cat 1", new NullPointerException() );
        }
    }
}

Regards,

Spinni