Java Code Examples for javax.swing.JLabel#setDisplayedMnemonic()

The following examples show how to use javax.swing.JLabel#setDisplayedMnemonic() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
private JPanel createListPanel(final ServiceItemListModel model,
                               final String title,
                               final char mnemonic) {
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    JList<ServiceItem> list = new JList<>(model);
    list.setCellRenderer(new ServiceItemListRenderer());

    JLabel label = new JLabel(title);
    label.setLabelFor(list);
    label.setDisplayedMnemonic(mnemonic);
    JPanel labelPanel = new JPanel();
    labelPanel.setLayout(new BoxLayout(labelPanel, BoxLayout.X_AXIS));
    labelPanel.add(label, BorderLayout.EAST);
    labelPanel.add(Box.createHorizontalGlue());

    panel.add(labelPanel);
    panel.add(new JScrollPane(list));
    return panel;
}
 
Example 2
Source Project: azure-devops-intellij   File: FeedbackForm.java    License: MIT License 6 votes vote down vote up
/**
 * @noinspection ALL
 */
private void $$$loadLabelText$$$(JLabel component, String text) {
    StringBuffer result = new StringBuffer();
    boolean haveMnemonic = false;
    char mnemonic = '\0';
    int mnemonicIndex = -1;
    for (int i = 0; i < text.length(); i++) {
        if (text.charAt(i) == '&') {
            i++;
            if (i == text.length()) break;
            if (!haveMnemonic && text.charAt(i) != '&') {
                haveMnemonic = true;
                mnemonic = text.charAt(i);
                mnemonicIndex = result.length();
            }
        }
        result.append(text.charAt(i));
    }
    component.setText(result.toString());
    if (haveMnemonic) {
        component.setDisplayedMnemonic(mnemonic);
        component.setDisplayedMnemonicIndex(mnemonicIndex);
    }
}
 
Example 3
private JPanel createListPanel(final ServiceItemListModel model,
                               final String title,
                               final char mnemonic) {
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    JList<ServiceItem> list = new JList<>(model);
    list.setCellRenderer(new ServiceItemListRenderer());

    JLabel label = new JLabel(title);
    label.setLabelFor(list);
    label.setDisplayedMnemonic(mnemonic);
    JPanel labelPanel = new JPanel();
    labelPanel.setLayout(new BoxLayout(labelPanel, BoxLayout.X_AXIS));
    labelPanel.add(label, BorderLayout.EAST);
    labelPanel.add(Box.createHorizontalGlue());

    panel.add(labelPanel);
    panel.add(new JScrollPane(list));
    return panel;
}
 
Example 4
/**
 * @noinspection ALL
 */
private void $$$loadLabelText$$$(JLabel component, String text) {
    StringBuffer result = new StringBuffer();
    boolean haveMnemonic = false;
    char mnemonic = '\0';
    int mnemonicIndex = -1;
    for (int i = 0; i < text.length(); i++) {
        if (text.charAt(i) == '&') {
            i++;
            if (i == text.length()) break;
            if (!haveMnemonic && text.charAt(i) != '&') {
                haveMnemonic = true;
                mnemonic = text.charAt(i);
                mnemonicIndex = result.length();
            }
        }
        result.append(text.charAt(i));
    }
    component.setText(result.toString());
    if (haveMnemonic) {
        component.setDisplayedMnemonic(mnemonic);
        component.setDisplayedMnemonicIndex(mnemonicIndex);
    }
}
 
Example 5
Source Project: azure-devops-intellij   File: TfsLoginForm.java    License: MIT License 6 votes vote down vote up
/**
 * @noinspection ALL
 */
private void $$$loadLabelText$$$(JLabel component, String text) {
    StringBuffer result = new StringBuffer();
    boolean haveMnemonic = false;
    char mnemonic = '\0';
    int mnemonicIndex = -1;
    for (int i = 0; i < text.length(); i++) {
        if (text.charAt(i) == '&') {
            i++;
            if (i == text.length()) break;
            if (!haveMnemonic && text.charAt(i) != '&') {
                haveMnemonic = true;
                mnemonic = text.charAt(i);
                mnemonicIndex = result.length();
            }
        }
        result.append(text.charAt(i));
    }
    component.setText(result.toString());
    if (haveMnemonic) {
        component.setDisplayedMnemonic(mnemonic);
        component.setDisplayedMnemonicIndex(mnemonicIndex);
    }
}
 
Example 6
Source Project: azure-devops-intellij   File: VsoLoginForm.java    License: MIT License 6 votes vote down vote up
/**
 * @noinspection ALL
 */
private void $$$loadLabelText$$$(JLabel component, String text) {
    StringBuffer result = new StringBuffer();
    boolean haveMnemonic = false;
    char mnemonic = '\0';
    int mnemonicIndex = -1;
    for (int i = 0; i < text.length(); i++) {
        if (text.charAt(i) == '&') {
            i++;
            if (i == text.length()) break;
            if (!haveMnemonic && text.charAt(i) != '&') {
                haveMnemonic = true;
                mnemonic = text.charAt(i);
                mnemonicIndex = result.length();
            }
        }
        result.append(text.charAt(i));
    }
    component.setText(result.toString());
    if (haveMnemonic) {
        component.setDisplayedMnemonic(mnemonic);
        component.setDisplayedMnemonicIndex(mnemonicIndex);
    }
}
 
Example 7
Source Project: azure-devops-intellij   File: ImportForm.java    License: MIT License 6 votes vote down vote up
/**
 * @noinspection ALL
 */
private void $$$loadLabelText$$$(JLabel component, String text) {
    StringBuffer result = new StringBuffer();
    boolean haveMnemonic = false;
    char mnemonic = '\0';
    int mnemonicIndex = -1;
    for (int i = 0; i < text.length(); i++) {
        if (text.charAt(i) == '&') {
            i++;
            if (i == text.length()) break;
            if (!haveMnemonic && text.charAt(i) != '&') {
                haveMnemonic = true;
                mnemonic = text.charAt(i);
                mnemonicIndex = result.length();
            }
        }
        result.append(text.charAt(i));
    }
    component.setText(result.toString());
    if (haveMnemonic) {
        component.setDisplayedMnemonic(mnemonic);
        component.setDisplayedMnemonicIndex(mnemonicIndex);
    }
}
 
Example 8
/**
 * @noinspection ALL
 */
private void $$$loadLabelText$$$(JLabel component, String text) {
    StringBuffer result = new StringBuffer();
    boolean haveMnemonic = false;
    char mnemonic = '\0';
    int mnemonicIndex = -1;
    for (int i = 0; i < text.length(); i++) {
        if (text.charAt(i) == '&') {
            i++;
            if (i == text.length()) break;
            if (!haveMnemonic && text.charAt(i) != '&') {
                haveMnemonic = true;
                mnemonic = text.charAt(i);
                mnemonicIndex = result.length();
            }
        }
        result.append(text.charAt(i));
    }
    component.setText(result.toString());
    if (haveMnemonic) {
        component.setDisplayedMnemonic(mnemonic);
        component.setDisplayedMnemonicIndex(mnemonicIndex);
    }
}
 
Example 9
private void $$$loadLabelText$$$( JLabel component, String text )
{
    StringBuffer result = new StringBuffer();
    boolean haveMnemonic = false;
    char mnemonic = '\0';
    int mnemonicIndex = -1;
    for( int i = 0; i < text.length(); i++ )
    {
        if( text.charAt( i ) == '&' )
        {
            i++;
            if( i == text.length() )
            {
                break;
            }
            if( !haveMnemonic && text.charAt( i ) != '&' )
            {
                haveMnemonic = true;
                mnemonic = text.charAt( i );
                mnemonicIndex = result.length();
            }
        }
        result.append( text.charAt( i ) );
    }
    component.setText( result.toString() );
    if( haveMnemonic )
    {
        component.setDisplayedMnemonic( mnemonic );
        component.setDisplayedMnemonicIndex( mnemonicIndex );
    }
}
 
Example 10
ControlPanel( SwingInteractivityViewer siv )
{
	this.siv = siv;

	setLayout( new GridLayout( 0, 1, 0, 0 ) );

	JPanel jp = new JPanel( );
	jp.setLayout( new FlowLayout( FlowLayout.LEFT, 3, 3 ) );

	JLabel choose = new JLabel( "Choose:" );//$NON-NLS-1$
	choose.setDisplayedMnemonic( 'c' );
	jp.add( choose );

	jcbModels = new JComboBox( );
	choose.setLabelFor( jcbModels );
	jcbModels.addItem( "Highlight Series" );//$NON-NLS-1$
	jcbModels.addItem( "Show Tooltip" );//$NON-NLS-1$
	jcbModels.addItem( "Toggle Visibility" );//$NON-NLS-1$
	jcbModels.addItem( "URL Redirect" );//$NON-NLS-1$
	jcbModels.addItem( "Multiple URLs Redirect" );//$NON-NLS-1$
	jcbModels.addItem( "Call Back" );//$NON-NLS-1$
	jcbModels.addItem( "Right Mouse Click" );//$NON-NLS-1$
	jcbModels.addItem( "Mouse Cursor" );//$NON-NLS-1$
	jcbModels.setSelectedIndex( 0 );
	jp.add( jcbModels );

	jbUpdate = new JButton( "Update" );//$NON-NLS-1$
	jbUpdate.setMnemonic( 'u' );
	jbUpdate.addActionListener( this );
	jbUpdate.setToolTipText( "Show" );//$NON-NLS-1$
	jp.add( jbUpdate );

	add( jp );
}
 
Example 11
Source Project: swift-explorer   File: MainPanel.java    License: Apache License 2.0 5 votes vote down vote up
private void addSearchPanel (JComponent parent)
{
    JPanel panel = new JPanel(new FlowLayout(SwingConstants.RIGHT, 0, 0));
    JLabel label = new JLabel(getIcon("zoom.png"));
    label.setLabelFor(searchTextField);
    label.setDisplayedMnemonic('f');
    panel.add(label);
    panel.add(searchTextField);
    parent.add(panel);
}
 
Example 12
Source Project: wpcleaner   File: Utilities.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Create a JLabel.
 * 
 * @param message Label text with optional mnemonic inside.
 * @return Label initialized with text and mnemonic.
 */
public static JLabel createJLabel(String message) {
  JLabel label = new JLabel(getLabelWithoutMnemonic(message));
  int mnemonic = getMnemonic(message);
  if (mnemonic != -1) {
    label.setDisplayedMnemonic(mnemonic);
  }
  return label;
}
 
Example 13
Source Project: birt   File: FormatChartsViewer.java    License: Eclipse Public License 1.0 5 votes vote down vote up
ControlPanel( FormatChartsViewer fcv )
{
	this.fcv = fcv;

	setLayout( new GridLayout( 0, 1, 0, 0 ) );

	JPanel jp = new JPanel( );
	jp.setLayout( new FlowLayout( FlowLayout.LEFT, 3, 3 ) );

	JLabel choose=new JLabel( "Choose:" );//$NON-NLS-1$
	choose.setDisplayedMnemonic( 'c' );
	jp.add( choose );
	jcbModels = new JComboBox( );

	jcbModels.addItem( "Axis Format" );//$NON-NLS-1$
	jcbModels.addItem( "Colored By Category" );//$NON-NLS-1$
	jcbModels.addItem( "Legend & Title Format" );//$NON-NLS-1$
	jcbModels.addItem( "Percentage Values" );//$NON-NLS-1$
	jcbModels.addItem( "Plot Format" );//$NON-NLS-1$
	jcbModels.addItem( "Series Format" );//$NON-NLS-1$

	choose.setLabelFor( jcbModels );
	jcbModels.setSelectedIndex( 0 );
	jp.add( jcbModels );

	jbUpdate = new JButton( "Update" );//$NON-NLS-1$
	jbUpdate.setMnemonic( 'u' );
	jbUpdate.setToolTipText( "Update" );//$NON-NLS-1$
	jbUpdate.addActionListener( this );
	jp.add( jbUpdate );

	add( jp );
}
 
Example 14
Source Project: birt   File: DataChartsViewer.java    License: Eclipse Public License 1.0 5 votes vote down vote up
ControlPanel( DataChartsViewer dcv )
{
	this.dcv = dcv;

	setLayout( new GridLayout( 0, 1, 0, 0 ) );

	JPanel jp = new JPanel( );
	jp.setLayout( new FlowLayout( FlowLayout.LEFT, 3, 3 ) );

	JLabel choose=new JLabel( "Choose:" );//$NON-NLS-1$
	choose.setDisplayedMnemonic( 'c' );
	jp.add( choose );
	jcbModels = new JComboBox( );

	jcbModels.addItem( "Min Slice" );//$NON-NLS-1$
	jcbModels.addItem( "Multiple Y Axis" );//$NON-NLS-1$
	jcbModels.addItem( "Multiple Y Series" );//$NON-NLS-1$
	jcbModels.addItem( "Big number Y Series" );//$NON-NLS-1$

	jcbModels.setSelectedIndex( 0 );
	choose.setLabelFor( jcbModels );
	jp.add( jcbModels );

	jbUpdate = new JButton( "Update" );//$NON-NLS-1$
	jbUpdate.setMnemonic( 'u' );
	jbUpdate.setToolTipText( "Update" );//$NON-NLS-1$
	jbUpdate.addActionListener( this );
	jp.add( jbUpdate );

	add( jp );
}
 
Example 15
private void $$$loadLabelText$$$( JLabel component, String text )
{
    StringBuffer result = new StringBuffer();
    boolean haveMnemonic = false;
    char mnemonic = '\0';
    int mnemonicIndex = -1;
    for( int i = 0; i < text.length(); i++ )
    {
        if( text.charAt( i ) == '&' )
        {
            i++;
            if( i == text.length() )
            {
                break;
            }
            if( !haveMnemonic && text.charAt( i ) != '&' )
            {
                haveMnemonic = true;
                mnemonic = text.charAt( i );
                mnemonicIndex = result.length();
            }
        }
        result.append( text.charAt( i ) );
    }
    component.setText( result.toString() );
    if( haveMnemonic )
    {
        component.setDisplayedMnemonic( mnemonic );
        component.setDisplayedMnemonicIndex( mnemonicIndex );
    }
}
 
Example 16
Source Project: netbeans   File: DDChangesPanel.java    License: Apache License 2.0 4 votes vote down vote up
/** Initializes the Form */
public DDChangesPanel (String caption, final JButton processButton) {
    setLayout (new java.awt.BorderLayout (0, 12));
    setBorder (new EmptyBorder (12, 12, 11, 0));
    
    JTextArea text = new JTextArea ();
    text.setEnabled (false);
    text.setEditable (false);
    text.setDisabledTextColor (UIManager.getColor ("Label.foreground")); // NOI18N
    text.setBackground (UIManager.getColor ("Label.background")); // NOI18N
    text.setLineWrap (true);
    text.setWrapStyleWord (true);
    text.setText (caption);
    add (text, "North"); // NOI18N
    
    changesPanel = new JPanel ();
    changesPanel.setLayout (new java.awt.BorderLayout (5, 5));
    
    JLabel changesLabel = new JLabel ();
    changesLabel.setText (NbBundle.getMessage (DDChangesPanel.class, "LAB_ChangesList"));
    changesLabel.getAccessibleContext ().setAccessibleDescription (NbBundle.getMessage (DDChangesPanel.class, "ACS_ChangesListA11yDesc"));  // NOI18N
    changesPanel.add (changesLabel, "North"); // NOI18N
    
    jScrollPane1 = new JScrollPane ();
    
    listModel = new DefaultListModel ();
    
    changesList = new JList (listModel);
    changesList.setToolTipText (NbBundle.getMessage (DDChangesPanel.class, "HINT_ChangesList"));
    changesList.setCellRenderer (new ChangesListCellRenderer ());
    changesList.addListSelectionListener (new ListSelectionListener () {
        public void valueChanged (ListSelectionEvent e) {
            processButton.setEnabled (!changesList.isSelectionEmpty ());
        }
    });
    changesLabel.setLabelFor (changesList);
    changesLabel.setDisplayedMnemonic (NbBundle.getMessage (DDChangesPanel.class, "LAB_ChangesList_Mnemonic").charAt (0));
    getAccessibleContext().setAccessibleDescription(NbBundle.getMessage (DDChangesPanel.class, "ACS_ChangesListA11yPanelDesc"));
    
    jScrollPane1.setViewportView (changesList);
    
    changesPanel.add (jScrollPane1, "Center"); // NOI18N
    
    add (changesPanel, "Center"); // NOI18N
}
 
Example 17
Source Project: netbeans   File: DDChangesPanel.java    License: Apache License 2.0 4 votes vote down vote up
/** Initializes the Form */
public DDChangesPanel (String caption, final JButton processButton) {
    setLayout (new java.awt.BorderLayout (0, 12));
    setBorder (new EmptyBorder (12, 12, 11, 0));
    
    JTextArea text = new JTextArea ();
    text.setEnabled (false);
    text.setEditable (false);
    text.setDisabledTextColor (UIManager.getColor ("Label.foreground")); // NOI18N
    text.setBackground (UIManager.getColor ("Label.background")); // NOI18N
    text.setLineWrap (true);
    text.setWrapStyleWord (true);
    text.setText (caption);
    add (text, "North"); // NOI18N
    
    changesPanel = new JPanel ();
    changesPanel.setLayout (new java.awt.BorderLayout (5, 5));
    
    JLabel changesLabel = new JLabel ();
    changesLabel.setText (NbBundle.getMessage (DDChangesPanel.class, "LAB_ChangesList"));
    changesLabel.getAccessibleContext ().setAccessibleDescription (NbBundle.getMessage (DDChangesPanel.class, "ACS_ChangesListA11yDesc"));  // NOI18N
    changesPanel.add (changesLabel, "North"); // NOI18N
    
    jScrollPane1 = new JScrollPane ();
    
    listModel = new DefaultListModel ();
    
    changesList = new JList (listModel);
    changesList.setToolTipText (NbBundle.getMessage (DDChangesPanel.class, "HINT_ChangesList"));
    changesList.setCellRenderer (new ChangesListCellRenderer ());
    changesList.addListSelectionListener (new ListSelectionListener () {
        public void valueChanged (ListSelectionEvent e) {
            processButton.setEnabled (!changesList.isSelectionEmpty ());
        }
    });
    changesLabel.setLabelFor (changesList);
    changesLabel.setDisplayedMnemonic (NbBundle.getMessage (DDChangesPanel.class, "LAB_ChangesList_Mnemonic").charAt (0));
    getAccessibleContext().setAccessibleDescription(NbBundle.getMessage (DDChangesPanel.class, "ACS_ChangesListA11yPanelDesc"));
    
    jScrollPane1.setViewportView (changesList);
    
    changesPanel.add (jScrollPane1, "Center"); // NOI18N
    
    add (changesPanel, "Center"); // NOI18N
}
 
Example 18
Source Project: netbeans   File: InitParamPanel.java    License: Apache License 2.0 4 votes vote down vote up
private void initComponents() {
    // Layout description
    setLayout(new java.awt.GridBagLayout());

    // Entity covers entire row
    GridBagConstraints fullRowC = new GridBagConstraints();
    fullRowC.gridx = 0;
    fullRowC.gridy = 0;
    fullRowC.gridwidth = 2;
    fullRowC.anchor = GridBagConstraints.WEST;
    fullRowC.fill = GridBagConstraints.HORIZONTAL;
    fullRowC.insets = new Insets(4, 0, 4, 0);

    // Button
    GridBagConstraints bC = new GridBagConstraints();
    bC.gridx = 1;
    bC.gridy = 1;
    bC.weightx = 0.1;
    bC.fill = GridBagConstraints.HORIZONTAL;
    bC.insets = new Insets(4, 20, 4, 0);

    // Table panel
    GridBagConstraints tableC = new GridBagConstraints();
    tableC.gridx = 0;
    tableC.gridy = 1;
    tableC.gridheight = 4;
    tableC.fill = GridBagConstraints.BOTH;
    tableC.weightx = 0.9;
    tableC.weighty = 1.0;
    tableC.anchor = GridBagConstraints.WEST;
    tableC.insets = new Insets(4, 0, 4, 0);

    // Filler panel
    GridBagConstraints fillerC = new GridBagConstraints();
    fillerC.gridx = 1;
    fillerC.gridy = GridBagConstraints.RELATIVE;
    fillerC.fill = GridBagConstraints.BOTH;
    fillerC.weighty = 1.0;
    fillerC.insets = new Insets(4, 0, 4, 0);

    // Component Initialization by row
    // 1. Init parameter
    jLinitparams = new JLabel(NbBundle.getMessage(InitParamPanel.class, "LBL_initparamsL"));
    jLinitparams.setDisplayedMnemonic(NbBundle.getMessage(InitParamPanel.class, "LBL_initparams_mnemonic").charAt(0));
    // PENDING
    this.add(jLinitparams, fullRowC);

    // 2. Table row

    String[] headers = {"paramname", "paramvalue"};
    table = new DDTable(headers, "LBL_initparams", Editable.BOTH);

    jLinitparams.setLabelFor(table);

    // Enable the buttons according to the row selected
    table.getSelectionModel().addListSelectionListener(this);
    table.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(InitParamPanel.class, "ACSD_initparams_desc")); // NOI18N
    table.getAccessibleContext().setAccessibleName(NbBundle.getMessage(InitParamPanel.class, "ACSD_initparams")); // NOI18N


    table.getModel().addTableModelListener(new TableModelListener() {

        public void tableChanged(TableModelEvent evt) {
            updateInitParams();
        }
    });

    scrollP = new JScrollPane(table);
    this.add(scrollP, tableC);

    jBnew = new JButton();
    jBnew.setText(NbBundle.getMessage(InitParamPanel.class, "LBL_new"));
    jBnew.setMnemonic(NbBundle.getMessage(InitParamPanel.class, "LBL_new_mnemonic").charAt(0));
    jBnew.addActionListener(this);
    jBnew.setActionCommand(ADD);
    jBnew.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(InitParamPanel.class, "ACSD_initparam_new")); // NOI18N
    this.add(jBnew, bC);

    bC.gridy++;
    jBedit = new JButton();
    jBedit.setText(NbBundle.getMessage(InitParamPanel.class, "LBL_edit"));
    jBedit.setMnemonic(NbBundle.getMessage(InitParamPanel.class, "LBL_edit_mnemonic").charAt(0));
    jBedit.addActionListener(this);
    jBedit.setActionCommand(EDIT);
    jBedit.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(InitParamPanel.class, "ACSD_initparam_edit")); // NOI18N
    jBedit.setEnabled(false);
    this.add(jBedit, bC);

    bC.gridy++;
    jBdelete = new JButton();
    jBdelete.setText(NbBundle.getMessage(InitParamPanel.class, "LBL_delete"));
    jBdelete.setMnemonic(NbBundle.getMessage(InitParamPanel.class, "LBL_delete_mnemonic").charAt(0));
    jBdelete.addActionListener(this);
    jBdelete.setActionCommand(REMOVE);
    jBdelete.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(InitParamPanel.class, "ACSD_initparam_delete")); // NOI18N
    jBdelete.setEnabled(false);
    this.add(jBdelete, bC);

    this.add(new javax.swing.JPanel(), fillerC);
}
 
Example 19
Source Project: netbeans   File: AddJspWatchAction.java    License: Apache License 2.0 4 votes vote down vote up
public void performAction () {
        ResourceBundle bundle = NbBundle.getBundle (AddJspWatchAction.class);

        JPanel panel = new JPanel();
        panel.getAccessibleContext ().setAccessibleDescription (bundle.getString ("ACSD_WatchPanel")); // NOI18N
        JTextField textField;
        JLabel textLabel = new JLabel (bundle.getString ("CTL_Watch_Name")); // NOI18N
        textLabel.setBorder (new EmptyBorder (0, 0, 0, 10));
        panel.setLayout (new BorderLayout ());
        panel.setBorder (new EmptyBorder (11, 12, 1, 11));
        panel.add ("West", textLabel); // NOI18N
        panel.add ("Center", textField = new JTextField (25)); // NOI18N
        textField.getAccessibleContext ().setAccessibleDescription (bundle.getString ("ACSD_CTL_Watch_Name")); // NOI18N
        textField.setBorder (
            new CompoundBorder (textField.getBorder (), 
            new EmptyBorder (2, 0, 2, 0))
        );
        textLabel.setDisplayedMnemonic (
            bundle.getString ("CTL_Watch_Name_Mnemonic").charAt (0) // NOI18N
        );


        String t = null;//Utils.getELIdentifier();
//        Utils.log("Watch: ELIdentifier = " + t);
        
        boolean isScriptlet = Utils.isScriptlet();
        Utils.log("Watch: isScriptlet: " + isScriptlet);
        
        if ((t == null) && (isScriptlet)) {
            t = Utils.getJavaIdentifier();
            Utils.log("Watch: javaIdentifier = " + t);
        }
        
        if (t != null) {
            textField.setText(t);
        } else {
            textField.setText(watchHistory);
        }
        textField.selectAll ();        
        textLabel.setLabelFor (textField);
        textField.requestFocus ();

        org.openide.DialogDescriptor dd = new org.openide.DialogDescriptor (
            panel, 
            bundle.getString ("CTL_Watch_Title") // NOI18N
        );
        dd.setHelpCtx (new HelpCtx ("debug.add.watch"));
        Dialog dialog = DialogDisplayer.getDefault ().createDialog (dd);
        dialog.setVisible(true);
        dialog.dispose ();

        if (dd.getValue() != org.openide.DialogDescriptor.OK_OPTION) return;
        String watch = textField.getText();
        if ((watch == null) || (watch.trim ().length () == 0)) {
            return;
        }
        
        String s = watch;
        int i = s.indexOf (';');
        while (i > 0) {
            String ss = s.substring (0, i).trim ();
            if (ss.length () > 0)
                DebuggerManager.getDebuggerManager ().createWatch (ss);
            s = s.substring (i + 1);
            i = s.indexOf (';');
        }
        s = s.trim ();
        if (s.length () > 0)
            DebuggerManager.getDebuggerManager ().createWatch (s);
        
        watchHistory = watch;
        
        // open watches view
//        new WatchesAction ().actionPerformed (null); TODO
    }
 
Example 20
Source Project: Spark   File: ResourceUtils.java    License: Apache License 2.0 3 votes vote down vote up
/**
 * Sets the resources on a {@link JLabel}.  It sets the text, mnemonic,
 * and labelFor property.
 *
 * @param label     The Label on which to set the properties
 * @param labelFor  the {@link Component} to set with the
 *                  <code>labelFor</code> property on the <code>label</code>.
 * @param labelText The text label to set on the <code>label</code>
 * @see JLabel#setText(String)
 * @see JLabel#setLabelFor(Component)
 * @see JLabel#setDisplayedMnemonic(int)
 */
public static void resLabel(JLabel label, Component labelFor, String labelText) {
    label.setText(stripMnemonic(labelText));

    if (Spark.isWindows()) {
        label.setDisplayedMnemonic(getMnemonicKeyCode(labelText));
    }
    label.setLabelFor(labelFor);
}