import java.awt.*;
import javax.swing.*;
public class Test extends JApplet{
byte january = 1;
int date = 18;
long year = 1995;
I want the screen to be able to say: 1/18/1995 and I'm not sure of how to accomplish that.
1 个答案:
答案 0 :(得分:2)
Use the built in println() method:
System.out.println(month + "//" + date + "//" + year);
EDIT for use with JApplet (Swing)
Put this in a label:
import javax.swing.JLabel;
// ... other code
JLabel label = new JLabel(month + "//" + date + "//" + year);
// you can set the vertical and horizontal text positions with these lines:
// label1.setVerticalTextPosition(JLabel.BOTTOM);
// label1.setHorizontalTextPosition(JLabel.CENTER);
// assuming your JPanel is called panel
panel.add(label);
(the double backslahes are to escape each other and print out a single backslash; you use + operator to concatenate strings; month, date, and year will automatically be converted to strings here)