• Post Reply Bookmark Topic Watch Topic
  • New Topic

JOptionPane String formatting

 
Rob Wilkin
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm new to java and I am trying to get a table like display with JOptionPane.
the code I have is:

str = String.format(str + " %d \t %.0f \t %1.0f \t %d \n",count,qty,demand,inv);

JOptionPane.showMessageDialog(null,str,"Weekly Stats",JOptionPane.INFORMATION_MESSAGE);

the output im getting ignores the \t so everythiong is just crammed in next to each other. I was wondering of there is a different way to format the string to display in a table form.
I'm only allowed to use on method (main) and not allowed to use arrays.

Thank you all in advance
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was able to do it with inspiration from this: USING HTML IN SWING COMPONENTS.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!