Results 1 to 3 of 3
Thread: Help With Dice Game Please
- 10-07-2012, 07:58 PM #1
Member
- Join Date
- Oct 2012
- Posts
- 7
- Rep Power
- 0
Help With Dice Game Please
I'm writing a dice game program where it randomly generates a number from 1 to 6, and that is your roll. It does the same thing again for the computer's roll. I've implemented a line of code that will show the picture of the die you rolled in the JOptionPane, but when I do so, it put all of my text on the same line, even though I use \n. Help please?

Here is the lines of code:
Java Code:JLabel diceLabel = new JLabel("Your roll: " + userRoll + "\nComputer's Roll: " + compRoll + "\nYou lost to the computer."); diceLabel.setIcon(new ImageIcon("C:\\Users\\default.default-VAIO\\Downloads\\Dice Game\\DiceFace" + userRoll + ".png")); JOptionPane.showMessageDialog(null, diceLabel, "Results", JOptionPane.INFORMATION_MESSAGE);
- 10-07-2012, 08:15 PM #2
Senior Member
- Join Date
- Oct 2010
- Location
- Germany
- Posts
- 780
- Rep Power
- 4
Re: Help With Dice Game Please
Try to use html!
->
new JLabel("<html>Your roll: " + userRoll + "<br />Computer's Roll: " + compRoll + "<br />You lost to the computer.</html>");
- 10-07-2012, 08:16 PM #3
Member
- Join Date
- Oct 2012
- Posts
- 7
- Rep Power
- 0
Similar Threads
-
Help with a Dice Game.
By HalfAZN in forum New To JavaReplies: 30Last Post: 04-30-2012, 06:36 PM -
Dice Game
By Rachel1991 in forum New To JavaReplies: 1Last Post: 11-24-2011, 11:10 PM -
Pig Dice Game Help
By pvccstudent in forum New To JavaReplies: 3Last Post: 07-10-2011, 02:21 AM -
Pig dice game
By dangyounoobs in forum New To JavaReplies: 0Last Post: 06-12-2011, 06:57 AM -
Help with a dice game.
By hero in forum AWT / SwingReplies: 14Last Post: 07-26-2009, 11:50 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks