当前位置:网站首页>Swing display time (click once to display once)
Swing display time (click once to display once)
2022-04-23 05:08:00 【FOWng_ lp】
import javax.swing.*;
import java.awt.*;
public class SwingDemo
{
private static void createGUI()
{
MyFrame frame = new MyFrame("Swing Demo");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(400, 300);
frame.setVisible(true);
}
public static void main(String[] args)
{
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run()
{
createGUI();
}
});
}
}
import javax.swing.*;
import javax.swing.plaf.multi.MultiButtonUI;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.SimpleTimeZone;
public class MyFrame extends JFrame {
JLabel timetable = new JLabel("00:00:00");
JButton button = new JButton(" Display time ");
public MyFrame(String swing_demo) {
super(swing_demo);
// Content panel
Container contenePane = getContentPane();
contenePane.setLayout(new FlowLayout());
// Add components to the content panel
contenePane.add(button);
contenePane.add(timetable);
//contenePane.add(new JButton(" test 2"));
// Create a listener object
MyButtonListener listener = new MyButtonListener();
button.addActionListener(listener);
}
//ActionListener It's a interface
private class MyButtonListener implements ActionListener{
public void actionPerformed(ActionEvent e){
// When the button is clicked ,Swing The framework will automatically call the listener actionPerformed() Method
System.out.println(" Button clicked ...");
MyFrame.this.showtime();
}
}
public void showtime(){
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
String timetr = sdf.format(new Date());
timetable.setText(timetr);
}
}
版权声明
本文为[FOWng_ lp]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220549345629.html
边栏推荐
- Sword finger offer: symmetric binary tree (recursive iteration leetcode 101)
- How does PostgreSQL parse URLs
- Chapter III project schedule management of information system project manager summary
- C list field sorting contains numbers and characters
- 深度学习笔记 —— 物体检测和数据集 + 锚框
- Download PDF from HowNet (I don't want to use CAJViewer anymore!!!)
- Deep learning notes - semantic segmentation and data sets
- Use the built-in function of win to transfer files between two computers in the same LAN (the speed is the same as that between local disks)
- Leetcode 1547: minimum cost of cutting sticks
- Independent station operation | Facebook marketing artifact - chat robot manychat
猜你喜欢

Download PDF from HowNet (I don't want to use CAJViewer anymore!!!)

数据安全问题已成隐患,看vivo如何让“用户数据”重新披甲

Use model load_ state_ Attributeerror appears when dict(): 'STR' object has no attribute 'copy‘

Details related to fingerprint payment
![[WinUI3]编写一个仿Explorer文件管理器](/img/3e/62794f1939da7f36f7a4e9dbf0aa7a.png)
[WinUI3]编写一个仿Explorer文件管理器

Perfect test of coil in wireless charging system with LCR meter

Uglifyjs compress JS
![[2022 ICLR] Pyramid: low complexity pyramid attention for long range spatiotemporal sequence modeling and prediction](/img/7c/51ac43080d9721f1bdc1cd78cd685b.png)
[2022 ICLR] Pyramid: low complexity pyramid attention for long range spatiotemporal sequence modeling and prediction
![[2021] Spatio-Temporal Graph Contrastive Learning](/img/7d/67a0bfa0adecee24bbe291a25ae906.png)
[2021] Spatio-Temporal Graph Contrastive Learning

【数据库】MySQL基本操作(基操~)
随机推荐
直播带货表格模板-自动显示图片-自动关联系列商品
#define 定义常量和宏,指针和结构体
Detailed explanation of hregionserver
Differences between redis and MySQL
A trinomial expression that causes a null pointer
Innovation training (V) mid term inspection
[WinUI3]编写一个仿Explorer文件管理器
The applet calls the function of scanning QR code and jumps to the path specified by QR code
JS engine loop mechanism: synchronous, asynchronous, event loop
Barcode generation and decoding, QR code generation and decoding
Live delivery form template - automatically display pictures - automatically associate series products
Unity C e-learning (IV)
MySQL memo (for your own query)
Servlet3 0 + event driven for high performance long polling
Innovation training (XI) airline ticket crawling company information
scp命令详解
The difference between static pipeline and dynamic pipeline
Mac enters MySQL terminal command
Golang select priority execution
On distributed lock