Java:
package com.company;
import java.awt.*;
import java.text.*;
import java.util.*;
import javax.swing.*;
public class myfarme extends JFrame{
Calendar calendar;
SimpleDateFormat timeFormat;
JLabel timeLabel;
String time;
myfarme()
{
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setTitle("Clock Program");
this.setLayout(new FlowLayout());
this.setSize(350,200);
this.setResizable(false);
timeFormat = new SimpleDateFormat("hh:mm a");
timeLabel = new JLabel();
timeLabel.setFont(new Font("Verdana",Font.PLAIN,50));
timeLabel.setForeground(new Color(0x00FF00));
timeLabel.setBackground(Color.black);
timeLabel.setOpaque(true);
this.add(timeLabel);
this.setVisible(true);
setTime();
}
public void setTime() {
while(true) {
time = timeFormat.format(Calendar.getInstance().getTime());
timeLabel.setText(time);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
Guten Abend ich habe hier Code für eine uhr mit GUI aber das Problem ist, dass die zeit so gezeigt wird ( 9:30 anstatt 21:30 ) kann jemand mir sagen wie ich das ändern kann und nch eine frage
gibt es die möglichkeit die uhr einzustellen ( ich meine also wenn ich auf die taste Klicke dann kann ich die uhr zeit ändern bei userface
ich freue mich auf paar tipps
vielen dank