1、首先在电脑中新建一个记事本,将记事本的后缀改为“.java”,如下图所示。
2、然后使用记事本的方式打开,输入java程序代码,如下图所示。
3、接着在键盘上按“win+R”快捷键键打开运行,输入“cmd”,如下图所示。
4、在命令行输入“D:”,按“Enter”键进去D盘,再输入“cd Desktop”进去Desktop文件夹,如下图所示。
5、最后再输入“javac Test.java”,按“Enter”键编译java程序,如下图所示就完成了。
全实现,程序太长,发不上去,先实现基本的 图形用户界面import java.awt.*
import java.awt.event.*
public class TestMenu {
public static void main (String[] args) {
new MenuFrame("新建"+" "+"文本文档"+".txt"+" "+"-"+" "+"记事本").launchFrame()
}
}
class MenuFrame extends Frame {
MenuBar mb = null
MenuFrame (String s) {
super (s)
}
public void launchFrame() {
Menu file = new Menu ("文件")
Menu edit = new Menu ("编辑")
Menu format = new Menu ("格式")
Menu help = new Menu ("帮助")
MenuItem newItem = new MenuItem ("新建")
newItem.addActionListener (new ActionListener () {
public void actionPerformed(ActionEvent e) {
final Frame ff = new Frame ("记事本")
ff.setMenuBar(mb)
ff.setBounds (300,300,400,200)
ff.setVisible (true)
ff. addWindowListener (new WindowAdapter () {
public void windowClosing(WindowEvent e) {
ff.setVisible (false)
}
} )
}
})
MenuItem saveItem = new MenuItem ("保存")
MenuItem exitItem = new MenuItem ("退出")
MenuItem helpTitle = new MenuItem ("帮助主题")
MenuItem line = new MenuItem ("-")
MenuItem about = new MenuItem ("关于记事本")
MenuItem copy = new MenuItem ("粘贴")
MenuItem serach = new MenuItem ("查找")
edit.add (copy)
edit.add (serach)
help.add (helpTitle)
help.add (line)
help.add (about)
exitItem.addActionListener (new ActionListener () {
public void actionPerformed(ActionEvent e) {
System.exit (0)
}
} )
file.add (newItem)
file.add (saveItem)
file.add (exitItem)
mb = new MenuBar()
mb.add (file)
mb.add (edit)
mb.add (format)
mb.add (help)
addWindowListener (new WindowAdapter () {
public void windowClosing(WindowEvent e) {
System.exit (0)
}
} )
setLayout (new FlowLayout())
setMenuBar (mb)
setBounds (300,300,400,200)
setVisible (true)
}
}
日历记事本课程设计报告java编写
/*
说明:主程序
*/
import
java.util.Calendar
import
javax.swing.*
import
java.awt.*
import
java.awt.event.*
import
java.io.*
import
java.util.Hashtable
public
class
CalendarPad
extends
JFrame
implements
MouseListener
{
int
year,month,day
Hashtable
hashtable
File
file
JTextField
showDay[]
JLabel
title[]
Calendar
日历
int
星期几
NotePad
notepad=null
Month
负责改变月
Year
负责改变年
String
星期[]={"星期日","星期一","星期二","星期三","星期四","星期五","星期六"}
JPanel
leftPanel,rightPanel
public
CalendarPad(int
year,int
month,int
day)
{
leftPanel=new
JPanel()
//左边日历...........
JPanel
leftCenter=new
JPanel()
JPanel
leftNorth=new
JPanel()
leftCenter.setLayout(new
GridLayout(7,7))
rightPanel=new
JPanel()
this.year=year
this.month=month
this.day=day
负责改变年=new
Year(this)
负责改变年.setYear(year)
负责改变月=new
Month(this)
负责改变月.setMonth(month)
title=new
JLabel[7]
showDay=new
JTextField[42]
for(int
j=0j<7j++)
{
title[j]=new
JLabel()
title[j].setText(星期[j])
title[j].setBorder(BorderFactory.createRaisedBevelBorder())
leftCenter.add(title[j])
}
........
看下是不是收到了啊
额外人提问
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)