Posted By

mouseroot on 11/14/10


Tagged


Versions (?)

JComponents inside JOptionPane.showMessageDialog();


 / Published in: Java
 

I didnt know you could do this but you can put JComponets from awt or swing inside JOptionPane.showMessageDialog ...probly other variations also who knows

this is excellent for html formatting inside a messagebox

  1. import javax.swing.*;
  2. import java.awt.*;
  3.  
  4. String test = "<html><font color=green>Test<br></font></html>";
  5. ShowMsg(test,"Testing HTML");
  6.  
  7.  
  8. public static void ShowMsg(String in,String title)
  9. {
  10. JOptionPane.showMessageDialog( null,
  11. new JLabel(in),title,JOptionPane.INFORMATION_MESSAGE );
  12. }

Report this snippet  

You need to login to post a comment.