Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

I need to display the system date in a Textfield

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Hello everyone and anyone,
I need to display the system date in the textfield, but it is not recognised when i try to do so, the date type is not compatible with the setText() method.
the code is below, I have commented where the error is.
import java.awt.*;
import java.applet.*;
import java.util.Date;
/*<applet code="display" width=200 height=300></applet>*/
public class display extends Applet
{
Label lbl1, lbl2, lbl3;
TextField t1, t2;
Choice clist;
GridBagLayout gb;
GridBagConstraints gbc;
public void init()
{
gb = new GridBagLayout();
setLayout(gb);
gbc = new GridBagConstraints();
lbl1 = new Label("Name:");
lbl2 = new Label("Course Enrolled:");
lbl3 = new Label("Date Enrolled:");
t1 = new TextField(15);
t2 = new TextField(,15);

//display the date in a textfield.
//t2.setText(new Date());
clist = new Choice();

clist.addItem("Office Assistant");
clist.addItem("CPISM");
clist.addItem("DISM");
clist.addItem("HDSE");
clist.addItem("ADSE");
gbc.fill=GridBagConstraints.BOTH;
addComp(lbl1,0,0,1,1);
gbc.fill=GridBagConstraints.BOTH;
addComp(t1,0,1,1,1);
gbc.fill=GridBagConstraints.BOTH;
addComp(lbl2,1,0,1,1);
gbc.fill=GridBagConstraints.BOTH;
addComp(clist,1,1,1,1);
gbc.fill=GridBagConstraints.BOTH;
addComp(lbl3,2,0,1,1);
gbc.fill=GridBagConstraints.BOTH;
addComp(t2,2,1,1,1);


}
public void addComp(Component c, int row, int col, int nrow, int ncol)
{
gbc.gridx=col;
gbc.gridy=row;
gbc.gridwidth=ncol;
gbc.gridheight=nrow;
gb.setConstraints(c, gbc);
add(c);
}

}
Prue.
 
Rancher
Posts: 1449
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
You've posted this twice so I'll close this thread of the two.
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic