2011-03-13 4 views
0

사용자가 대화 상자에 다양한 문자열과 정수를 입력하고 싶지만 모든 정보가 포함 된 최종 출력을 하나의 대화 상자에 표시하고 싶습니다. 이것은 내가 가지고있는 것입니다 :하나의 대화 상자에 여러 개의 출력을 표시하려고합니다. 어떻게해야합니까?

   JOptionPane.showMessageDialog("Product Name" + inv[i].getName(), JOptionPane.PLAIN_MESSAGE); 
      JOptionPane.showMessageDialog("Product Type" + theItem.getType(), JOptionPane.PLAIN_MESSAGE); 
      JOptionPane.showMessageDialog("Product Number", + theItem.getpNumber(), JOptionPane.PLAIN_MESSAGE); 
      JOptionPane.showMessageDialog("Amount of Units in Stock", + theItem.getUnits(), JOptionPane.PLAIN_MESSAGE); 
      JOptionPane.showMessageDialog("Price per Unit", + theItem.getPrice(), JOptionPane.PLAIN_MESSAGE); 
      JOptionPane.showMessageDialog("Total cost for %s in stock: $%.2f", theItem.getName(), theItem.calculateTotalPrice(), JOptionPane.PLAIN_MESSAGE); 
+0

제쳐두고, 나는 그 발췌 문장이 어떻게 컴파일 될 수 있는지를 알 수 없습니다. –

답변

1

다양한 옵션이 있습니다.

  1. 는 가 showMessageDialog위한 성분으로서 사용하는 상기 OUPUT JTextArea에 넣어.
  2. 를 사용하여 HTML 문자열에 서식 - JLabel의 (기본 구성 요소를 포함한 JOptionPane에 문자열을 렌더링) 간단한 HTML 렌더링됩니다.
0

JDialog을 확장하고 적절하게 사용자 정의하여 대화 상자 클래스를 직접 만들 수도 있습니다.

관련 문제