Hello people of Stackoverflow, I'm trying to make a Java program that has a title bar with the inputted integer. So here's a little of my code:
import javax.swing.JOptionPane;
public class ConvertHoursToMinutes {
public static void main(String args[]) {
int hours;
int minutes;
hours=Integer.parseInt(JOptionPane.showInputDialog(null,"Enter hour: "));
minutes=hours*60;
JOptionPane.showMessageDialog(null,"Converted into minutes is: " +minutes,"is equivalent to",JOptionPane.INFORMATION_MESSAGE);
}
}
What I want to happen is that, ON THE TITLE BAR OF THE DIALOG BOX, it is default on the output that what's written is MESSAGE right? So I wanted to make it, " the number inputted by the user is equivalent to" what I have on my title bar is only "in minutes is..." please help thanks. I tried searching on Google but I can't find answers.
For example, the user entered 1.
So my title bar (i am hoping) that it should be...
1 in minutes is...
then the output goes
You forgot to add the variable to the String in the message box. Change your message dialog to the following:
JOptionPane.showMessageDialog(null, "Converted into minutes is: " + minutes, hours + " is equivalent to", JOptionPane.INFORMATION_MESSAGE);
According to the constructor you are using, this will set the
message: "Converted into minutes is 60" //for example
title: "is equivelant to: 1" //for example