下载此文档

java swing图形用户界面.doc


文档分类:IT计算机 | 页数:约10页 举报非法文档有奖
1/10
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/10 下载此文档
文档列表 文档介绍
java swing图形用户界面
实例1:(文本区,菜单)
import .*;
import .*;
import .*;
public class MyFrame1 extends JFrame{
JTextArea area;
JMenuBar bar;
JMenu menu;
JMenuItem itemCopy,itemCut,itemPaste;
menuListen listen =new menuListen();
MyFrame1(){
init();
setBounds(100,100,400,400);
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
public void init(){
setLayout(new FlowLayout());
area=new JTextArea(5,20);
add(area);
bar=new JMenuBar();
setJMenuBar(bar);
menu=new JMenu("编辑");
(menu);
itemCopy=new JMenuItem("复制");
itemCut=new JMenuItem("剪切");
itemPaste=new JMenuItem("粘贴");
(itemCopy);
(itemCut);
(itemPaste);
(listen);
(listen);
(listen);
(itemCopy, itemCut, itemPaste, area);
}
public static void main(String[] args) {
MyFrame1 win=new MyFrame1();
}
}
class menuListen implements ActionListener{
JMenuItem itemCopy,itemCut,itemPaste;
JTextArea area;
public void setItem(JMenuItem itemCopy,JMenuItem itemCut,JMenuItem itemPaste,JTextArea area){
=itemCopy;
=itemCut;
=itemPaste;
=area;
}
public void actionPerformed(ActionEvent e){
if(()==itemCopy){
();
}else if(()==item

java swing图形用户界面 来自淘豆网www.taodocs.com转载请标明出处.

非法内容举报中心
文档信息
  • 页数10
  • 收藏数0 收藏
  • 顶次数0
  • 上传人xunlai783
  • 文件大小73 KB
  • 时间2018-01-07