• 第十二周


    其他容器。

    JPanle

    Panel 面板JPanel 是一种中间层容器,它能容纳组件并将组件组合在一起,但它本身必须添加到其他容器中使用。
    JPanel 类的构造方法如下。JPanel():使用默认的布局管理器创建新面板,默认的布局管理器为 FlowLayout。
    JPanel(LayoutManagerLayout layout):创建指定布局管理器的 JPanel 对象。

    JSplitpane.

    JSplitPane 用于分隔两个(只能两个)Component。两个 Component 图形化分隔以外观实现为基础,并且这两个 Component 可以由用户交互式调整大小。

    构造函数
    public JSplitPanel():创建一个配置为将其子组件水平排列、无连续布局、为组件使用两个按钮的新 JSplitPane
    public JSplitPanel(int newOrientation):创建一个指定方向的分割板,这里的newOrientation可以设置两个值, VERTICAL_SPLIT(设置分割板为上下布局),HORIZONTAL_SPLIT(设置分隔板左右布局)
    public JSplitPane(int newOrientation,Component newLeftComponent,Component newRightComponent):创建一个具有指定方向和不连续重绘的指定组件的新 JSplitPane。
    public JSplitPane(int newOrientation,boolean newContinuousLayout,Component newLeftComponent,Component newRightComponent):创建一个具有指定方向、重绘方式和指定组件的新 JSplitPane。
    常用方法
    setContinuousLayout(boolean newContinuousLayout):设置是否连续重新显示组件,如果为false就会发现在调整面板的过程中会显示一道黑线,只有当停下的时候才能正常的显示,默认是false
    setDividerSize(int newSize):设置分割条的大小 
    setDividerLocation(double size):设置分隔条的位置,这里的size是小数,个人觉得官方文档好像这里有点对劲,相当于占整个面板的百分比
    setLeftComponent(Componentcomp)/setTopComponent(Component comp): 将组件设置到分隔条的上面或者左边。
    setRightComponent(Component comp)/setBottomComponent(Component comp):将组件设置到分隔条的下面或者右边。
    setOneTouchExpandable(boolean newValue):设置 oneTouchExpandable 属性的值,要使 JSplitPane 在分隔条上提供一个 UI 小部件来快速展开/折叠分隔条,此属性必须为 true。

    2.鼠标事件
    a:监听器class MyMouseListener implements MouseListener
    提示:他提示给出所有方法;
    一般用于Button类的对象;
    button.addMouseListener(new MouseListener);
    也可以使用类部类;
    button.addMouseListener(new MouseListener(){重写});
    3.键盘事件
    a:监听器 类KeyListener int KeyCode=e.getKeyCode();
    文本框类TextField
    4.动作事件:
    a:监听器 :ActionListener
    public void actionPerformed(ActionEvent e) {
    String str = e.getActionCommand();//获取按钮的名字
    }
    button类对象.addActionListener(动作事件监听ActionListener器对象);[b][/b]

    JFrame类的常用方法 类型 描述

        JFrame()                                     构造方法                                     创建一个普通的窗体对象
    
      JFrame(String a)                           构造方法                                     创建一个窗体对象,并指定标题
    
     setSize(int width,int height)            普通方法                                      设置窗体大小
    
     setBackgorund(color.red)              普通方法                                      设置窗体背景颜色
    
     setLocation(int x,int y)                   普通方法                                       设置组件的显示位置
    
     setLocation(point p)                      普通方法                                       通过point来设置组件的显示位置
    
     setVisible(true/false)                     普通方法                                       显示或隐藏组件
    
    add(Component comp)                  普通方法                                       向容器中增加组件
    
    setLay·out(LayoutManager mgr)   普通方法                                        设置局部管理器,如果设置为null表示不使用
    
     pack()                                            普通方法                                       调整窗口大小,以适合其子组件的首选大小和局部
    
     getContentpane()                          普通方法                                       返回此窗口的容器对象
     
  • 相关阅读:
    R语言代写模型中的加总偏误与内生性:一种数值模拟方法
    R语言代写NYPD纽约市警察局抢劫者数据分析
    R语言代写使用马尔可夫链Markov Chain, MC来模拟抵押违约
    BZOJ 2600: [Ioi2011]ricehub 双指针+贪心
    BZOJ 4903: [Ctsc2017]吉夫特 数论+dp
    BZOJ 4500: 矩阵 带权并查集
    草稿
    BZOJ 5082: 弗拉格 矩阵乘法
    BZOJ 4764: 弹飞大爷 LCT
    BZOJ 3309: DZY Loves Math 莫比乌斯反演+打表
  • 原文地址:https://www.cnblogs.com/wangzihaojun/p/11869146.html
Copyright © 2020-2023  润新知