文件名称:Demo7
介绍说明--下载内容均来自于网络,请自行研究使用
设计一个窗口, 窗口中的元素如下:
菜单,其内容模仿记事本的菜单
三个文本框,一个按钮.在前两个文本框中输入两个整数, 点击按钮后把两数之和显示到第三个文本框中.-package cn
import java.awt.*
import java.awt.event.ActionEvent
import java.awt.event.ActionListener
import java.awt.event.WindowAdapter
import java.awt.event.WindowEvent
public class Mywindow extends fr a me implements ActionListener{
private MenuBar mb=new MenuBar()
private Menu menu1=new Menu("文件")
private Menu menu2=new Menu("查看")
private MenuItem mi_open=new MenuItem("打开")
private MenuItem mi_save=new MenuItem("保存")
private MenuItem mi_state=new MenuItem("状态")
private TextField t1=new TextField(10)
private TextField t2=new TextField(10)
private TextField t3=new TextField(10)
private Button bt=new Button("求和")
public Mywindow(){
this.setTitle("这是我的第一个窗口程序")
menu1.add(mi_open)
menu1.add(mi_save)
menu2.add(mi_state)
mb.add(menu1)
mb.add(menu2)
this.setMenuBar(mb)
this.setLayout(new FlowLayout())
this.add(t1)
this.add(t2)
this.add(bt)
this.add(t3)
t3.setEditable(false)
bt.addActio
菜单,其内容模仿记事本的菜单
三个文本框,一个按钮.在前两个文本框中输入两个整数, 点击按钮后把两数之和显示到第三个文本框中.-package cn
import java.awt.*
import java.awt.event.ActionEvent
import java.awt.event.ActionListener
import java.awt.event.WindowAdapter
import java.awt.event.WindowEvent
public class Mywindow extends fr a me implements ActionListener{
private MenuBar mb=new MenuBar()
private Menu menu1=new Menu("文件")
private Menu menu2=new Menu("查看")
private MenuItem mi_open=new MenuItem("打开")
private MenuItem mi_save=new MenuItem("保存")
private MenuItem mi_state=new MenuItem("状态")
private TextField t1=new TextField(10)
private TextField t2=new TextField(10)
private TextField t3=new TextField(10)
private Button bt=new Button("求和")
public Mywindow(){
this.setTitle("这是我的第一个窗口程序")
menu1.add(mi_open)
menu1.add(mi_save)
menu2.add(mi_state)
mb.add(menu1)
mb.add(menu2)
this.setMenuBar(mb)
this.setLayout(new FlowLayout())
this.add(t1)
this.add(t2)
this.add(bt)
this.add(t3)
t3.setEditable(false)
bt.addActio
(系统自动生成,下载前可以参看下载内容)
下载文件列表
Demo7\.classpath
.....\.project
.....\.settings\org.eclipse.jdt.core.prefs
.....\bin\cn\test\MyFrame$1.class
.....\...\..\....\MyFrame.class
.....\src\cn\test\MyFrame.java
.....\bin\cn\test
.....\src\cn\test
.....\bin\cn
.....\src\cn
.....\.settings
.....\bin
.....\src
Demo7
.....\.project
.....\.settings\org.eclipse.jdt.core.prefs
.....\bin\cn\test\MyFrame$1.class
.....\...\..\....\MyFrame.class
.....\src\cn\test\MyFrame.java
.....\bin\cn\test
.....\src\cn\test
.....\bin\cn
.....\src\cn
.....\.settings
.....\bin
.....\src
Demo7