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.
public class Project extends JFrame implements ActionListener {
DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
Date date = new Date();
String addDate =dateFormat.format(date);
JButton btnclose = new JButton("Close");
JButton btnSearch = new JButton("Search");
JLabel datetime = new JLabel(addDate);
Timer timer = new Timer();
Font fonttype = new Font("Verdana",Font.PLAIN,50);
private Vector<Vector<String>> data; //used for data from database
private Vector<String> header; //used to store data header
JTable table = new JTable(data, header);
public void timer() {
timer.scheduleAtFixedRate(new TimerTask(){
public void run() {
datetime.setText(dateFormat.format(new Date()));
}
}, 0, 100);
}
public Project() throws Exception{
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);
DBEngine dbengine = new DBEngine();
data = dbengine.getEmployee();
//create header for the table
header = new Vector<String>();
header.add("StudentID"); //Empid
header.add("Student Name"); // employee name
header.add("Student Lastname"); // employee position
header.add("Student Email"); // employee position
header.add("StudentsRFID"); // employee position
north.setBorder(BorderFactory.createTitledBorder("Date&Time Display"));
BoxLayout layout = new BoxLayout(north, BoxLayout.X_AXIS);
datetime.setFont(fonttype);
north.add(datetime);
timer();
center.setBorder(BorderFactory.createTitledBorder("Attendence Record"));
center.setLayout(new BorderLayout());
center.add(table);
center.add(table.getTableHeader(), BorderLayout.PAGE_START);
center.add(table, BorderLayout.CENTER);
center.add(table.getTableHeader(), BorderLayout.PAGE_START);
south.setBorder(BorderFactory.createTitledBorder("Selection"));
south.add(btnclose);
BoxLayout la = new BoxLayout(south, BoxLayout.X_AXIS);
btnclose.addActionListener(this);
btnSearch.addActionListener(this);
}
public void actionPerformed(ActionEvent sc) {
if(sc.getSource()== btnclose){
System.exit(0);
}
}
public static void main(String [] a) throws Exception{
Project me = new Project();
me.addWindowListener(new WindowAdapter () {
public void run() {
try
{
new Project().setVisible(true);
}catch(Exception e){e.printStackTrace();}
}
@Override
public void windowClosing(WindowEvent e) {
System.exit(0) ;
}
});
me.pack();
me.setVisible(true);
}
import java.awt.BorderLayout;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;
import java.util.Vector;
import javax.swing.*;
public class Project extends JFrame implements ActionListener
{
private static final DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
private final JButton btnclose = new JButton("Close");
private final JButton btnSearch = new JButton("Search");
public Project() throws Exception {
super("Project"); // Fenstername
setDefaultCloseOperation(EXIT_ON_CLOSE); // Fenster schließen, wenn X gedrückt wurde
final JPanel north = new JPanel();
final JPanel south = new JPanel();
final JPanel east = new JPanel();
final JPanel west = new JPanel();
final JPanel center = new JPanel();
add("North", north);
add("South", south);
add("East", east);
add("West", west);
add("Center", center);
final DBEngine dbengine = new DBEngine();
final Vector<Vector<String>> data = dbengine.getEmployee();
// create header for the table
final Vector<String> header = new Vector<String>();
header.add("StudentID"); // Empid
header.add("Student Name"); // employee name
header.add("Student Lastname"); // employee position
header.add("Student Email"); // employee position
header.add("StudentsRFID"); // employee position
final JTable table = new JTable(data, header);
north.setBorder(BorderFactory.createTitledBorder("Date&Time Display"));
final BoxLayout layout = new BoxLayout(north, BoxLayout.X_AXIS);
final JLabel datetime = new JLabel("#NO DATE#");
datetime.setFont(new Font("Verdana", Font.PLAIN, 50));
north.add(datetime);
center.setBorder(BorderFactory.createTitledBorder("Attendence Record"));
center.setLayout(new BorderLayout());
center.add(table);
center.add(table.getTableHeader(), BorderLayout.PAGE_START);
center.add(table, BorderLayout.CENTER);
center.add(table.getTableHeader(), BorderLayout.PAGE_START);
south.setBorder(BorderFactory.createTitledBorder("Selection"));
south.add(btnclose);
final BoxLayout la = new BoxLayout(south, BoxLayout.X_AXIS);
btnclose.addActionListener(this);
btnSearch.addActionListener(this);
new Timer().scheduleAtFixedRate(new TimerTask()
{
@Override
public void run() {
datetime.setText(dateFormat.format(new Date()));
}
}, 0, 100);
}
public void actionPerformed(final ActionEvent sc) {
if (sc.getSource() == btnclose) {
System.exit(0);
}
}
public static void main(final String[] args) throws Exception {
final Project me = new Project();
me.pack();
me.setVisible(true);
}
}