日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
java代碼實現(xiàn)自動計 java如何自動生成代碼

java怎么讓代碼自動

你說的是Eclipse代碼自動補(bǔ)全功能吧??梢詫崿F(xiàn)輸入任意字母均可出現(xiàn)代碼補(bǔ)全提示框。

成都創(chuàng)新互聯(lián)公司專注于企業(yè)全網(wǎng)整合營銷推廣、網(wǎng)站重做改版、肥鄉(xiāng)網(wǎng)站定制設(shè)計、自適應(yīng)品牌網(wǎng)站建設(shè)、H5高端網(wǎng)站建設(shè)商城開發(fā)、集團(tuán)公司官網(wǎng)建設(shè)、成都外貿(mào)網(wǎng)站制作、高端網(wǎng)站制作、響應(yīng)式網(wǎng)頁設(shè)計等建站業(yè)務(wù),價格優(yōu)惠性價比高,為肥鄉(xiāng)等各大城市提供網(wǎng)站開發(fā)制作服務(wù)。

具體設(shè)置方式如下:

eclipse--windows--preferences--java--editor--content assist--右邊設(shè)置如下圖

紅色箭頭指向的地方設(shè)置為:

.abcdefghijklmnopqrstuvwxyz(26個字母全部寫進(jìn)去不區(qū)分大小寫)

用java編寫一個倒計時器代碼。

import java.awt.BorderLayout;import java.awt.Container;import java.awt.Font;import java.awt.GridLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JTextField;public class TimerDemo extends JFrame implements ActionListener { private static final long serialVersionUID = 201306211111L; private JTextField screen = new JTextField("0"); private JButton start = new JButton("開始"); private JButton reset = new JButton("重置"); private JPanel panel = new JPanel(); private boolean isRunning; private int time; private int timeBetween; public TimerDemo(int timeBetween) { super("計時器"); this.timeBetween = timeBetween; try { init(); } catch (Exception e) { e.printStackTrace(); } } public TimerDemo() { super("計時器"); this.timeBetween = 100; try { init(); } catch (Exception e) { e.printStackTrace(); } } private void init() { panel.setLayout(new GridLayout()); panel.add(start); panel.add(reset); start.addActionListener(this); reset.addActionListener(this); screen.setFont(new Font("幼圓", Font.BOLD, 60)); screen.setHorizontalAlignment(JTextField.CENTER); screen.setEditable(false); Container c = getContentPane(); c.setLayout(new BorderLayout()); c.add(panel, BorderLayout.SOUTH); c.add(screen, BorderLayout.CENTER); this.setSize(200, 150); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setResizable(false); this.setLocationRelativeTo(null); this.setVisible(true); } public static void main(String[] args) { new TimerDemo(1);// 設(shè)定 1ms/次 // new TimerDemo(); } @Override public void actionPerformed(ActionEvent e) { if (e.getSource() == start) { if (start.getText().equals("開始")) { start.setText("暫停"); isRunning = true; } else if (start.getText().equals("暫停")) { start.setText("開始"); isRunning = false; } } if (e.getSource() == reset) { start.setText("開始"); screen.setText("0"); isRunning = false; time = 0; } new Thread(new TimeZone()).start(); } class TimeZone implements Runnable { @Override public void run() { while (isRunning) { time++; if (time = Integer.MAX_VALUE) { screen.setText("ERROR"); JOptionPane.showMessageDialog(null, "ERROR"); isRunning = false; } screen.setText(String.valueOf(time)); try { Thread.sleep(timeBetween); } catch (Exception e) { e.printStackTrace(); } } } }}

java中如何實現(xiàn)自動計時功能,就是點擊一個start按鈕就開始計時,以秒為單位

簡單代碼如下:

import?java.awt.Button;

import?java.awt.FlowLayout;

import?java.awt.Label;

import?java.awt.event.ActionEvent;

import?java.awt.event.ActionListener;

import?java.text.SimpleDateFormat;

import?java.util.Date;

import?javax.swing.JFrame;

import?javax.swing.Timer;

@SuppressWarnings("serial")

public?class?Timers?extends?JFrame?{

final?Label?lab?=?new?Label();

Date?now?=?new?Date();

@SuppressWarnings("deprecation")

public?Timers()?{

now.setHours(0);

now.setMinutes(0);

now.setSeconds(0);

setBounds(550,?270,?200,?150);

final?Timer?timer?=?new?Timer(1000,?new?ActionListener()?{

public?void?actionPerformed(ActionEvent?e)?{

Date?now2?=?new?Date(now.getTime()?+?1000);

now?=?now2;

SimpleDateFormat?formatter?=?new?SimpleDateFormat("HH:mm:ss");

lab.setText(formatter.format(now));

}

});

Button?b1?=?new?Button("開始");

Button?b2?=?new?Button("停止");

b2.setBounds(40,?40,?40,?40);

b1.setBounds(30,?30,?30,?30);

b1.addActionListener(new?ActionListener()?{

@Override

public?void?actionPerformed(ActionEvent?e)?{

Button?b?=?(Button)?e.getSource();

b.setLabel("開始");

timer.start();

}

});

b2.addActionListener(new?ActionListener()?{

@Override

public?void?actionPerformed(ActionEvent?e)?{

Button?b?=?(Button)?e.getSource();

b.setLabel("停止");

timer.stop();

}

});

this.setLayout(new?FlowLayout());

this.add(b2);

this.add(b1);

this.add(lab);

this.setSize(300,?200);

this.setVisible(true);

this.setDefaultCloseOperation(EXIT_ON_CLOSE);

}

public?static?void?main(String[]?args)?{

Timers?t?=?new?Timers();

t.lab.setText("00:00:00");

}

}

不知是否幫到你,如滿意請采納!

求人用java編寫一條計時器代碼。

import?java.awt.BorderLayout;

import?java.awt.Container;

import?java.awt.GridLayout;

import?java.awt.event.ActionEvent;

import?java.awt.event.ActionListener;

import?java.awt.event.WindowEvent;

import?java.awt.event.WindowListener;

import?java.io.*;

import?java.util.*;

import?javax.swing.JButton;

import?javax.swing.JFrame;

import?javax.swing.JOptionPane;

import?javax.swing.JPanel;

import?javax.swing.JTextField;

import?javax.swing.plaf.OptionPaneUI;

public?class?Demo?{

static?boolean?isRuning=false;

static?boolean?isFirst=true;

@SuppressWarnings("unchecked")

public?static?void?main(String[]?args)?throws?Exception?{

JFrame?form1?=?new?JFrame("Form1");

JTextField?jTextField?=?new?JTextField(10);

jTextField.setSize(10,?10);

jTextField.setText("0");

jTextField.setEditable(false);

JButton?jButton?=?new?JButton("開始");

jButton.setSize(10,?10);

Thread?thread?=?new?Thread(new?Runnable()?{

@Override

public?void?run()?{

while?(true)?{

while(isRuning){

Integer?counter?=?Integer.parseInt(jTextField.getText().trim());

counter++;

jTextField.setText(counter.toString());

try?{

Thread.sleep(1000);

}?catch?(Exception?e2)?{

}

}

}

}

});

jButton.addActionListener(new?ActionListener()?{

@Override

public?void?actionPerformed(ActionEvent?e)?{

???String?text=jButton.getText().equals("開始")?"暫停":"開始";

???jButton.setText(text);

???isRuning=!isRuning;

???if(isFirst){

???thread.start();

???isFirst=false;

???}

}

});

JPanel?panel?=?new?JPanel();

panel.setSize(200,?200);

panel.add(jTextField,?BorderLayout.NORTH);

panel.add(jButton,?BorderLayout.CENTER);

form1.add(panel);

form1.setBounds(200,?100,?250,?150);

form1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

form1.addWindowListener(new?WindowListener()?{

@Override

public?void?windowOpened(WindowEvent?e)?{

//?TODO?Auto-generated?method?stub

}

@Override

public?void?windowIconified(WindowEvent?e)?{

//?TODO?Auto-generated?method?stub

}

@Override

public?void?windowDeiconified(WindowEvent?e)?{

//?TODO?Auto-generated?method?stub

}

@Override

public?void?windowDeactivated(WindowEvent?e)?{

//?TODO?Auto-generated?method?stub

}

@Override

public?void?windowClosing(WindowEvent?e)?{

//?窗口關(guān)閉前取出文本框的數(shù)字保存到外部文件,代碼在此處寫

JOptionPane.showMessageDialog(null,?"Are?you?sure?closing?");

}

@Override

public?void?windowClosed(WindowEvent?e)?{

//?TODO?Auto-generated?method?stub

}

@Override

public?void?windowActivated(WindowEvent?e)?{

//?TODO?Auto-generated?method?stub

}

});

form1.setVisible(true);

}

}


網(wǎng)站題目:java代碼實現(xiàn)自動計 java如何自動生成代碼
網(wǎng)址分享:http://www.dlmjj.cn/article/hipopi.html