1 19 package org.netbeans.modules.debugger.ui; 20 21 import org.openide.awt.Mnemonics; 22 import org.openide.util.NbBundle; 23 24 import javax.swing.*; 25 import javax.swing.border.EmptyBorder ; 26 import javax.swing.border.CompoundBorder ; 27 import java.util.*; 28 import java.awt.BorderLayout ; 29 30 35 public class WatchPanel { 36 37 private JPanel panel; 38 private JTextField textField; 39 private String expression; 40 41 public WatchPanel(String expression) { 42 this.expression = expression; 43 } 44 45 public JComponent getPanel() { 46 if (panel != null) return panel; 47 48 panel = new JPanel(); 49 ResourceBundle bundle = NbBundle.getBundle(WatchPanel.class); 50 51 panel.getAccessibleContext ().setAccessibleDescription (bundle.getString ("ACSD_WatchPanel")); JLabel textLabel = new JLabel(); 53 Mnemonics.setLocalizedText(textLabel, bundle.getString ("CTL_Watch_Name")); textLabel.setBorder (new EmptyBorder (0, 0, 0, 10)); 55 panel.setLayout (new BorderLayout ()); 56 panel.setBorder (new EmptyBorder (11, 12, 1, 11)); 57 panel.add ("West", textLabel); panel.add ("Center", textField = new JTextField (25)); textField.getAccessibleContext ().setAccessibleDescription (bundle.getString ("ACSD_CTL_Watch_Name")); textField.setBorder ( 61 new CompoundBorder (textField.getBorder (), 62 new EmptyBorder (2, 0, 2, 0)) 63 ); 64 String t = Utils.getIdentifier (); 65 if (t != null) { 66 textField.setText (t); 67 } else { 68 textField.setText (expression); 69 } 70 textField.selectAll (); 71 72 textLabel.setLabelFor (textField); 73 textField.requestFocus (); 74 return panel; 75 } 76 77 public String getExpression() { 78 return textField.getText().trim(); 79 } 80 } 81 | Popular Tags |