Folge dem Video um zu sehen, wie unsere Website als Web-App auf dem Startbildschirm installiert werden kann.
Anmerkung: Diese Funktion ist in einigen Browsern möglicherweise nicht verfügbar.
DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
Date date = new Date();
String addDate =dateFormat.format(date);
JPanel north = new JPanel()
add("North",north);
north.add(new JLabel(addDate)); // Dies will ich fontsize 18 und Tickent haben ?
import java.awt.Font;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class JSimpleClock extends JLabel
{
private final DateFormat formatter = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
public JSimpleClock() {
setHorizontalAlignment(CENTER);
setFont(new Font("Arial", Font.PLAIN, 18));
new Timer().scheduleAtFixedRate(new TimerTask()
{
@Override
public void run() {
setText(formatter.format(new Date()));
}
}, 0, 100);
}
public static void main(final String[] args) {
final JFrame f = new JFrame("JClock - Demo");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setSize(200, 50);
f.add(new JSimpleClock());
f.setResizable(false);
f.setUndecorated(true);
f.setLocationRelativeTo(null);
f.setVisible(true);
}
}
public class Project extends JFrame implements ActionListener {
DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
Date date = new Date();
String addDate =dateFormat.format(date);
JButton btnOk = new JButton("Run");
JButton btnSearch = new JButton("Search");
JComboBox jcbSelect = new JComboBox();
JTextField jtfName = new JTextField(10);
TextArea information = new TextArea(20,80);
LibraryData db = new LibraryData();
JLabel datetime = new JLabel(addDate);
public Project(){
JPanel north = new JPanel();
JPanel south = new JPanel();
JPanel east = new JPanel();
JPanel west = new JPanel();
JPanel center = new JPanel();
add("North",north);
add("South",south);
add("East",east);
add("West",west);
add("Center",center);
north.setBorder(BorderFactory.createTitledBorder("Output"));
BoxLayout layou = new BoxLayout(north, BoxLayout.X_AXIS);
north.add(datetime); // Hier habe ich es Hinzugefuegt dies soll Fontsize 18 sein und ticken
btnOk.addActionListener(this);
btnSearch.addActionListener(this);
south.setBorder(BorderFactory.createTitledBorder("Output"));
south.add(btnOk);
BoxLayout la = new BoxLayout(south, BoxLayout.X_AXIS);
center.add(information);
}
public void actionPerformed(ActionEvent sc) {
DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
Date date = new Date();
String addDate =dateFormat.format(date);
....
JLabel datetime = new JLabel(addDate);
public class Project extends JFrame implements ActionListener {
DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
Date date = new Date();
String addDate =dateFormat.format(date);
JButton btnOk = new JButton("Run");
JButton btnSearch = new JButton("Search");
JComboBox jcbSelect = new JComboBox();
JTextField jtfName = new JTextField(10);
TextArea information = new TextArea(20,80);
LibraryData db = new LibraryData();
JLabel datetime = new JLabel(addDate);
Timer timer = new Timer();
public void timer() {
timer.scheduleAtFixedRate(new TimerTask(){
@Override
public void run() {
setText(dateFormat.format(new Date())); // Er gibt mir ein Fehler fuer setText er will das ich zu setTitle aender. es funk. trotzdem nicht
}
}, 0, 100);
}
public Project(){
JPanel north = new JPanel();
JPanel south = new JPanel();
JPanel east = new JPanel();
JPanel west = new JPanel();
JPanel center = new JPanel();
add("North",north);
add("South",south);
add("East",east);
add("West",west);
add("Center",center);
north.setBorder(BorderFactory.createTitledBorder("Output"));
BoxLayout layou = new BoxLayout(north, BoxLayout.X_AXIS);
north.add(datetime);