Thursday, March 24, 2011

JOptionPane with bold text and different font

  1. public class abc {
  2. public static void main(String[] args) {
  3. String msg = "my name is :
    • italics abc "
    • + "
    • bold and "
    • + "
    • underlined...
    "
    ;
  4. JLabel label = new JLabel(msg);
  5. label.setFont(new Font("serif", Font.PLAIN, 14));
  6. JOptionPane.showConfirmDialog(null, label);
  7. System.exit(0);
  8. }
  9. }

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();

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 );
}
}