实验十三  图形界面事件处理技术

实验时间 2018-11-22

1、实验目的与要求

(1) 掌握事件处理的基本原理,理解其用途;

事件源:能够产生事件的对象都可以成为事件源,如文本框、按钮等,一个事件源是一个能够注册监听器并向监听器发送事件对象的对象。

事件监听器:事件监听器对象接收事件源发送的报告(事件对象),并对发生的事件作出响应。一个监听器对象就是一个实现了专门监听器接口的类实例该类必须实现接口中的方法方法当事件发生时就自动执行。

事件对象:java将时间的相关信息封装在一个事件对象中,所有的事件对象都最终派生于java.util.EventObject类。不同的事件源都可以产生不同类别的事件。

(2) 掌握AWT事件模型的工作机制;

监听器对象:是一个实现了特定监听器接口的类实例。

事件源:是一个能够注册监听器对象并发送事件对象的对象。

当事件发生时,事件源将事件对象自动传递给所有注册的监听器。监听器对象利用事件对象中的信息决定如何事件作出响应。

(3) 掌握事件处理的基本编程模型;

注册监听器方法:

eventSourceObject.addEventListener(eventListenerObject)

监听器接口的方法实现:

Class Mylistener implements ActionListener

{

Public void actionforomered(ActionEvent event)

{……}

}

创建按钮对象

JButton类常用的一组构造方法:

JButton(String text)创建一个带文本的按钮。

JButton(Icon icon):创建一个带图标的按钮。

JButton(String text,Icon icon):创建一个带文本和图标的按钮。

按钮对象的常用方法:

getLable():返回按钮的标签字符串;

setLable(String s):设置按钮的标签为字符串s。

(4) 了解GUI界面组件观感设置方法;

String程序设计默认使用Metal观感,采用两种方式改变观感。

第一种:在java安装的子目录下jre/lib下的文件

swing.properties中,将属性swing.defaultlaf设置为所希望的观感类名。

Swing.defaultlaf =

Com.sun.java.swing.plaf.motifLookAndFeel

第二种:调用静态的UIManager.setLookAndFeel方法,动态的改变观感,提供所想要的观感类名,再调用静态方法SwingUtilities.updateComponentTreUI来刷新全部的组件集。

(5) 掌握WindowAdapter类、AbstractAction类的用法;

扩展WindowAdapter类,继承六个空方法,并且覆盖WindowClosing()方法;

class Terminator extends WindowAdapter

{

public void windowClosing(WindowEvent e)

{

System.exit(0);

}

}

(6) 掌握GUI程序中鼠标事件处理技术。

鼠标事件 MouseEvent

鼠标监听器接口 MouseMotionListener

鼠标监听器适配器 MouseAdapt     ,      MouseMotionAdapter

2、实验内容和步骤

实验1: 导入第11章示例程序,测试程序并进行代码注释。

测试程序1:

l 在elipse IDE中调试运行教材443页-444页程序11-1,结合程序运行结果理解程序;

l 在事件处理相关代码处添加注释;

l 用lambda表达式简化程序;

l 掌握JButton组件的基本API;

l 掌握Java中事件处理的基本编程模型。

ButtonTest

  1. package button;
  2.  
  3. import java.awt.*;
  4. import javax.swing.*;
  5.  
  6. /**
  7. * @version 1.34 2015-06-12
  8. * @author Cay Horstmann
  9. */
  10. public class ButtonTest
  11. {
  12. public static void main(String[] args)
  13. {
  14. EventQueue.invokeLater(() -> {
  15. JFrame frame = new ButtonFrame();
  16. frame.setTitle("ButtonTest");
  17. frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//设置默认的关闭操作
  18. frame.setVisible(true);//对图形用户界面进行可视化处理。
  19. });
  20. }
  21. }

ButtonFrame

  1. package button;
  2.  
  3. import java.awt.*;
  4. import java.awt.event.*;
  5. import javax.swing.*;
  6.  
  7. /**
  8. * A frame with a button panel
  9. */
  10. public class ButtonFrame extends JFrame
  11. {
  12. private JPanel buttonPanel;//
  13. private static final int DEFAULT_WIDTH = 300;//宽为300px
  14. private static final int DEFAULT_HEIGHT = 200;//长为200px
  15. //方法一
  16. //注释掉这个构造器之后只能显示一个窗格,面板上没有内容
  17. /* public ButtonFrame()//构造器
  18. {
  19. setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);//决定框架大小
  20.  
  21. // create buttons 创建按钮
  22. JButton yellowButton = new JButton("Yellow");//Yellow字符串是显示在按钮上的文本
  23. JButton blueButton = new JButton("Blue");
  24. JButton redButton = new JButton("Red");
  25.  
  26. buttonPanel = new JPanel();//使 buttonPanel指向一个具体的容器对象
  27.  
  28. // add buttons to panel
  29. buttonPanel.add(yellowButton);//将按钮添加到面板中
  30. buttonPanel.add(blueButton);
  31. buttonPanel.add(redButton);
  32.  
  33. // add panel to frame
  34. add(buttonPanel);
  35.  
  36. // create button actions
  37. //生成三个监听器类对象 当事件发生时,事件源将事件对象传递给所有注册的监听器
  38. //颜色值在Color类中,通过类名调用
  39. ColorAction yellowAction = new ColorAction(Color.YELLOW);
  40. ColorAction blueAction = new ColorAction(Color.BLUE);
  41. ColorAction redAction = new ColorAction(Color.RED);
  42.  
  43. // associate actions with buttons 将操作与按钮相关联
  44. yellowButton.addActionListener(yellowAction);
  45. //注释掉之后程序可以运行,点击按钮,背景色不变
  46. blueButton.addActionListener(blueAction);
  47. redButton.addActionListener(redAction);
  48. }*/
  49.  
  50. //方法二
  51. /*public ButtonFrame()//构造器
  52. {
  53. buttonPanel = new JPanel();//使 buttonPanel指向一个具体的容器对象
  54. setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);//决定框架大小
  55. add(buttonPanel);
  56. makeButton("Yellow",Color.YELLOW);
  57. makeButton("blue",Color.BLUE);
  58. makeButton("red",Color.RED);
  59. makeButton("green",Color.GREEN);
  60. }
  61. public void makeButton(String name,Color BackgroundColor)
  62. {
  63. JButton button = new JButton(name);
  64. buttonPanel.add(button);
  65. ColorAction action = new ColorAction(BackgroundColor);//初始化一个颜色对象
  66. button.addActionListener(action);//添加一个事件监听器
  67. }*/
  68.  
  69. //方法三
  70. /*public ButtonFrame()//构造器
  71. {
  72. buttonPanel = new JPanel();//使 buttonPanel指向一个具体的容器对象
  73. setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);//决定框架大小
  74. add(buttonPanel);
  75. makeButton("Yellow",Color.YELLOW);
  76. makeButton("blue",Color.BLUE);
  77. makeButton("red",Color.RED);
  78. makeButton("green",Color.GREEN);
  79. }
  80. public void makeButton(String name,Color BackgroundColor)
  81. {
  82. JButton button = new JButton(name);
  83. buttonPanel.add(button);
  84. //使响应用户动作的组件和监听器放在一起
  85. button.addActionListener(new ActionListener()
  86. //new之后有一个缺省的类名,之后直接跟了ActionListener接口 匿名内部类
  87. {
  88. public void actionPerformed(ActionEvent event)
  89. {
  90. buttonPanel.setBackground(BackgroundColor);
  91. }
  92. });
  93. }
  94. *//**
  95. * An action listener that sets the panel's background color.
  96. *//*
  97. */
  98. public ButtonFrame()//构造器
  99. {
  100. buttonPanel = new JPanel();//使 buttonPanel指向一个具体的容器对象
  101. setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);//决定框架大小
  102. add(buttonPanel);
  103. makeButton("Yellow",Color.YELLOW);
  104. makeButton("blue",Color.BLUE);
  105. makeButton("red",Color.RED);
  106. makeButton("green",Color.GREEN);
  107. }
  108. public void makeButton(String name,Color BackgroundColor)
  109. {
  110. JButton button = new JButton(name);
  111. buttonPanel.add(button);
  112. button.addActionListener((background)->
  113. {
  114. buttonPanel.setBackground(BackgroundColor);
  115. });
  116. }
  117. /**
  118. * An action listener that sets the panel's background color.
  119. */
  120.  
  121. //监听器类,类名是ColorAction
  122. /* private class ColorAction implements ActionListener//实现了一个监听器接口
  123. {
  124. private Color backgroundColor;
  125.  
  126. public ColorAction(Color c)
  127. {
  128. backgroundColor = c;
  129. }
  130.  
  131. public void actionPerformed(ActionEvent event)
  132. {
  133. buttonPanel.setBackground(backgroundColor);
  134. }
  135. }*/
  136. }

运行结果:

测试程序2:

l 在elipse IDE中调试运行教材449页程序11-2,结合程序运行结果理解程序;

l 在组件观感设置代码处添加注释;

l 了解GUI程序中观感的设置方法。

PlafTest

  1. package plaf;
  2.  
  3. import java.awt.*;
  4. import javax.swing.*;
  5.  
  6. /**
  7. * @version 1.32 2015-06-12
  8. * @author Cay Horstmann
  9. */
  10. public class PlafTest
  11. {
  12. public static void main(String[] args)
  13. {
  14. EventQueue.invokeLater(() -> {//lambda表达式
  15. JFrame frame = new PlafFrame();//生成plafFrame类对象
  16. frame.setTitle("PlafTest");//设置框架标题
  17. frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//设置默认的关闭操作
  18. frame.setVisible(true);//对图形用户界面进行可视化处理。
  19. });
  20. }
  21. }

PlafFrame

  1. package plaf;
  2.  
  3. import javax.swing.JButton;
  4. import javax.swing.JFrame;
  5. import javax.swing.JPanel;
  6. import javax.swing.SwingUtilities;
  7. import javax.swing.UIManager;
  8.  
  9. /**
  10. * A frame with a button panel for changing look-and-feel
  11. */
  12. //使用辅助方法makeButton指定按钮动作,即切换观感。
  13. public class PlafFrame extends JFrame
  14. {
  15. private JPanel buttonPanel;
  16.  
  17. public PlafFrame()
  18. {
  19. buttonPanel = new JPanel();
  20.  
  21. UIManager.LookAndFeelInfo[] infos = UIManager.getInstalledLookAndFeels();
  22. for (UIManager.LookAndFeelInfo info : infos)
  23. makeButton(info.getName(), info.getClassName());//得到观感的名字和类名
  24.  
  25. add(buttonPanel);
  26. pack();//调整窗口大小,要考虑其组建的首选大小
  27. }
  28.  
  29. /**
  30. * Makes a button to change the pluggable look-and-feel.
  31. * 创建一个按钮来更改可插入的外观
  32. * @param name the button name
  33. * @param className the name of the look-and-feel class
  34. */
  35. private void makeButton(String name, String className)
  36. {
  37. // add button to panel
  38.  
  39. JButton button = new JButton(name);
  40. buttonPanel.add(button);
  41.  
  42. // set button action
  43.  
  44. button.addActionListener(event -> {
  45. // button action: switch to the new look-and-feel 按钮动作:切换到新的观感
  46. //加入异常处理技术
  47. try
  48. {
  49. UIManager.setLookAndFeel(className);
  50. SwingUtilities.updateComponentTreeUI(this);
  51. pack();
  52. }
  53. catch (Exception e)
  54. {
  55. e.printStackTrace();
  56. }
  57. });
  58. }
  59. }

运行结果:

测试程序3:

l 在elipse IDE中调试运行教材457页-458页程序11-3,结合程序运行结果理解程序;

l 掌握AbstractAction类及其动作对象;

l 掌握GUI程序中按钮、键盘动作映射到动作对象的方法。

ButtonFrame

  1. package button;
  2.  
  3. import java.awt.*;
  4. import java.awt.event.*;
  5. import javax.swing.*;
  6.  
  7. /**
  8. * A frame with a button panel
  9. */
  10. public class ButtonFrame extends JFrame
  11. {
  12. private JPanel buttonPanel;
  13. private static final int DEFAULT_WIDTH = 300;
  14. private static final int DEFAULT_HEIGHT = 200;
  15.  
  16. public ButtonFrame()
  17. {
  18. setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);
  19.  
  20. // create buttons 创建按钮
  21. JButton yellowButton = new JButton("Yellow");//括号内是按钮上的文本字符串
  22. JButton blueButton = new JButton("Blue");
  23. JButton redButton = new JButton("Red");
  24.  
  25. buttonPanel = new JPanel();
  26.  
  27. // add buttons to panel 将设置好的按钮添加到面板中
  28. buttonPanel.add(yellowButton);
  29. buttonPanel.add(blueButton);
  30. buttonPanel.add(redButton);
  31.  
  32. // add panel to frame
  33. add(buttonPanel);//在框架中添加新的面板
  34.  
  35. // create button actions 创建按钮动作 改变面板颜色
  36. ColorAction yellowAction = new ColorAction(Color.YELLOW);//颜色值在Color类中,通过类名调用
  37. ColorAction blueAction = new ColorAction(Color.BLUE);
  38. ColorAction redAction = new ColorAction(Color.RED);
  39.  
  40. // associate actions with buttons 将操作与按钮相关联
  41. yellowButton.addActionListener(yellowAction);
  42. blueButton.addActionListener(blueAction);
  43. redButton.addActionListener(redAction);
  44. }
  45.  
  46. /**
  47. * An action listener that sets the panel's background color.
  48. * 设置面板背景色的动作监听器
  49. */
  50. private class ColorAction implements ActionListener//实现了一个监听器接口
  51. {
  52. private Color backgroundColor;
  53.  
  54. public ColorAction(Color c)
  55. {
  56. backgroundColor = c;
  57. }
  58.  
  59. public void actionPerformed(ActionEvent event)
  60. {
  61. buttonPanel.setBackground(backgroundColor);
  62. }
  63. }
  64. }

ButtonTest

  1. package button;
  2.  
  3. import java.awt.*;
  4. import javax.swing.*;
  5.  
  6. /**
  7. * @version 1.34 2015-06-12
  8. * @author Cay Horstmann
  9. */
  10. public class ButtonTest
  11. {
  12. public static void main(String[] args)
  13. {
  14. EventQueue.invokeLater(() -> {
  15. JFrame frame = new ButtonFrame();
  16. frame.setTitle("ButtonTest");
  17. frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  18. frame.setVisible(true);
  19. });
  20. }
  21. }

运行结果:

测试程序4:

l 在elipse IDE中调试运行教材462页程序11-4、11-5,结合程序运行结果理解程序;

l 掌握GUI程序中鼠标事件处理技术。

运行结果:

  1. package mouse;
  2.  
  3. import java.awt.*;
  4. import javax.swing.*;
  5.  
  6. /**
  7. * @version 1.34 2015-06-12
  8. * @author Cay Horstmann
  9. */
  10. public class MouseTest
  11. {
  12. public static void main(String[] args)
  13. {
  14. EventQueue.invokeLater(() -> {
  15. JFrame frame = new MouseFrame();//生成一个MouseFrame类对象
  16. frame.setTitle("MouseTest");
  17. frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  18. frame.setVisible(true);
  19. });
  20. }
  21. }
  1. package mouse;
  2.  
  3. import java.awt.*;
  4. import java.awt.event.*;
  5. import java.awt.geom.*;
  6. import java.util.*;
  7. import javax.swing.*;
  8.  
  9. /**
  10. * A component with mouse operations for adding and removing squares.
  11. * 用于添加和删除方块的具有鼠标操作的组件
  12. */
  13. public class MouseComponent extends JComponent
  14. {
  15. //设置框架大小
    private static final int DEFAULT_WIDTH = 300;
  16. private static final int DEFAULT_HEIGHT = 200;
  17.  
  18. private static final int SIDELENGTH = 10;//设置小方块边长为10px
  19. private ArrayList<Rectangle2D> squares;
  20. private Rectangle2D current;
  21. // the square containing the mouse cursor 包含鼠标指针的方块
  22.  
  23. public MouseComponent()
  24. {
  25. squares = new ArrayList<>();
  26. current = null;
  27.  
  28. addMouseListener(new MouseHandler());
  29. addMouseMotionListener(new MouseMotionHandler());
  30. }
  31.  
  32. public Dimension getPreferredSize() { return new Dimension(DEFAULT_WIDTH, DEFAULT_HEIGHT); }
  33.  
  34. public void paintComponent(Graphics g)
  35. {
  36. Graphics2D g2 = (Graphics2D) g;
  37.  
  38. // draw all squares
  39. for (Rectangle2D r : squares)
  40. g2.draw(r);
  41. }
  42.  
  43. /**
  44. * Finds the first square containing a point.
  45. * @param p a point
  46. * @return the first square that contains p
  47. */
  48. public Rectangle2D find(Point2D p)
  49. {
  50. for (Rectangle2D r : squares)
  51. {
  52. if (r.contains(p)) return r;
  53. }
  54. return null;
  55. }
  56.  
  57. /**
  58. * Adds a square to the collection.
  59. * @param p the center of the square
  60. */
  61. public void add(Point2D p)
  62. {
  63. double x = p.getX();
  64. double y = p.getY();
  65.  
  66. current = new Rectangle2D.Double(x - SIDELENGTH / 2, y - SIDELENGTH / 2, SIDELENGTH,
  67. SIDELENGTH);
  68. squares.add(current);
  69. repaint();
  70. }
  71.  
  72. /**
  73. * Removes a square from the collection.
  74. * @param s the square to remove
  75. */
  76. public void remove(Rectangle2D s)
  77. {
  78. if (s == null) return;
  79. if (s == current) current = null;
  80. squares.remove(s);
  81. repaint();
  82. }
  83.  
  84. private class MouseHandler extends MouseAdapter
  85. {
  86. public void mousePressed(MouseEvent event)
  87. {
  88. // add a new square if the cursor isn't inside a square
  89. current = find(event.getPoint());
  90. if (current == null) add(event.getPoint());
  91. }
  92.  
  93. public void mouseClicked(MouseEvent event)
  94. {
  95. // remove the current square if double clicked 如果双击,则删除当前方块
  96. current = find(event.getPoint());
  97. if (current != null && event.getClickCount() >= 2) remove(current);
  98. }
  99. }
  100.  
  101. private class MouseMotionHandler implements MouseMotionListener
  102. {
  103. public void mouseMoved(MouseEvent event)
  104. {
  105. // set the mouse cursor to cross hairs if it is inside
  106. // a rectangle
  107.  
  108. if (find(event.getPoint()) == null) setCursor(Cursor.getDefaultCursor());
  109. else setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
  110. }
  111.  
  112. public void mouseDragged(MouseEvent event)
  113. {
  114. if (current != null)
  115. {
  116. int x = event.getX();
  117. int y = event.getY();
  118.  
  119. // drag the current rectangle to center it at (x, y)
  120. current.setFrame(x - SIDELENGTH / 2, y - SIDELENGTH / 2, SIDELENGTH, SIDELENGTH);
  121. repaint();
  122. }
  123. }
  124. }
  125. }
  1. package mouse;
  2.  
  3. import javax.swing.*;
  4.  
  5. /**
  6. * A frame containing a panel for testing mouse operations
  7. */
  8. public class MouseFrame extends JFrame
  9. {
  10. public MouseFrame()
  11. {
  12. add(new MouseComponent());
  13. pack();
  1. } }

实验2:结对编程练习

利用班级名单文件、文本框和按钮组件,设计一个有如下界面(图1)的点名器,要求用户点击开始按钮后在文本输入框随机显示2017级网络与信息安全班同学姓名,如图2所示,点击停止按钮后,文本输入框不再变换同学姓名,此同学则是被点到的同学姓名。

结对人:白玛次仁

  1. package dianming;
  2. import java.util.*;
  3. import java.awt.*;
  4. import javax.swing.*;
  5. import java.awt.event.*;
  6. import java.awt.Frame;
  7. import java.io.File;
  8. import java.io.FileNotFoundException;
  9.  
  10. public class dianmingqi extends JFrame implements ActionListener{
  11. private static final long serialVersionUID = 1L;
  12. //serialVersionUID适用于Java的序列化机制,简单来说,Java的序列化机制是通过判断类的
  13.  
  14. private JButton but ;
  15. private JButton show;
  16. private static boolean flag = true;
  17. public static void main(String arguments []) {
  18. new dianmingqi();
  19.  
  20. }
  21.  
  22. public dianmingqi(){
  23.  
  24. but = new JButton("开始");//创建一个“开始”按钮
  25. but.setBounds(100,150,100,40);
  26. show = new JButton("随机点名");//创建一个“随机点名”按钮
  27. show.setBounds(80,80,180,30);
  28. add(but);//将按钮添加到面板中
  29. add(show);
  30.  
  31. setLayout(null);
  32. setVisible(true);//面板的可视化处理
  33. setResizable(false);
  34. setBounds(100,100,300,300);
  35. this.getContentPane().setBackground(Color.white);//面板背景色为白色
  36. setTitle("点名");//设置框架标题
  37. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//关闭该面板
  38. but.addActionListener(this);
  39. }
  40.  
  41. public void actionPerformed(ActionEvent e){
  42. int i=0;
  43. String names[]=new String[50];//创建一个数组,大小为50
  44. try {
  45. Scanner in=new Scanner(new File("D:\\studentnamelist.txt"));//将文件写入程序
  46. while(in.hasNextLine())
  47. {
  48. names[i]=in.nextLine();//读取文件,遍历全班姓名
  49. i++;
  50. }
  51. } catch (FileNotFoundException e1) {
  52.  
  53. e1.printStackTrace();//异常处理
  54. }
  55.  
  56. //点击开始后的操作
  57. if(but.getText()=="开始"){
  58.  
  59. show.setBackground(Color.gray);
  60. flag=true;
  61. new Thread(){
  62. public void run(){
  63. while(dianmingqi.flag){
  64. Random r = new Random(); //随机点名
  65. int i= r.nextInt(43);
  66. show.setText(names[i]);
  67. }
  68. }
  69. }.start();
  70. but.setText("停止");
  71. but.setBackground(Color.darkGray);
  72. }
  73. else if(but.getText()=="停止"){
  74. flag = false;
  75. but.setText("开始");
  76. but.setBackground(Color.WHITE);
  77. show.setBackground(Color.magenta);
  78. }
  79. }
  80.  
  81. }

运行结果:

总结:本周主要学习了事件处理,也同时综合了上一章的内容。前三个程序看起来比较容易理解,最后一个关于鼠标的有一点看不懂,自己动手编程的话就感觉很难,失败了好多次。主要是平时不加以练习的原因。还需要继续学习。

Java第十三周实验作业的更多相关文章

  1. java第十三周课后作业 0529

    1.把多个企鹅的信息添加到集合中查看企鹅的数量及所有企鹅的信息删除集合中部分企鹅的元素判断集合中是否包含指定企鹅 package homework; import java.util.ArrayLis ...

  2. c++ 西安交通大学 mooc 第十三周基础练习&第十三周编程作业

    做题记录 风影影,景色明明,淡淡云雾中,小鸟轻灵. c++的文件操作已经好玩起来了,不过掌握好控制结构显得更为重要了. 我这也不做啥题目分析了,直接就题干-代码. 总结--留着自己看 1. 流是指从一 ...

  3. 20187101021-王方《面面相对象程序设计java》第十三周实验总结

    项目 内容 这个作业属于哪个课程 https://www.cnblogs.com/nwnu-daizh/ 这个作业的要求在哪里 https://www.cnblogs.com/nwnu-daizh/p ...

  4. 201771010123汪慧和《面向对象程序设计Java》第十三周实验总结

     一.理论部分 1.GUI为用户提供交互式的图形化操作界面. (1)提供了程序的外观和感觉.(2)程序利用图形用户界面接受用户的输入,向用户输出程序运行的结果. 2.Java有专门的类库生成各种标准图 ...

  5. 201521123093 java 第十三周学习总结

    1. 本周学习总结 以你喜欢的方式(思维导图.OneNote或其他)归纳总结多网络相关内容. 2. 书面作业 1. 网络基础 1.1 比较ping www.baidu.com与ping cec.jmu ...

  6. Java第十三周学习总结

    1. 本周学习总结 以你喜欢的方式(思维导图.OneNote或其他)归纳总结多网络相关内容. 2. 书面作业 1. 网络基础 1.1 比较ping www.baidu.com与ping cec.jmu ...

  7. JAVA第三周课后作业

    JAVA课后作业 一.枚举类型 代码: enum Size{SMALL,MEDIUM,LARGE}; public cl ass EnumTest { public static void main( ...

  8. Java第十三周总结

    1. 本周学习总结 以你喜欢的方式(思维导图.OneNote或其他)归纳总结多网络相关内容. 2. 书面作业 1. 网络基础 1.1 比较ping www.baidu.com与ping cec.jmu ...

  9. Java第六周实验+总结

    一.实验目的 (1)掌握类的继承 1.子类继承父类中非private的成员变量和成员方法,同时,注意构造方法不能被子类继承. 2.定义类时若缺省extends关键字,则所定义的类为java.lang. ...

随机推荐

  1. 同时安装Python2,Python3如何解决冲突问题【官方解法】

    使用py -2或py -3命令来区分调用Python启动器 去掉参数 -2/-3如何运行? 每次运行都要加入参数-2/-3还是比较麻烦,所以py.exe这个启动器允许你在代码中加入说明,表明这个文件应 ...

  2. ES:PB级别的大索引如何设计

    一.单个大索引的缺陷 如果每天亿万+的实时增量数据呢,基于以下几点原因,单个索引是无法满足要求的: 1.存储大小限制维度 单个分片(Shard)实际是 Lucene 的索引,单分片能存储的最大文档数是 ...

  3. Ubuntu 16.04 PXE+kickstart部署系统

    #PXE+TFTP+Kickstart 自动部署服务器系统系统Ubuntu16.04apt-get install isc-dhcp-servervim /etc/default/isc-dhcp-s ...

  4. 内核ioctl函数的cmd宏参数

    在驱动程序里, ioctl() 函数上传送的变量 cmd 是应用程序用于区别设备驱动程序请求处理内容的值.cmd除了可区别数字外,还包含有助于处理的几种相应信息. cmd的大小为 32位,共分 4 个 ...

  5. Lambda表达式和函数试接口的最佳实践 · LiangYongrui's Studio

    1.概述 本文主要深入研究java 8中的函数式接口和Lambda表达式,并介绍最佳实践. 2.使用标准的函数式接口 包java.util.function中的函数是接口已经可以满足大部分的java开 ...

  6. VM安装Linux Centos7.0虚拟机

    一.准备工作 1.安装VMware 官网https://www.vmware.com/cn.html 2.准备centos7的镜像文件 官网下载链接:http://isoredirect.centos ...

  7. NIO-EPollSelectorIpml源码分析

    目录 NIO-EPollSelectorIpml源码分析 目录 前言 初始化EPollSelectorProvider 创建EPollSelectorImpl EPollSelectorImpl结构 ...

  8. 记一次手机与PC同步开发Android项目

    目录 -1 前言 0.0 流程简介 1.0 AS创建项目并上传GitHub 2.0 AIDE克隆GitHub项目 能力不足时曲线救国 > 3.0 termux编译AIDE目录下的项目文件 3.1 ...

  9. 国产数据库适配publiccms开源项目

    金仓数据库适配 操作说明: 一.在程序的所有实体层添加schema=”public”(这里的public是根据数据库定义的模式) 二.切换数据库,修改配置文件cms.properties里面的cms. ...

  10. CORS(cross-origin-resource-sharing)跨源资源共享

    其实就是跨域请求.我们知道XHR只能访问同一个域中的资源,这是浏览器的安全策略所限制,但是开发中合理的跨域请求是必须的.CORS是W3的一个工作草案,基本思想就是:使用自定义的HTTP头部让浏览器与服 ...