Hello
i'm trying to display date in textfield
this is my code:

private void DateObjectActionPerformed(java.awt.event.ActionEvent evt) {                                           
// TODO add your handling code here:

    java.util.Date date=new java.util.Date();
    this.DateObject.setText(date.toString());

olny the problem is the date will only show If i press a button
I want it to display automatically when I run the programme without the need to press any buttons
i'm using netBeans GUI Bilder
thank you

Edited 3 Years Ago by Osaid9

I want it to display automatically when I run the programme without the need to press any buttons

Set the text field's content in your constructor.

Edited 3 Years Ago by mvmalderen

try this code:

Date date = new Date(); //declare this above;
txtFieldDate.setText(date.toString()); //set this inside you class.

Hi tyranx, welcome to DaniWeb.
Did you notice the date of this thread? It was marked as "solved" five months ago, so your answer is a little late!
Your contributions are very welcome - have a look at some of the more recent topics tha thave not yet been marked so"solved".
JC

This question has already been answered. Start a new discussion instead.