Backgorund Information :
I have a friend in the navy, and he wanted to know if I could pick it up with a small application that would calculate when he had the guard, because, apparently, it was difficult to count on a calendar. I used JOptionPane.showMessageDialog to give it the output. This is how I do it.
GregorianCalendar knownDate = new GregorianCalendar(year,month,day); GregorianCalendar[] futureDates = new GregorianCalendar[10]; for(int i = 0; i < 10; i++) { futureDates[i] = new GregorianCalendar(year,month,day); futureDates[i].add(Calendar.DAY_OF_MONTH,10*(i+1)); // duty every 10 days } String newline = System.getProperty("line.separator"); StringBuilder sb = new StringBuilder("Jakes duty dates:").append(newline); for(GregorianCalendar d : futureDates) { sb.append(months[d.get(Calendar.MONTH)]).append(" "); sb.append(d.get(Calendar.DAY_OF_MONTH)).append(newline); } JOptionPane.showMessageDialog(null,sb.toString());
"The only problem" is that you cannot select the text that is displayed. He would like to choose him for instant messaging and e-mail, because the point is that he was only half lazy, right? (Only the problem is in quotation marks, because I have a feeling that he will cover it to death ... haha)
My question is :
Is there a one-line solution for choosing showMessageDialog ?
java swing
corsiKa
source share