01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: */
18:
19: package org.apache.jmeter.gui;
20:
21: import java.awt.BorderLayout;
22:
23: import javax.swing.JLabel;
24: import javax.swing.JPanel;
25: import javax.swing.JTextArea;
26:
27: import org.apache.jmeter.util.JMeterUtils;
28:
29: /**
30: * Generic comment panel for Test Elements
31: *
32: */
33: public class CommentPanel extends JPanel {
34: /** A text field containing the comment. */
35: private JTextArea commentField;
36:
37: /**
38: * Create a new NamePanel with the default name.
39: */
40: public CommentPanel() {
41: init();
42: }
43:
44: /**
45: * Initialize the GUI components and layout.
46: */
47: private void init() {
48: setLayout(new BorderLayout(5, 0));
49:
50: commentField = new JTextArea();
51: JLabel commentLabel = new JLabel(JMeterUtils
52: .getResString("testplan_comments")); //$NON-NLS-1$
53: commentLabel.setLabelFor(commentField);
54:
55: JPanel commentPanel = new JPanel();
56: commentPanel.setLayout(new BorderLayout(0, 5));
57: commentPanel.add(commentLabel, BorderLayout.WEST);
58: commentPanel.add(commentField, BorderLayout.CENTER);
59: add(commentPanel);
60: }
61:
62: public void setText(String comment) {
63: this .commentField.setText(comment);
64: }
65:
66: public String getText() {
67: return this .commentField.getText();
68: }
69:
70: public void clearGui() {
71: commentField.setText(""); // $NON-NLS-1$
72: }
73: }
|