KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > core > gui > scripting > MessageDetailsDialog


1 /*
2  The contents of this file are subject to the Mozilla Public License Version 1.1
3  (the "License"); you may not use this file except in compliance with the License.
4  You may obtain a copy of the License at http://www.mozilla.org/MPL/
5
6  Software distributed under the License is distributed on an "AS IS" basis,
7  WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
8  for the specific language governing rights and limitations under the License.
9
10  The Original Code is "The Columba Project"
11
12  The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
13  Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
14
15  All Rights Reserved.
16  */

17
18 package org.columba.core.gui.scripting;
19
20 import java.awt.BorderLayout JavaDoc;
21 import java.awt.Dialog JavaDoc;
22 import java.awt.FlowLayout JavaDoc;
23 import java.awt.event.ActionEvent JavaDoc;
24 import java.awt.event.ActionListener JavaDoc;
25
26 import javax.swing.BorderFactory JavaDoc;
27 import javax.swing.JDialog JavaDoc;
28 import javax.swing.JLabel JavaDoc;
29 import javax.swing.JPanel JavaDoc;
30 import javax.swing.JScrollPane JavaDoc;
31 import javax.swing.JTextArea JavaDoc;
32
33 import org.columba.core.gui.base.ButtonWithMnemonic;
34 import org.columba.core.scripting.ScriptLogger;
35
36 /**
37  @author Celso Pinto <cpinto@yimports.com> */

38 public class MessageDetailsDialog
39     extends JDialog JavaDoc
40     implements ActionListener JavaDoc
41 {
42     private static final String JavaDoc
43         RES_TITLE = "Log message details",
44         RES_CLOSE = "&Close";
45
46     public MessageDetailsDialog( Dialog JavaDoc owner, ScriptLogger.LogEntry logEntry)
47     {
48         super(owner,RES_TITLE,true);
49         init(logEntry);
50
51         setLocationRelativeTo(getParent());
52
53     }
54
55     private void init(ScriptLogger.LogEntry logEntry)
56     {
57
58         JPanel JavaDoc
59             main = new JPanel JavaDoc(new BorderLayout JavaDoc(10,10)),
60             centerPanel = new JPanel JavaDoc(new BorderLayout JavaDoc(10,5)),
61             buttonPanel = new JPanel JavaDoc(new FlowLayout JavaDoc(FlowLayout.RIGHT));
62
63         JLabel JavaDoc messageLabel = new JLabel JavaDoc(logEntry.getMessage());
64
65         JScrollPane JavaDoc scroll = new JScrollPane JavaDoc(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
66                                             JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
67
68         JTextArea JavaDoc detailsField = new JTextArea JavaDoc(logEntry.getDetails(),5,40);
69         ButtonWithMnemonic closeButton = new ButtonWithMnemonic(RES_CLOSE);
70
71         detailsField.setLineWrap(true);
72         detailsField.setWrapStyleWord(true);
73
74         scroll.getViewport().add(detailsField);
75
76         centerPanel.add(messageLabel,BorderLayout.NORTH);
77         centerPanel.add(scroll,BorderLayout.CENTER);
78
79         closeButton.addActionListener(this);
80         buttonPanel.add(closeButton);
81
82         main.add(buttonPanel,BorderLayout.SOUTH);
83         main.add(centerPanel,BorderLayout.CENTER);
84         main.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
85
86         setLayout(new BorderLayout JavaDoc());
87         add(main,BorderLayout.CENTER);
88         pack();
89     }
90
91     public void actionPerformed(ActionEvent JavaDoc e)
92     {
93         setVisible(false);
94         dispose();
95     }
96
97 }
98
Popular Tags