java代码补全 java代码补全文件夹名称快捷键
java 补全代码
楼主,依题意,完整的程序如下:
专注于为中小企业提供成都做网站、网站设计服务,电脑端+手机端+微信端的三站合一,更高效的管理,为中小企业云安免费做网站提供优质的服务。我们立足成都,凝聚了一批互联网行业人才,有力地推动了成百上千企业的稳健成长,帮助中小企业通过网站建设实现规模扩充和转变。
import java.awt.FlowLayout;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class Exam2 extends Thread implements ActionListener
{
//声明界面元素
private JFrame timeFrame;
private JButton startButton;
private JButton stopButton;
private JButton resetButton;
private JLabel timeLabel;
//定义变量存储时、分、秒
int hour = 0;
int minute = 0;
int second = 0;
//声明线程对象
Thread myThread;
public Exam2()
{
timeFrame = new JFrame("计时器");
startButton = new JButton("开始");
stopButton = new JButton("停止");
resetButton = new JButton("重置");
timeLabel = new JLabel("00:00:00");
timeFrame.setLayout(new FlowLayout());
timeFrame.setBounds((Toolkit.getDefaultToolkit().getScreenSize().width - 300)/2,
(Toolkit.getDefaultToolkit().getScreenSize().height - 200)/2, 300, 200);
timeFrame.add(timeLabel);
timeFrame.add(startButton);
timeFrame.add(stopButton);
timeFrame.add(resetButton);
timeFrame.setVisible(true);
timeFrame.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
startButton.addActionListener(this);
stopButton.addActionListener(this);
resetButton.addActionListener(this);
myThread = this;
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource() == this.startButton)
{
System.out.println("计时开始...");
if(this.start)
{
this.myThread.start();
}
else
{
this.start = true;
}
}
if(e.getSource() == this.stopButton)
{
System.out.println("计时停止...");
this.start = false;
}
if(e.getSource() == this.resetButton)
{
hour = 0;
minute = 0;
second = 0;
}
}
volatile boolean start = true;
@Override
public void run()
{
while(true)
{
if(this.start)
{
second++;
try
{
Thread.sleep(1000);
} catch (InterruptedException e)
{
e.printStackTrace();
}
if(second = 60)
{
second = 0;
minute++;
}
if(minute = 60)
{
minute = 0;
hour++;
}
showTime();
}
}
}
private void showTime()
{
String strTime = "";
if(hour 10)
{
strTime += "0"+hour + ":";
}
else
{
strTime += hour + ":";
}
if(minute 10)
{
strTime += "0"+minute + ":";
}
else
{
strTime += minute + ":";
}
if(second 10)
{
strTime += "0"+second;
}
else
{
strTime += second;
}
this.timeLabel.setText(strTime);
}
public static void main(String[] args)
{
new Exam2();
}
}
有问题欢迎提问,满意请采纳,谢谢!
怎样设置Eclipse的java自动补全
设置Eclipse的java自动补全步骤如下:
第一步:打开编译器然后再点开一个java文件。
第二步:在文件里右击鼠标,然后再选择Preferences。
第三步:而后再Preferences里选择java
第四步:再选择Editor,再选择Content Assist
第五步:再在我所圈出的地方设置时间(200)和字母(.ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz),而后点击ok即可。
eclipse的设置界面里面还可以调整整体的字体大小、编辑器的背景颜色等,还有一个保存时自动格式化,可以免去很多不规范的代码。
Java补全代码
public class Manager extends Employee {
private String department;
public String getDepartment() {
return department;
}
public void setDepartment(String department) {
this.department = department;
}
public Manager(String name){
super(name);
}
public Manager(String name,String department){
super(name);
this.department = department;
}
}
public class Main {
public static void main(String[] args) {
Scanner sca = new Scanner(System.in);
String str = sca.next();
String str1 = sca.next();
Manager m = new Manager(str, str1);
System.out.println("name:"+m.getName()+" department:"+m.getDepartment());
}
}
如果Main类中不想用getName()和getDepartment()的话,需要在Manager中把name和department定义成public
本文题目:java代码补全 java代码补全文件夹名称快捷键
URL网址:http://ybzwz.com/article/doshjos.html