2020-05-27

/*

  • To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. /package javaapplication81;import java.awt.;/** * * @author Angle~子敬 /public class JavaApplication81 { static Frame f; static TextArea ta; static Label lab; static MenuBar mb; static Menu m1,m2,m3,m4,m5; static MenuItem mi1,mi2,mi3,mi4,mi5,mi6,mi7; /* * @param args the command line arguments */ public static void main(String[] args) { f=new Frame(“无标题-记事本”); ta=new TextArea(); mb=new MenuBar(); f.setMenuBar(mb); m1=new Menu(“文件(F)”); m2=new Menu(“编辑(E)”); m3=new Menu(“格式©”); m4=new Menu(“查看(V)”); m5=new Menu(“帮助(H)”); mi1=new MenuItem(“新建(N) Ctrl+N”); mi2=new MenuItem(“打开(O)… Ctrl+O”); mi3=new MenuItem(“保存(S) Ctrl+S”); mi4=new MenuItem(“另存为(A)…”); mi5=new MenuItem(“页面设置(U)…”); mi6=new MenuItem(“打印§… Ctrl+P”); mi7=new MenuItem(“退出(X)”); mb.add(m1); mb.add(m2); mb.add(m3); mb.add(m4); mb.add(m5); m1.add(mi1); m1.add(mi2); m1.add(mi3); m1.add(mi4); m1.addSeparator(); m1.add(mi5); m1.add(mi6); m1.addSeparator(); m1.add(mi7); f.add(ta); f.setSize(800,600); f.setVisible(true); // TODO code application logic here } }

/*

  • To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. /package javaapplication82;import java.awt.;import java.awt.event.*;/** * * @author Angle~子敬 /public class JavaApplication82 { static Frame f; static Button b; static TextField tf; static List li; static boolean isPrime(int n){ for(int i=2;i<=n-1;i++) if(n%i==0) return false; return true; } static class BH implements ActionListener{ @Override public void actionPerformed(ActionEvent e) { int m; m=Integer.valueOf(tf.getText()); for(int n=2;n<=m;n++) if(isPrime(n)) li.add(String.valueOf(n)); //throw new UnsupportedOperationException(“Not supported yet.”); //To change body of generated methods, choose Tools | Templates. } }static class WH extends WindowAdapter{ @Override public void windowClosing(WindowEvent e) { System.exit(0); //super.windowClosing(e); //To change body of generated methods, choose Tools | Templates. } } /* * @param args the command line arguments */ public static void main(String[] args) { f=new Frame(); b=new Button(); tf=new TextField(“100”); li=new List(); f.add(tf,“North”); f.add(b,“East”); f.add(li,“Center”); f.setSize(640,480); f.setVisible(true); b.addActionListener(new BH()); f.addWindowListener(new WH()); // TODO code application logic here } }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值