KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > editor > options > AbbrevInputPanel


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
20 package org.netbeans.modules.editor.options;
21
22 import java.awt.Dimension JavaDoc;
23 import org.openide.util.NbBundle;
24
25 /**
26  * Input panel for pair of strings, one inline and one in editor
27  *
28  * @author Petr Nejedly
29  */

30
31 public class AbbrevInputPanel extends javax.swing.JPanel JavaDoc {
32
33     /** Creates new form AbbrevsInputPanel */
34     public AbbrevInputPanel() {
35         initComponents ();
36
37         getAccessibleContext().setAccessibleDescription(getBundleString("ACSD_AIP")); // NOI18N
38
abbrevLabel.setDisplayedMnemonic(getBundleString("AIP_Abbrev_Mnemonic").charAt (0)); // NOI18N
39
expandLabel.setDisplayedMnemonic(getBundleString("AIP_Expand_Mnemonic").charAt (0)); // NOI18N
40
abbrevField.getAccessibleContext().setAccessibleDescription(getBundleString("ACSD_AIP_Abbrev")); // NOI18N
41
expandTextArea.getAccessibleContext().setAccessibleDescription(getBundleString("ACSD_AIP_Expand")); // NOI18N
42

43         Dimension JavaDoc dim = getPreferredSize();
44         dim.width = 4*dim.width;
45         dim.height = 4*dim.height;
46         setPreferredSize( dim );
47     }
48     
49     private String JavaDoc getBundleString(String JavaDoc s) {
50         return NbBundle.getMessage(AbbrevInputPanel.class, s);
51     }
52     
53     public void requestFocus(){
54         abbrevField.requestFocus();
55     }
56
57     public void setAbbrev( String JavaDoc[] abbrev ) {
58         abbrevField.setText( abbrev[0] );
59         expandTextArea.setText( abbrev[1] );
60     }
61
62     public String JavaDoc[] getAbbrev() {
63         String JavaDoc[] retVal = { abbrevField.getText(), expandTextArea.getText() };
64         return retVal;
65     }
66
67
68     private void initComponents() {//GEN-BEGIN:initComponents
69
java.awt.GridBagConstraints JavaDoc gridBagConstraints;
70
71         abbrevLabel = new javax.swing.JLabel JavaDoc();
72         abbrevField = new javax.swing.JTextField JavaDoc();
73         expandLabel = new javax.swing.JLabel JavaDoc();
74         expandScrollPane = new javax.swing.JScrollPane JavaDoc();
75         expandTextArea = new javax.swing.JTextArea JavaDoc();
76
77         setLayout(new java.awt.GridBagLayout JavaDoc());
78
79         setBorder(new javax.swing.border.EmptyBorder JavaDoc(new java.awt.Insets JavaDoc(12, 12, 11, 11)));
80         abbrevLabel.setLabelFor(abbrevField);
81         abbrevLabel.setText(getBundleString( "AIP_Abbrev" )); // NOI18N
82
gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
83         gridBagConstraints.gridx = 0;
84         gridBagConstraints.gridy = 0;
85         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
86         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 0, 12);
87         add(abbrevLabel, gridBagConstraints);
88
89         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
90         gridBagConstraints.gridx = 1;
91         gridBagConstraints.gridy = 0;
92         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
93         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
94         add(abbrevField, gridBagConstraints);
95
96         expandLabel.setLabelFor(expandTextArea);
97         expandLabel.setText(getBundleString( "AIP_Expand" )); // NOI18N
98
gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
99         gridBagConstraints.gridx = 0;
100         gridBagConstraints.gridy = 1;
101         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
102         gridBagConstraints.insets = new java.awt.Insets JavaDoc(14, 0, 0, 12);
103         add(expandLabel, gridBagConstraints);
104
105         expandScrollPane.setViewportView(expandTextArea);
106
107         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
108         gridBagConstraints.gridx = 1;
109         gridBagConstraints.gridy = 1;
110         gridBagConstraints.gridheight = 2;
111         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
112         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
113         gridBagConstraints.weightx = 1.0;
114         gridBagConstraints.weighty = 1.0;
115         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 0, 0, 0);
116         add(expandScrollPane, gridBagConstraints);
117
118     }//GEN-END:initComponents
119

120
121     // Variables declaration - do not modify//GEN-BEGIN:variables
122
private javax.swing.JTextArea JavaDoc expandTextArea;
123     private javax.swing.JLabel JavaDoc abbrevLabel;
124     private javax.swing.JTextField JavaDoc abbrevField;
125     private javax.swing.JScrollPane JavaDoc expandScrollPane;
126     private javax.swing.JLabel JavaDoc expandLabel;
127     // End of variables declaration//GEN-END:variables
128

129 }
130
Popular Tags