KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectstyle > cayenne > modeler > dialog > ValidationResultBrowserView


1 package org.objectstyle.cayenne.modeler.dialog;
2
3 import java.awt.BorderLayout JavaDoc;
4 import java.awt.Dimension JavaDoc;
5 import java.awt.FlowLayout JavaDoc;
6
7 import javax.swing.JButton JavaDoc;
8 import javax.swing.JComponent JavaDoc;
9 import javax.swing.JDialog JavaDoc;
10 import javax.swing.JPanel JavaDoc;
11 import javax.swing.JScrollPane JavaDoc;
12 import javax.swing.JTextArea JavaDoc;
13
14 import com.jgoodies.forms.builder.PanelBuilder;
15 import com.jgoodies.forms.layout.CellConstraints;
16 import com.jgoodies.forms.layout.FormLayout;
17
18 /**
19  * @author Andrei Adamchik
20  */

21 public class ValidationResultBrowserView extends JDialog JavaDoc {
22
23     protected JTextArea JavaDoc messageLabel;
24     protected JTextArea JavaDoc errorsDisplay;
25     protected JButton JavaDoc closeButton;
26
27     public ValidationResultBrowserView() {
28         this.closeButton = new JButton JavaDoc("Close");
29
30         this.messageLabel = new JTextArea JavaDoc();
31         messageLabel.setEditable(false);
32         messageLabel.setLineWrap(true);
33         messageLabel.setWrapStyleWord(true);
34
35         this.errorsDisplay = new JTextArea JavaDoc();
36         errorsDisplay.setEditable(false);
37         errorsDisplay.setLineWrap(true);
38         errorsDisplay.setWrapStyleWord(true);
39
40         // assemble
41
CellConstraints cc = new CellConstraints();
42         PanelBuilder builder = new PanelBuilder(new FormLayout(
43                 "fill:min(50dlu;pref):grow",
44                 "fill:20dlu, 9dlu, p, 3dlu, fill:40dlu:grow"));
45         builder.setDefaultDialogBorder();
46         builder.add(new JScrollPane JavaDoc(
47                 messageLabel,
48                 JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
49                 JScrollPane.HORIZONTAL_SCROLLBAR_NEVER), cc.xy(1, 1));
50         builder.addSeparator("Details", cc.xy(1, 3));
51         builder.add(new JScrollPane JavaDoc(
52                 errorsDisplay,
53                 JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
54                 JScrollPane.HORIZONTAL_SCROLLBAR_NEVER), cc.xy(1, 5));
55
56         JPanel JavaDoc buttons = new JPanel JavaDoc(new FlowLayout JavaDoc(FlowLayout.RIGHT));
57         buttons.add(closeButton);
58
59         JComponent JavaDoc container = (JComponent JavaDoc) getContentPane();
60         container.setLayout(new BorderLayout JavaDoc());
61         container.add(builder.getPanel(), BorderLayout.CENTER);
62         container.add(buttons, BorderLayout.SOUTH);
63
64         // update top label bg
65
messageLabel.setBackground(container.getBackground());
66
67         // we need the right preferred size so that dialog "pack()" produces decent
68
// default size...
69
container.setPreferredSize(new Dimension JavaDoc(450, 270));
70     }
71
72     public JButton JavaDoc getCloseButton() {
73         return closeButton;
74     }
75
76     public JTextArea JavaDoc getErrorsDisplay() {
77         return errorsDisplay;
78     }
79
80     public JTextArea JavaDoc getMessageLabel() {
81         return messageLabel;
82     }
83 }
Popular Tags