String msg = "asergre4545dgfdfg45";
String dateMonthMsg = "明细";
JOptionPane.showMessageDialog(null, msg, dateMonthMsg, JOptionPane.INFORMATION_MESSAGE);
我想让弹出的消息对话框里,数字是红色的。字母和汉字是兰色的
能做到么?
String dateMonthMsg = "明细";
JOptionPane.showMessageDialog(null, msg, dateMonthMsg, JOptionPane.INFORMATION_MESSAGE);
我想让弹出的消息对话框里,数字是红色的。字母和汉字是兰色的
能做到么?
// String msg = "asergre4545dgfdfg45";
String str1 = "<font color=\"blue\">asergre</font>",
str2 = "<font color=\"red\">4545</font>",
str3 = "<font color=\"blue\">dgfdfg可以吗?</font>", str4 = "<font color=\"red\">45</font>"; String msg = "<html>" + str1 + str2 + str3 + str4 + "</html>"; String dateMonthMsg = "明细";
JOptionPane.showMessageDialog(null, msg, dateMonthMsg,
JOptionPane.INFORMATION_MESSAGE);
上面这种方法可是可以,但是有点....你可以写个方法去实现判断字符串的.
是数字就:"<font color=\"red\">4545</font>",
是字母就:"<font color=\"blue\">asergre</font>",
是汉字就:"<font color=\"blue\">asergre</font>"
然后连接连接字符串.return;
SWING里面的组件都是支持以HTML方式呈现的
String dateMonthMsg = "明细";
JOptionPane.showMessageDialog(this, table, dateMonthMsg, JOptionPane.INFORMATION_MESSAGE);
想要特别的要求,那就用substring()方法,取得其中的需要的字符啊,然后经过获得的值经过颜色转变传到消息对话框中啊!!
学习了!