import java.awt.*; import DialogLayout; public class ExceptionDialog extends CloseableDialog { boolean init = false; String msg=""; DialogLayout m_Layout; // Control definitions //-------------------------------------------------------------------------- Button OkayButton; MultiLineLabel ExceptionLabel; // Constructor //-------------------------------------------------------------------------- public ExceptionDialog (Frame parent, Exception e) { this(parent,e.getClass()+"\n"+e.getMessage()); } public ExceptionDialog (Frame parent, String msg) { super(parent, "Exception", true); setResizable(false); this.msg=msg; CreateControls(); } // Initialization. //-------------------------------------------------------------------------- public boolean CreateControls() { // CreateControls should be called only once //---------------------------------------------------------------------- if (init) return false; // Since a given font may not be supported across all platforms, it // is safe to modify only the size of the font, not the typeface. //---------------------------------------------------------------------- Font OldFnt = this.getFont(); if (OldFnt != null) { Font NewFnt = new Font(OldFnt.getName(), OldFnt.getStyle(), 8); this.setFont(NewFnt); } // All position and sizes are in dialog logical units, so we use a // DialogLayout as our layout manager. //---------------------------------------------------------------------- m_Layout = new DialogLayout(this, 311, 115); this.setLayout(m_Layout); this.addNotify(); Dimension size = m_Layout.getDialogSize(); Insets insets = this.insets(); this.resize(insets.left + size.width + insets.right, insets.top + size.height + insets.bottom); // Control creation //---------------------------------------------------------------------- OkayButton = new Button ("Okay"); this.add(OkayButton); m_Layout.setShape(OkayButton, 131, 94, 50, 14); ExceptionLabel = new MultiLineLabel (msg, Label.CENTER); this.add(ExceptionLabel); m_Layout.setShape(ExceptionLabel, 7, 7, 297, 70); //this.pack(); init = true; return true; } public boolean action(Event e, Object arg) { if (e.target==OkayButton) { this.hide(); this.dispose(); return true; } else return super.action(e,arg); } }