Java - Swing用户界面设计(4)

 

2.3 各种容器面板和组件 

2.3.1. 根面板(JRootPane) 

根面板由一个玻璃面板(glassPane)、一个内容面板(contentPane)和一个可选择的菜单条(JMenuBar)组成,而内容面板和可选择的菜单条放在同一分层。玻璃面板是完全透明的,缺省值为不可见,为接收鼠标事件和在所有组件上绘图提供方便。    根面板提供的方法:

 

  1.  Container getContentPane(); //获得内容面板   
  2.  setContentPane(Container); //设置内容面   
  3.  JMenuBar getMenuBar( ); //活动菜单条  
  4.  setMenuBar(JMenuBar); //设置菜单条  
  5.  JLayeredPane getLayeredPane(); //获得分层面板  
  6.  setLayeredPane(JLayeredPane); //设置分层面板  
  7.  Component getGlassPane(); //获得玻璃面板  
  8.  setGlassPane(Component); //设置玻璃面板  

   2.3.2 分层面板(JLayeredPane) 

  Swing提供两种分层面板:JlayeredPane和JDesktopPane。 JDesktopPane是JLayeredPane的子类,专门为容纳内部框架(JInternalFrame)而设置。    向一个分层面板种添加组件,需要说明将其加入哪一层,指明组件在该层中的位置:add(Component c, Integer Layer, int position)。 

2.3.3 面板(JPanel) 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值