使用"更改Java框中的邮件头;如果"和"否则"

时间:2013-10-02 14:58:59

标签: java swing joptionpane

如果我有多个字符串和整数一起工作,如何更改showMessageDialog中的邮件头?

这就是我的工作方式:

showMessageDialog (null, "string", "where I change the name of the box", INFORMATION_MESSAGE);

这是我无法工作的地方:

if (price >= 300) {
    deduction = price * 0.10;
    price = price - deduction;

    showMessageDialog (null, "Total price: ", 
                "where I want to change the        name", INFORMATION_MESSAGE 
                + price + " ." + " Received deduction: " + deduction);

Eclipse提供以下错误消息:

  

“方法showMessageDialog(Component,Object,String,int)中的   类型JOptionPane不适用于参数(null,String,   String,String)“并建议我创建方法showMessageDialog   (Object,String,String,String)。

有什么建议吗? :)

2 个答案:

答案 0 :(得分:1)

INFORMATION_MESSAGE是一个定义消息类型的常量。请尝试使用这种方式:

showMessageDialog(null, "Total price: ", price + " ." + " Received deduction: " + deduction, INFORMATION_MESSAGE);

答案 1 :(得分:1)

我真的不能说我理解这个问题,不过试试..

showMessageDialog (null, "Total price: " + 
    + price + " ." + " Received deduction: " + deduction,
    "where I want to change the name", INFORMATION_MESSAGE);