大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
eclipse菜单栏windows---preferences----左侧展开General----key---找到Content Assist选中 在下面的快捷键位置把原来的删除 添加新的快捷键就可以了,我的是alt+j 这样收可以不用离开键盘 可以参考一下
让客户满意是我们工作的目标,不断超越客户的期望值来自于我们对这个行业的热爱。我们立志把好的技术通过有效、简单的方式提供给客户,将通过不懈努力成为客户在信息化领域值得信任、有价值的长期合作伙伴,公司提供的服务项目有:空间域名、虚拟主机、营销软件、网站建设、都兰网站维护、网站推广。
工具:eclipse
步骤:
1、打开eclipse,然后找到Windows
2、接下来点击Windows,然后选择perferences
3、接下来选择java
4、接下里选择Editor,然后再选择Content Assis
5、最后在图中红框内填入(200)和.ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxy,然后 点解ok,就行了
以下代码仅供参考,用的是另外一种思路
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
public class Main {
public static void main(String[] args) {
Calendar c = Calendar.getInstance();
SimpleDateFormat s = new SimpleDateFormat("yyyy");
int year = Integer.parseInt(s.format(new Date()));
s = new SimpleDateFormat("MM");
int month = Integer.parseInt(s.format(new Date()));
s = new SimpleDateFormat("dd");
int day = c.get(Calendar.DAY_OF_MONTH);
c.set(Calendar.YEAR, year);
c.set(Calendar.MONTH, month);
System.out.println(year + "年" + month + "月" + day + "日" + "\t" + "日历如下:");
c = Calendar.getInstance();
int currentMonth = -1;
c.set(year, 0, 1);
while (c.get(Calendar.YEAR) == year) {
/**
* 判断是否处于同一个月份
* 若不是 则需要输出表头
*
*/
if (currentMonth != c.get(Calendar.MONTH)) {
System.out.println("");
System.out.println("");
currentMonth = c.get(Calendar.MONTH);
System.out.println((currentMonth + 1) + "月");
System.out.println("星期日\t星期一\t星期二\t星期三\t星期四\t星期五\t星期六");
for (int i = 1, k = c.get(Calendar.DAY_OF_WEEK); i k; i++) {
System.out.print(String.format("%1$5s\t", ""));
}
}
System.out.print(String.format("%1$5d\t", c.get(Calendar.DAY_OF_MONTH)));
/**
* 日期+1
*/
c.add(Calendar.DAY_OF_YEAR, 1);
/**
* 当日期是星期天并且不是一个月的最后一天时 输出换行
*/
if (c.get(Calendar.DAY_OF_WEEK) == 1 currentMonth == c.get(Calendar.MONTH)) {
System.out.println("");
}
}
}
}
楼主,依题意,完整的程序如下:
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();
}
}
有问题欢迎提问,满意请采纳,谢谢!