KickJava   Java API By Example, From Geeks To Geeks.

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


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 MacroInputPanel extends javax.swing.JPanel JavaDoc {
32
33     /** Creates new form MacrosInputPanel */
34     public MacroInputPanel() {
35         initComponents ();
36         getAccessibleContext().setAccessibleDescription(getBundleString("ACSD_MIP")); // NOI18N
37
macroLabel.setDisplayedMnemonic(getBundleString("MIP_Macro_Mnemonic").charAt(0)); // NOI18N
38
expandLabel.setDisplayedMnemonic(getBundleString("MIP_Expand_Mnemonic").charAt(0)); // NOI18N
39
macroField.getAccessibleContext().setAccessibleDescription(getBundleString("ACSD_MIP_Macro")); // NOI18N
40
expandTextArea.getAccessibleContext().setAccessibleDescription(getBundleString("ACSD_MIP_Expand")); // NOI18N
41
Dimension JavaDoc dim = getPreferredSize();
42         dim.width = 4*dim.width;
43         dim.height = 4*dim.height;
44         setPreferredSize( dim );
45     }
46     
47     private String JavaDoc getBundleString(String JavaDoc s) {
48         return NbBundle.getMessage(MacroInputPanel.class, s);
49     }
50
51     public void setMacro( String JavaDoc[] macro ) {
52         macroField.setText( macro[0] );
53         expandTextArea.setText( macro[1] );
54     }
55
56     public String JavaDoc[] getMacro() {
57         String JavaDoc[] retVal = { macroField.getText(), expandTextArea.getText() };
58         return retVal;
59     }
60     
61     public void requestFocus(){
62         macroField.requestFocus();
63     }
64
65
66     private void initComponents() {//GEN-BEGIN:initComponents
67
java.awt.GridBagConstraints JavaDoc gridBagConstraints;
68
69         macroLabel = new javax.swing.JLabel JavaDoc();
70         macroField = new javax.swing.JTextField JavaDoc();
71         expandLabel = new javax.swing.JLabel JavaDoc();
72         expandScrollPane = new javax.swing.JScrollPane JavaDoc();
73         expandTextArea = new javax.swing.JTextArea JavaDoc();
74
75         setLayout(new java.awt.GridBagLayout JavaDoc());
76
77         setBorder(new javax.swing.border.EmptyBorder JavaDoc(new java.awt.Insets JavaDoc(12, 12, 11, 11)));
78         macroLabel.setLabelFor(macroField);
79         macroLabel.setText(getBundleString( "MIP_Macro" )); // NOI18N
80
gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
81         gridBagConstraints.gridx = 0;
82         gridBagConstraints.gridy = 0;
83         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
84         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 5, 12);
85         add(macroLabel, gridBagConstraints);
86
87         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
88         gridBagConstraints.gridx = 1;
89         gridBagConstraints.gridy = 0;
90         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
91         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
92         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 5, 0);
93         add(macroField, gridBagConstraints);
94
95         expandLabel.setLabelFor(expandTextArea);
96         expandLabel.setText(getBundleString( "MIP_Expand" )); // NOI18N
97
gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
98         gridBagConstraints.gridx = 0;
99         gridBagConstraints.gridy = 1;
100         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
101         gridBagConstraints.insets = new java.awt.Insets JavaDoc(2, 0, 0, 12);
102         add(expandLabel, gridBagConstraints);
103
104         expandScrollPane.setViewportView(expandTextArea);
105
106         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
107         gridBagConstraints.gridx = 1;
108         gridBagConstraints.gridy = 1;
109         gridBagConstraints.gridheight = 2;
110         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
111         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
112         gridBagConstraints.weightx = 1.0;
113         gridBagConstraints.weighty = 1.0;
114         add(expandScrollPane, gridBagConstraints);
115
116     }//GEN-END:initComponents
117

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

127 }
128
Popular Tags