在java中,如何在标签中每秒显示一下当前系统时间
4个回答
推荐于2017-08-27 · 知道合伙人互联网行家
正青春梦飞扬
知道合伙人互联网行家
向TA提问 私信TA
知道合伙人互联网行家
采纳数:6837
获赞数:306021
对SEO有这独特见解 工作努力积极、团结同事 连续2个月个人工作完成优秀 客户0投诉 评委最佳班组经理
向TA提问 私信TA
关注
展开全部
通过new Date获取当前的日期与时间
示例:
public static void main(String[] args){
Date now = new Date(); //获取当前时间
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");//格式化当前日期时间,显示如2015/06/27 14:22:22
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你说的是在jsp中吗?
如果是的话在jsp页面有设置<meta http-equiv="refresh" content="1">,
每秒刷新一次,就行了!!
<%Date date = new Date(); %>
<%=date %>//这样获取当前时间
希望对你有帮助。。。
如果是的话在jsp页面有设置<meta http-equiv="refresh" content="1">,
每秒刷新一次,就行了!!
<%Date date = new Date(); %>
<%=date %>//这样获取当前时间
希望对你有帮助。。。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
public class MyDesktopPane extends JFrame implements ActionListener {
final static JDesktopPane desktopPane = new JDesktopPane();
public MyDesktopPane() {
super("MyDesktopPane.java:DesktopPane测试");
JMenuBar menuBar = new JMenuBar();
JMenu menu = new JMenu("新增窗口");
JMenuItem menultem = new JMenuItem("内部框架窗口");
menu.add(menultem);
menuBar.add(menu);
setJMenuBar(menuBar);
getContentPane().add(desktopPane);
menultem.addActionListener(this);
setSize(350, 200);
setVisible(true);
}
public void actionPerformed(ActionEvent e) {
JInternalFrame inFrame = new JInternalFrame("内部框架(圆环)", true, true, true, true);
Container c = inFrame.getContentPane();
CirclePanel circlePanel = new CirclePanel();
JLabel label = new JLabel("圆环");
c.add(circlePanel, BorderLayout.CENTER);
c.add(label, BorderLayout.WEST);
int w = circlePanel.getImageWidthHeight().width + 150;
int h = circlePanel.getImageWidthHeight().height + 50;
inFrame.setSize(w, h);
inFrame.reshape(100, 50, w, h);
inFrame.setOpaque(true);
desktopPane.add(inFrame);
inFrame.setVisible(true);
}
public static void main(String args[]) {
MyDesktopPane app = new MyDesktopPane();
app.addWindowListener(new MyWindowListener());
}
}
class CirclePanel extends JPanel {
private ImageIcon imglcon;
public CirclePanel() {
try {
imglcon = new ImageIcon(new URL(""));
} catch (MalformedURLException ex) {
Logger.getLogger(CirclePanel.class.getName()).log(Level.SEVERE, null, ex);
}
}
public void paint(Graphics g) {
g.drawImage(imglcon.getImage(), 0, 0, this);
}
public Dimension getImageWidthHeight() {
return new Dimension(imglcon.getIconWidth(), imglcon.getIconHeight());
}
}
class MyWindowListener extends WindowAdapter {
public void windowClosing(WindowEvent e) {
System.exit(1);
}
}
final static JDesktopPane desktopPane = new JDesktopPane();
public MyDesktopPane() {
super("MyDesktopPane.java:DesktopPane测试");
JMenuBar menuBar = new JMenuBar();
JMenu menu = new JMenu("新增窗口");
JMenuItem menultem = new JMenuItem("内部框架窗口");
menu.add(menultem);
menuBar.add(menu);
setJMenuBar(menuBar);
getContentPane().add(desktopPane);
menultem.addActionListener(this);
setSize(350, 200);
setVisible(true);
}
public void actionPerformed(ActionEvent e) {
JInternalFrame inFrame = new JInternalFrame("内部框架(圆环)", true, true, true, true);
Container c = inFrame.getContentPane();
CirclePanel circlePanel = new CirclePanel();
JLabel label = new JLabel("圆环");
c.add(circlePanel, BorderLayout.CENTER);
c.add(label, BorderLayout.WEST);
int w = circlePanel.getImageWidthHeight().width + 150;
int h = circlePanel.getImageWidthHeight().height + 50;
inFrame.setSize(w, h);
inFrame.reshape(100, 50, w, h);
inFrame.setOpaque(true);
desktopPane.add(inFrame);
inFrame.setVisible(true);
}
public static void main(String args[]) {
MyDesktopPane app = new MyDesktopPane();
app.addWindowListener(new MyWindowListener());
}
}
class CirclePanel extends JPanel {
private ImageIcon imglcon;
public CirclePanel() {
try {
imglcon = new ImageIcon(new URL(""));
} catch (MalformedURLException ex) {
Logger.getLogger(CirclePanel.class.getName()).log(Level.SEVERE, null, ex);
}
}
public void paint(Graphics g) {
g.drawImage(imglcon.getImage(), 0, 0, this);
}
public Dimension getImageWidthHeight() {
return new Dimension(imglcon.getIconWidth(), imglcon.getIconHeight());
}
}
class MyWindowListener extends WindowAdapter {
public void windowClosing(WindowEvent e) {
System.exit(1);
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询