Here you can find the source of filterMnemonic(final String s, final AbstractButton b)
Parameter | Description |
---|---|
s | the String that contains the mnemonic definition |
b | the AbstractButton that should get the mnemonic |
public static String filterMnemonic(final String s, final AbstractButton b)
//package com.java2s; //License from project: Open Source License import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.swing.AbstractButton; public class Main { /**//from www. j av a 2 s. c om * Filters the mnemonic definition from the given string. If a mnemonic definition ([m]) is found, it will be set to * the given AbstractButton. * * @param s the String that contains the mnemonic definition * @param b the AbstractButton that should get the mnemonic * @return the String without the [] of the definition */ public static String filterMnemonic(final String s, final AbstractButton b) { if (s != null) { String tmpS = s; final Matcher m = Pattern.compile("\\[(.)\\]").matcher(tmpS); //$NON-NLS-1$ if (m.find()) { b.setMnemonic(m.group(1).charAt(0)); tmpS = m.replaceFirst(m.group(1)); } return tmpS; } return null; } }