JFrame的相关函数

Module java.desktop

Package javax.swing

Class JFrame

Pack()函数:使此窗口的大小适合其子组件的首选大小和布局。如果其中一个尺寸小于前面调用setMinimumSize方法所指定的最小尺寸,则会自动放大窗口的结果宽度和高度。

public void setDefaultCloseOperation​(int operation)     设置默认情况下,当用户在此Frame上启动“关闭”时将发生的操作。您必须指定以下选项之一: 

  • DO_NOTHING_ON_CLOSE (defined in WindowConstants): Don't do anything; require the program to handle the operation in the windowClosing method of a registered WindowListener object.
  • 不做任何事,需要程序去处理(一个已经注册了的WindowListener对象的windowClosing方法)的操作
  • HIDE_ON_CLOSE (defined in WindowConstants): Automatically hide the frame after invoking any registered WindowListener objects.
  • 在调用了任何已经注册了的WindowListener对象后自动隐藏Frame。
  • DISPOSE_ON_CLOSE (defined in WindowConstants): Automatically hide and dispose the frame after invoking any registered WindowListener objects.
  • 调用任何已注册的WindowListener对象后自动隐藏和处理Frame。
  • EXIT_ON_CLOSE (defined in WindowConstants): Exit the application using the System exit method. Use this only in applications.
  • 使用System exit方法退出应用程序。仅在应用程序中使用。

该值默认设置为HIDE_ON_CLOSE。此属性值的更改将引发属性更改事件,属性名称为“defaultCloseOperation”。

public Component add​(Component comp, int index)     在容器的给定位置添加此组件。

public void remove​(Component comp) 

从容器中移除指定的组件。如果comp不是rootPane,这将把调用转发到contentPane。如果comp不是JFrame或contentPane的子元素,这将不起任何作用。

public Container getContentPane()

返回此frame的contentPane对象。

@BeanProperty(bound=false) public Graphics getGraphics()

为该组件创建图形上下文。如果该组件当前不可显示,则此方法将返回null。

@BeanProperty(bound=false, hidden=true, description="The client area of the frame where child components are normally inserted.") public void setContentPane​(Container contentPane)

设置contentPane属性。此方法由构造函数调用。Swing的绘画体系结构需要包含层次结构中的不透明JComponent。这通常由content窗格提供。如果替换内容窗格,建议使用不透明的JComponent替换它。

@BeanProperty(bound=false, hidden=true, description="The menubar for accessing pulldown menus from this frame.") public void setJMenuBar​(JMenuBar menubar)

设置这个frame的菜单栏。

 

 

 

 

 

 

 

 

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值