001package edu.pdx.cs410J.grader.poa.ui; 002 003import com.google.inject.Inject; 004import com.google.inject.Singleton; 005import edu.pdx.cs410J.grader.poa.UnhandledExceptionView; 006 007import javax.swing.*; 008import java.awt.*; 009 010@Singleton 011public class UnhandledExceptionDialog extends JDialog implements UnhandledExceptionView { 012 013 private final JLabel message; 014 private final JTextArea details; 015 016 @Inject 017 public UnhandledExceptionDialog(TopLevelJFrame parent) { 018 super(parent, "Unhandled Exception Encountered", true); 019 this.setVisible(false); 020 021 this.message = new JLabel(); 022 this.details = new JTextArea(10, 50); 023 this.details.setEditable(false); 024 025 Container content = this.getContentPane(); 026 content.setLayout(new BorderLayout()); 027 028 content.add(this.message, BorderLayout.NORTH); 029 content.add(new JScrollPane(this.details), BorderLayout.CENTER); 030 031 } 032 033 @Override 034 public void setExceptionMessage(String message) { 035 this.message.setText(message); 036 } 037 038 @Override 039 public void setExceptionDetails(String details) { 040 this.details.setText(details); 041 } 042 043 @Override 044 public void displayView() { 045 this.pack(); 046 this.setVisible(true); 047 } 048 049}