import java.util.regex.*;
import java.io.*;
public class SpecialCharacters
{
public static void main( String[] args ) throws IOException
{
String string = "ashzxcvbnmasdfghjklopiuytrewqASHWINI00675%%%%";
Pattern pattern = Pattern.compile( "[^a-zA-Z0-9*]" );
Matcher matcher = pattern.matcher( string );
System.out.println(matcher.find());
String str = matcher.replaceAll( "F" );
System.out.print( str );
}
}
where [^a-zA-Z0-9*] Any character except a to z, A-Z , 0 to 9 or *
If it will find other then these character the matcher.find() return true else false
matcher.replaceAll( "F" ) will replace all the occurrence of other characters with F
Tuesday, April 12, 2011
Thursday, March 24, 2011
JOptionPane with bold text and different font
- public class abc {
- public static void main(String[] args) {
- String msg = "my name is :
- italics abc "
- + "
- bold and "
- + "
- underlined..."
; - JLabel label = new JLabel(msg);
- label.setFont(new Font("serif", Font.PLAIN, 14));
- JOptionPane.showConfirmDialog(null, label);
- System.exit(0);
- }
- }
JOptionPane with JCheckBox
JCheckBox checkbox = new JCheckBox("Non Callable Debt");
String message = "Enter CUSIP";
Object[] params = {message, checkbox};
String cusip = JOptionPane.showInputDialog( m_Page,params, "Input", JOptionPane.PLAIN_MESSAGE );
boolean nonCallableDebt = checkbox.isSelected();
String message = "Enter CUSIP";
Object[] params = {message, checkbox};
String cusip = JOptionPane.showInputDialog( m_Page,params, "Input", JOptionPane.PLAIN_MESSAGE );
boolean nonCallableDebt = checkbox.isSelected();
How to use JOptionPane with to display bold text and customize message option
String msg = "You cannot transact or perform financial calculations from this "
+ "version
for use in business, without permission from the VP of M&R Operations and the VP of Model Change Control";
System.getProperty( "Environment" );
if( !WorkBenchController.isProductionEnvironment() )
{
Object[] options =
{ "I Acknowledge", "Cancel" };
int n = JOptionPane.showOptionDialog( splashScreenPageController.getWindow(), msg, "Warning",
JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[ 1 ] );
if( n != 0 )
{
System.exit( 0 );
}
}
Subscribe to:
Posts (Atom)