已阅读5页,还剩10页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1 1 1 1 2 1 3 1 100 2 10 a 10 3 4 5 a 6 n Fact 4 7 Applet pica jpg 8 xn 103 9 Applet 10 1 public class Sum public static void main String args double sum 0 0 for int i 1 i 100 i sum 1 0 double i System out println sum sum 2 import java io public class Reverse public static void main String args int i n 10 int a new int 10 for i 0 i 0 i System out print a i System out println 3 import java awt public class abc public static void main String args new FrameOut class FrameOut extends Frame Frame Button btn FrameOut super btn new Button setLayout new FlowLayout add btn setSize 300 200 show 4 import java io public class Class1 public static void main String args int i Max Min int a 12 67 8 98 23 56 124 55 99 100 Max Min a 0 for i 1 i a length i if a i Max Max a i System out println Max Min System out println 5 public class ABC public static void main String args int i j int a 12 67 8 98 23 56 124 55 99 100 for i 0 i a length 1 i int k i for j i j a length j if a j b a b 1 Java Application 1 2 Java Application 10 10 3 Java Applet Complex 1 2i 3 4i 4 6i Complex 1 Complex RealPart int ImaginPart int 2 Complex Complex 0 Complex int r int i r i Complex complexAdd Complex a String ToString a bi a b 4 Student 1 Student id long name String age int sex boolen true false phone String 2 Student Student long i String n int a boolean s long p int getAge boolean getSex long getPhone public String toString 5 Java Applet 6 Java Applet 10 7 Java Applet 8 Applet Applet 9 10 1 import java io public class SUM public static void main String args int i n 1 sum 0 while n 1 try BufferedReader br new BufferedReader new InputStreamReader System in n Integer parseInt br readLine catch IOException e for i 1 i n i sum i System out println sum 2 import java io public class abc public static void main String args int i n 10 max 0 min 0 temp 0 try BufferedReader br new BufferedReader new InputStreamReader System in max min Integer parseInt br readLine catch IOException e for i 2 i max max temp if temp min min temp catch IOException e System out println max max nmin min 3 import java applet import java awt public class abc extends Applet Complex a b c public void init a new Complex 1 2 b new Complex 3 4 c new Complex public void paint Graphics g c plexAdd b g drawString a toString 10 50 g drawString b toString 10 70 g drawString c toString 10 90 class Complex int RealPart int ImaginPart Complex RealPart 0 ImaginPart 0 Complex int r int i RealPart r ImaginPart i Complex complexAdd Complex a Complex temp new Complex temp RealPart RealPart a RealPart temp ImaginPart ImaginPart a ImaginPart return temp public String toString return RealPart ImaginPart i 4 class Student long id String name int age boolean sex long phone Student long i String n int a boolean s long p id i name n age a sex s phone p int getAge return age boolean getSex return sex long getPhone return phone public String toString return name phone 5 import java applet import java awt import java awt event public class FindMin extends Label result TextField in1 in2 in3 Button btn1 btn2 int a 0 b 0 c 0 min Applet implements ActionListener public void init result new Label in1 new TextField 5 in2 new TextField 5 in3 new TextField 5 btn1 new Button btn2 new Button add in1 add in2 add in3 add btn1 add btn2 add result btn1 addActionListener this btn2 addActionListener this public void actionPerformed ActionEvent if e getSource btn1 a Integer parseInt in1 getText b Integer parseInt in2 getText c Integer parseInt in3 getText e min a if b min min b if c min min c result setText min else System exit 0 6 import java applet import java awt import java awt event public class Sushu extends Applet Label lb1 lb2 result TextField in1 in2 TextArea out1 Button btn1 btn2 int a 0 b 0 String s implements ActionListener public void init result new Label lb1 new Label lb2 new Label in1 new TextField 5 in2 new TextField 5 out1 new TextArea out1 setEditable false btn1 new Button btn2 new Button add lb1 add in1 add lb2 add in2 add btn1 add btn2 add result add out1 btn1 addActionListener this btn2 addActionListener this public void actionPerformed ActionEvent e int k 0 if e getSource btn1 out1 setText n a Integer parseInt in1 getText b Integer parseInt in2 getText s Loop for int i b i a i for int j 2 j i j if i j 0 continue Loop k if k 10 0 10 s s i n else s s i result setText b a k out1 setText s else System exit 0 7 import java applet import java awt import java awt event public class MouseListenerTest extends Applet int xPos 1 yPos 1 Color color int radius int mouseFlag public void paint Graphics g if mouseFlag 1 radius int 50 Math random color new Color int 255 Math random int 255 Math random int 255 Math random g setColor color g drawString radius is radius 20 20 g drawOval xPos yPos radius radius else if mouseFlag 2 g clearRect 0 0 getWidth getHeight public void init addMouseListener new MouseAdapter public void mouseClicked MouseEvent e if e getClickCount 1 mouseFlag 1 else if e getClickCount 2 mouseFlag 2 xPos e getX yPos e getY repaint 8 import java applet import java awt import java awt event public class MouseDrawRect extends Applet implements MouseMotionListener int xstart 1 ystart 1 int xend yend TextField showPosition public void init showPosition new TextField 20 add showPosition addMouseMotionListener this addMouseListener new MouseAdapter public void mousePressed MouseEvent event public void paint Graphics g if xstart 1 showPosition setText the x is xend the y is yend public void mouseDragged MouseEvent e xend e getX yend e getY repaint public void mouseMoved MouseEvent e xstart event getX ystart event getY 9 import javax swing import java awt class SpeakPhone extends JFrame JTextArea speak JButton numbers new JButton 12 String numberString 0 1 2 3 4 5 6 7 8 9 JButton enter cancel Font f1 new Font Arial Font BOLD 20 SpeakPhone setSize 200 400 Container con getContentPane speak new JTextArea 4 6 JPanel p1 new JPanel p1 setLayout new GridLayout 2 1 Label lab new Label Connet Number lab setFont f1 p1 add lab p1 add speak JPanel p2 new JPanel p2 setLayout new GridLayout 3 4 for int i 0 i 12 i numbers i new JButton numberString i numbers i setFont f1 p2 add numbers i JPanel p3 new JPanel p3 setLayout new GridLayout 1 2 enter new JButton cancel new JButton p3 add enter p3 add cancel con add p1 BorderLayout NORTH con add p2 BorderLayout CENTER con add p3 BorderLayout SOUTH setVisible true public static void main String args SpeakPhone mainFrm new SpeakPhone 10 import java awt class MyPanel1 extends Panel Checkbox box1 box2 box3 CheckboxGroup sex MyPanel1 sex new CheckboxGroup box1 new Checkbox true sex box2 new Checkbox false sex setLayout new GridLayout 3 1 add new Label add box1 add box2 class MyPanel2 extends Panel List list MyPanel2 list new List 4 false list add list add list add setLayout new GridLayout 4 1 add new Label add list class MyPanel3 extends Panel Checkbox box1 box2 box3 MyPanel3 box1 new Checkbox box2 new Checkbox box3 new Checkbox setLayout new GridLayout 4 1 add new Label add box1 add box2 add box3 class ChoiceLike extends Frame public static void main String args MyPanel1 panel1 new MyPanel1 MyPanel2 panel2 new MyPanel2 MyPanel3 panel3 new MyPanel3 ChoiceLike mainFrame new ChoiceLike mainFrame add panel1 BorderLayout WEST mainFrame add panel2 BorderLayout CENTER mainFrame add panel3 BorderLayout EAST mainFrame setVisible true 1 import java awt import java awt event public class RGBColor extends WindowAdapter implements TextListener Frame f TextField tf1 tf2 tf3 Panel p2 public RGBColor Frame f new Frame f setSize 500 200 Panel p1 new Panel p2 new Panel f add p1 North f add p2 p1 add new Label Red tf1 new TextField 255 10 p1 add tf1 p1 add new Label Green tf2 new TextField 0 10 p1 add tf2 p1 add new Label Blue tf3 new TextField 0 10 p1 add tf3 tf1 addTextListener this tf2 addTextListener this tf3 addTextListener this p2 setBackground new Color 255 0 0 f setVisible true f addWindowListener this f addWindowListener this public void textValueChanged TextEvent e int r new Integer tf1 getText intValue int g new Integer tf2 getText intValue int b new Integer tf3 getText intValue p2 setBackground new Color r g b public void windowClosing WindowEvent e System exit 0 public static void main String k new RGBColor 123456 2 123456 pass error you pass your password error import java awt import java awt event import javax swing import javax swing event public class Login1 public static void main String args LoginFrame frame new LoginFrame frame setDefaultCloseOperation JFrame EXIT ON CLOSE frame show class LoginFrame extends JFrame public LoginFrame setTitle Login setSize WIDTH HEIGHT Container contentPane getContentPane JPanel textPanel new JPanel JLabel inputPassword new JLabel Input password JLabel CENTER myPassword new JPasswordField 20 textPanel add inputPassword textPanel add myPassword JLabel checkedPassword new JLabel Checked password JLabel LEFT checkPassword new JTextField 20 checkPassword setEditable false textPanel add checkedPassword textPanel add checkPassword loginButton new JButton new ImageIcon hlpcd gif loginButton addActionListener new LoginAction textPanel add loginButton contentPane add textPanel private class LoginAction implements ActionListener public void actionPerformed ActionEvent event char s myPassword getPassword String gets new String s if gets equals CHECKPASSWORD checkPassword setText PASS else checkPassword setText WRONG PASSWORD public static final int WIDTH 280 public static final int HEIGHT 180 public static final String CHECKPASSWORD password private JPasswordField myPassword private JTextField checkPassword private JButton loginButton 1 2 3 20 20 3 application 1 2 3 20 public class jiechenghe public static void main String s long i 1 long k 0 for int n 1 ntruePrice return else if guessPrice truePrice return return class MyImgPanel extends Panel String fileName IXUS50 jpg Image myImage public void initImg URL url null try url Class forName Lucky52 getResource IXUS50 jpg catch Exception e myImage getToolkit getImage url MediaTracker myTracker new MediaTracker this myTracker addImage myImage 1 try myTracker wait myTracker checkAll catch Exception e public void paint Graphics g g drawImage myImage 135 30 55 75 this class MsgDlg extends Frame implements ActionListener Label label new Label public MsgDlg String strMsg super setTitle Panel myPanel new Panel add myPanel myPanel add label label setText strMsg setSize 150 100 setLocation 300 200 Button btnOk new Button btnOk addActionListener this myPanel add btnOk show public void actionPerformed ActionEvent evt this dispose 52 1 2 13 13 2 2 14 14 test txt 15 1 15 Java 1 2 2 16 APE YUAN 16 APE APE YUAN JUXING JUXING draw draw draw draw 17 18 18 application 1 1 3 1 5 1 7 1 9 40 19 19 import java awt event import javax swing public class TFMath public static void main String args new TFFrame class TFFrame extends JFrame JTextField num1 num2 num3 public public TFFrame num1 new JTextField 10 num2 new JTextField 10 num3 new JTextField 15 JLabel lblPlus new JLabel JButton btnEqual new JButton btnEqual addActionListener new MyMonitor setLayout new FlowLayout add num1 add lblPlus add num2 add btnEqual add num3 pack setVisible true private class MyMonitor implements ActionListener public void actionPerformed ActionEvent e Integer parseInt num1 getText int n1 Integer parseInt num1 getText int n2 Integer parseInt num2 getText num3 setText n1 n2 20 F 20 F test txt 21 MyThread 21 MyThread 1 30 TestThread Thread Thread TestThread Thread 01 Thread 02 02 1 30 synchronized 22 22 import import java io public class TCPServerD main String public static void main String args ServerSocket ss null Socket s null try ServerSocket 5858 5858 ss new ServerSocket 5858 while true System out println System out println s ss accept BufferedReader br new BufferedReader new InputStreamReader s getInputStream String str br readLine System out println s getInetAddress str str str toUpperCase PrintWriter pw new PrintWriter s getOutputStream pw println str pw flush catch IOException e e printStackTrace finally if ss null try ss close catch IOException e Auto TODO Auto generated catch block e printStackTrace if s null try s close catch IOException e Auto generated TODO Auto generated catch block e printStackTrace 23 23 ListExample java import java awt import java awt event import javax swing import javax swing event public class ListExample public static void main String args ListFrame frame new ListFrame frame setDefaultCloseOperation JFrame EXIT ON CLOSE frame show class ListFrame extends JFrame public ListFrame setTitle ListExample setSize WIDTH HEIGHT Container contentPane getContentPane JPanel textPanel new JPanel myTextArea new JTextArea checkedLabel 5 20 JScrollPane textScrollPane new JScrollPane myTextArea textPanel add textScrollPane contentPane add textPanel listPanel new JPanel String courses Math English Physics Chemic Biology Politics courseList new JList courses courseList setVisibleRowCount 4 courseList addListSelectionListener new courseList
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2020-2025年试验检测师之道路工程能力测试试卷B卷附答案
- 2020-2025年安全员之A证(企业负责人)能力测试试卷A卷附答案
- 胆囊息肉的护理
- 雨课堂学堂在线学堂云《财务管理(宁夏大学 )》单元测试考核答案
- 高考化学“3+2”模拟练试卷含答案(四)
- 青岛市平度市古岘镇社区工作者考试题目附答案解析
- 2026年注册土木工程师(水利水电)之专业基础知识考试题库200道及答案【典优】
- 2026年注册岩土工程师考试题库200道(各地真题)
- 2026年县直事业单位招聘公共基础知识真题200道带答案(轻巧夺冠)
- 2026年内蒙古阿拉善高新技术产业开发区教育领域紧缺人才引进10人历年真题汇编及答案解析(夺冠)
- GA 6-2004消防员灭火防护靴
- 不孕症及辅助生殖技术
- 2023年武汉市江夏文化旅游发展集团有限公司招聘笔试题库及答案解析
- 四川省某堤防工程单位工程监理工作报告
- 基础教育改革专题课件
- 课程与教学的基本原理讲解
- 社区园区无人配送智能网联基础设施白皮书
- 年级藏文期中试卷分析篇
- 汽机水冲击事故预案
- 简易劳动合同
- 学校校庆等大型活动安全应急预案
评论
0/150
提交评论