KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > web > debug > watchesfiltering > WatchPanel


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.modules.web.debug.watchesfiltering;
20
21 import org.openide.util.NbBundle;
22
23 import javax.swing.*;
24 import javax.swing.border.EmptyBorder JavaDoc;
25 import javax.swing.border.CompoundBorder JavaDoc;
26 import java.util.*;
27 import java.awt.BorderLayout JavaDoc;
28
29 /**
30  * A GUI panel for customizing a Watch.
31
32  * @author Maros Sandor
33  */

34 public class WatchPanel {
35
36     private JPanel panel;
37     private JTextField textField;
38     private String JavaDoc expression;
39
40     public WatchPanel(String JavaDoc expression) {
41         this.expression = expression;
42     }
43
44     public JComponent getPanel() {
45         if (panel != null) return panel;
46
47         panel = new JPanel();
48         ResourceBundle bundle = NbBundle.getBundle(WatchPanel.class);
49
50         panel.getAccessibleContext ().setAccessibleDescription (bundle.getString ("ACSD_WatchPanel")); // NOI18N
51
JLabel textLabel = new JLabel (bundle.getString ("CTL_Watch_Name")); // NOI18N
52
textLabel.setBorder (new EmptyBorder JavaDoc (0, 0, 0, 10));
53         panel.setLayout (new BorderLayout JavaDoc ());
54         panel.setBorder (new EmptyBorder JavaDoc (11, 12, 1, 11));
55         panel.add ("West", textLabel); // NOI18N
56
panel.add ("Center", textField = new JTextField (25)); // NOI18N
57
textField.getAccessibleContext ().setAccessibleDescription (bundle.getString ("ACSD_CTL_Watch_Name")); // NOI18N
58
textField.setBorder (
59             new CompoundBorder JavaDoc (textField.getBorder (),
60             new EmptyBorder JavaDoc (2, 0, 2, 0))
61         );
62         textLabel.setDisplayedMnemonic (
63             bundle.getString ("CTL_Watch_Name_Mnemonic").charAt (0) // NOI18N
64
);
65         textField.setText (expression);
66         textField.selectAll ();
67
68         textLabel.setLabelFor (textField);
69         textField.requestFocus ();
70         return panel;
71     }
72
73     public String JavaDoc getExpression() {
74         return textField.getText().trim();
75     }
76 }
77
Popular Tags