java - How can I make these data types display their values on screen? -
import java.awt.*; import javax.swing.*; public class test extends japplet{ byte january = 1; int date = 18; long year = 1995;
i want screen able say: 1/18/1995 , i'm not sure of how accomplish that.
use built in println()
method:
system.out.println(month + "//" + date + "//" + year);
edit use japplet
(swing)
put in label:
import javax.swing.jlabel; // ... other code jlabel label = new jlabel(month + "//" + date + "//" + year); // can set vertical , horizontal text positions these lines: // label1.setverticaltextposition(jlabel.bottom); // label1.sethorizontaltextposition(jlabel.center); // assuming jpanel called panel panel.add(label);
(the double backslahes escape each other , print out single backslash; use +
operator concatenate strings; month, date, , year automatically converted strings here)
Comments
Post a Comment