After
I would always like to display a java.util.Date in a JFrame with refresh will be refreshed when viewing the new date.
package supporters; Import java.awt.event.ActionEvent; Import java.awt.event.ActionListener; Import javax.swing.JOptionPane; Import javax.swing.Timer; Public class date {public stable timer t; Public stationary zero main (string [] args) {time (); } Public static timer timing () {t = New timer (1000, New ActionListener) {@SuppressWarnings ("Protest") @Override Public Zero ActionPerformed (ActionEvent arg0) {// TODO Automatic Created Method Stub JointPane.showMessageDialog (Zero , New java.util.Date (). ToGMTString ());}}); T.setRepeats (true); T.start (); Return T; I think I have done something wrong in the timer method I also tried to edit it
package supporter; Import java.awt.flowLayout; Import java.util.Date; Import javax.swing.JFrame; Import javax.swing.JLabel; Public Sector Date {Private Static JLabel L; Private static date d = new date (); Private Static JFrame f; @SuppressWarnings ("deprecation") public static zero main (string [] args) {f = new JFrame ("date program"); F.setVisible (true); F.pack (); F.revalidate (); F.setLayout (New Flow Layout (Flow Layouts. LEFT)); F.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); L = new JLABEL (DTMMTSTring ()); F.add (l); While (true) {l.revalidate (); }}}
Any answer will be appreciated.
"When I just write it this way like this I run in the second without being replaced in date it happens."
Just add a JLabel
to JOPtionPane and only JLabel
to the timer
> Update in Do not put a code in the joppaypackname
in the timer
code. Here is an example
import java.awt.event.ActionEvent; Import java.awt.event.ActionListener; Import java.util.Date; Import javax.swing.JLabel; Import javax.swing.JOptionPane; Import javax.swing.SwingUtilities; Import javax.swing.Timer; Public square clock {public static void} {SwingUtilities.invokeLater (New Runnable) {Public Zero Run} {Last Date Date = New Date (); Last JLabel timeLabel = New JLabel (date.toString () Timer Timer = New Timer (1000, New ActionListener) {Public Zero actionPerformed (ActionEvent e) {date.setTime (System.currentTimeMillis ()); timeLabel.setText (date.toString ());}}); Timer . Start (); JoptionPan.Shomosexialog (tap, timelabel);}}); }}
Comments
Post a Comment