Results 1 to 3 of 3
  1. #1
    Visions is offline Member
    Join Date
    Oct 2012
    Posts
    7
    Rep Power
    0

    Exclamation 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?

    Help With Dice Game Please-diceprogram.png

    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);

  2. #2
    eRaaaa is offline Senior Member
    Join Date
    Oct 2010
    Location
    Germany
    Posts
    786
    Rep Power
    5

    Default 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>");

  3. #3
    Visions is offline Member
    Join Date
    Oct 2012
    Posts
    7
    Rep Power
    0

    Default Re: Help With Dice Game Please

    That worked! Thank you very much

Similar Threads

  1. Pig dice game
    By dangyounoobs in forum New To Java
    Replies: 2
    Last Post: 12-09-2013, 04:21 AM
  2. Help with a Dice Game.
    By HalfAZN in forum New To Java
    Replies: 30
    Last Post: 04-30-2012, 06:36 PM
  3. Dice Game
    By Rachel1991 in forum New To Java
    Replies: 1
    Last Post: 11-24-2011, 11:10 PM
  4. Pig Dice Game Help
    By pvccstudent in forum New To Java
    Replies: 3
    Last Post: 07-10-2011, 02:21 AM
  5. Help with a dice game.
    By hero in forum AWT / Swing
    Replies: 14
    Last Post: 07-26-2009, 11:50 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •