Java的常用方法--Swing基础

style="WIDTH: 89.81%; HEIGHT: 64px" src="http://pagead2.googlesyndication.com/pagead/ads?client=ca-pub-4577827332549849&dt=1192819750500&lmt=1192819750&prev_fmts=468x60_as&format=468x15_0ads_al_s&output=html&correlator=1192819750437&channel=1741427766&pv_ch=1741427766%2B&url=http%3A%2F%2Fyzkzoo.5d6d.com%2Fthread-68-1-1.html&color_bg=FFFFFF&color_text=000000&color_link=0000FF&color_url=008000&color_border=336699&ref=http%3A%2F%2Fyzkzoo.5d6d.com%2Fforum-16-1.html&cc=100&ga_vid=1025434795.1192631677&ga_sid=1192817968&ga_hid=1871659779&ga_fc=true&flash=8&u_h=768&u_w=1024&u_ah=738&u_aw=1024&u_cd=32&u_tz=480&u_his=2&u_java=true">

style="WIDTH: 82.23%; HEIGHT: 74px" src="http://pagead2.googlesyndication.com/pagead/ads?client=ca-pub-4577827332549849&dt=1192818497343&lmt=1192818497&format=468x60_as&output=html&correlator=1192818497343&channel=1741427766&url=http%3A%2F%2Fyzkzoo.5d6d.com%2Fthread-68-1-1.html&color_bg=FFFFFF&color_text=000000&color_link=0000FF&color_url=008000&color_border=336699&ad_type=text_image&ref=http%3A%2F%2Fyzkzoo.5d6d.com%2Fforumdisplay.php%3Ffid%3D16%26page%3D1&ui=rc%3A6&cc=100&ga_vid=1025434795.1192631677&ga_sid=1192817968&ga_hid=1000484876&ga_fc=true&flash=8&u_h=768&u_w=1024&u_ah=738&u_aw=1024&u_cd=32&u_tz=480&u_his=6&u_java=true">

 1、Jcomponent类
Jcomponent类 是所有轻量组件的父类,主要的子类有:
JButton 创建按钮对象,而且可以创建在图标的按钮
JComboBox 创建组合框对象,和Choice相似
JCheckBox 创建复选框对象
JFileChooser 创建文件选择器
JInternalFrame 创建内部窗体
JLabel 创建标签
JMenu 创建菜单对象
JMenuBar 创建菜单条对象
JMenuItem 创建菜单项对象
JPanel 创建面板对象
JPasswordField 创建口令文本对象
JPopupMenu 创建弹出式菜单
JProgressBar 创建进程条
JRadioButton 创建单选按钮
JScrollBar 创建滚动条
JScrollPane 创建滚动窗格
JSlider 创建滚动条
JSplitPane 创建拆分窗格
JTable 创建表格
JTextArea 创建文本区
JTexPane 创建文本窗格
JToolBar 创建工具条
JToolTip 创建工具提示对象
JTree 创建树对象
2、JFrame类
JFrame类及其子类创建的对象是窗体
(1)JFrame类及其子类创建的窗体是swing窗体
(2)不可以把组件直接加到swing窗体中,应该把组件加到内容面板中
(3)不能为swing窗体设置布局,而应当为内容面板设置布局
(4)swing窗体通过调用getContentPane()方法得到它的内容面板
3、JApplet类
(1)不可以把组件直接添加到小程序容器中,也应该添加到内容面板中
(2)不能为小程序设置布局
(3)小程序容器通过调用getContenPane()方法得到内容面板
4、JDialog类
(1)不可以把组件直接添加到对话框容器中,也应该添加到内容面板中
(2)不能为对话框设置布局
(3)对话框容器通过调用getContenPane()方法得到内容面板
5、JPanel面板
JPanel()
JPanel(布局对象)
6、滚动窗口JScrollPane
JScrollPane()
JScrollPane(component c)
7、拆分窗口JSplitPane
JSplitPane(int a,Component b,Component c)
a的取值是HORIZONTAL_SPLIT或者VERTICAL_SPLIT决定水平拆分还是垂直拆分
JSplitPane(int a,boolean b ,Component b,Component c) b的取值决定拆分线移动的时候组件是否连续变化
8、内部窗体JInternalFrame
JInternalFrame(String title,boolean resizable,booleam closable,boolean max,boolean min)
参数的意义分别是窗口名称,是否能调整大小,是否有关闭按钮,最大化按钮,最小化按钮
(1)不能把组件直接加到窗体中,而是加到内容面板中
(2)必须先把内部窗体加到一个容器中(JDesktopPane),该容器是专门为内部窗体服务的
9、按钮(JButton)
JButton() 创建按钮
JButton(String s) s是按钮的名字
JButton(Icon icon) icon是按钮上的图标
JButton(String s,Icon icon)
getText() 获取按钮名字
getIcon() 获取按钮图标
setIcon(Icon icon) 设置按钮图标
setHorizontalTextposition(int a) a确定按钮上图标的位置,取值:
AbstractButton_CENTR,AbstractButton_LEFT,AbstractButton_RIGHT
setVerticalTextposition(int a) a确定按钮上名字相对图标的位置,取值:
AbstractButton.TOP,AbstractButton.BOTTOM,AbstractButton.CENTR
setMnemonic(char c) 设置按钮的键盘操作方式是字符c(Alt+c)
setEnabled(boolean b) b决定按钮是否可以被单击

style="WIDTH: 44.33%; HEIGHT: 259px" src="http://pagead2.googlesyndication.com/cpa/ads?client=ca-pub-4577827332549849&cpa_choice=CAEaCB94-nvUZWENUB9QugJQtwRQTVAgULcCUB4&oe=gb2312&dt=1192720966468&lmt=1192720966&format=250x250_as&output=html&correlator=1192720966453&channel=2735220158&url=http%3A%2F%2Fyzkzoo.5d6d.com%2Fthread-67-1-1.html&color_bg=FFFFFF&color_text=000000&color_link=0000FF&color_url=008000&color_border=336699&ad_type=text_image&region=_google_cpa_region_&ref=http%3A%2F%2Fyzkzoo.5d6d.com%2Fforum-16-1.html&cc=100&ga_vid=1025434795.1192631677&ga_sid=1192720940&ga_hid=1155529757&ga_fc=true&flash=8&u_h=768&u_w=1024&u_ah=738&u_aw=1024&u_cd=32&u_tz=480&u_his=2&u_java=true"> style="WIDTH: 52.39%; HEIGHT: 259px" src="http://pagead2.googlesyndication.com/cpa/ads?client=ca-pub-4577827332549849&cpa_choice=CAEaCKcC4yuPlq5lUDRQDVAtUK4BUENQCA&oe=gb2312&dt=1192819388296&lmt=1192819388&format=300x250_as&output=html&correlator=1192819388281&channel=2735220158&url=http%3A%2F%2Fyzkzoo.5d6d.com%2Fviewthread.php%3Ftid%3D70%26page%3D1%26extra%3Dpage%253D1&color_bg=FFFFFF&color_text=000000&color_link=0000FF&color_url=008000&color_border=336699&ad_type=text_image&region=_google_cpa_region_&ref=http%3A%2F%2Fyzkzoo.5d6d.com%2Fpost.php%3Faction%3Dedit%26fid%3D16%26tid%3D70%26pid%3D70%26page%3D1%26extra%3Dpage%253D1&cc=100&ga_vid=1025434795.1192631677&ga_sid=1192817968&ga_hid=1527165455&ga_fc=true&flash=8&u_h=768&u_w=1024&u_ah=738&u_aw=1024&u_cd=32&u_tz=480&u_his=5&u_java=true">

 

style="WIDTH: 82.23%; HEIGHT: 74px" src="http://pagead2.googlesyndication.com/pagead/ads?client=ca-pub-4577827332549849&dt=1192818497343&lmt=1192818497&format=468x60_as&output=html&correlator=1192818497343&channel=1741427766&url=http%3A%2F%2Fyzkzoo.5d6d.com%2Fthread-68-1-1.html&color_bg=FFFFFF&color_text=000000&color_link=0000FF&color_url=008000&color_border=336699&ad_type=text_image&ref=http%3A%2F%2Fyzkzoo.5d6d.com%2Fforumdisplay.php%3Ffid%3D16%26page%3D1&ui=rc%3A6&cc=100&ga_vid=1025434795.1192631677&ga_sid=1192817968&ga_hid=1000484876&ga_fc=true&flash=8&u_h=768&u_w=1024&u_ah=738&u_aw=1024&u_cd=32&u_tz=480&u_his=6&u_java=true">

style="WIDTH: 82.23%; HEIGHT: 74px" src="http://pagead2.googlesyndication.com/pagead/ads?client=ca-pub-4577827332549849&dt=1192818497343&lmt=1192818497&format=468x60_as&output=html&correlator=1192818497343&channel=1741427766&url=http%3A%2F%2Fyzkzoo.5d6d.com%2Fthread-68-1-1.html&color_bg=FFFFFF&color_text=000000&color_link=0000FF&color_url=008000&color_border=336699&ad_type=text_image&ref=http%3A%2F%2Fyzkzoo.5d6d.com%2Fforumdisplay.php%3Ffid%3D16%26page%3D1&ui=rc%3A6&cc=100&ga_vid=1025434795.1192631677&ga_sid=1192817968&ga_hid=1000484876&ga_fc=true&flash=8&u_h=768&u_w=1024&u_ah=738&u_aw=1024&u_cd=32&u_tz=480&u_his=6&u_java=true">

style="WIDTH: 58.41%; HEIGHT: 156px" src="http://pagead2.googlesyndication.com/pagead/ads?client=ca-pub-4577827332549849&dt=1192819750656&lmt=1192819750&prev_fmts=468x60_as%2C468x15_0ads_al_s%2C234x60_as&format=200x90_0ads_al_s&output=html&correlator=1192819750437&channel=1741427766&pv_ch=1741427766%2B&url=http%3A%2F%2Fyzkzoo.5d6d.com%2Fthread-68-1-1.html&color_bg=FFFFFF&color_text=000000&color_link=0000FF&color_url=008000&color_border=336699&ref=http%3A%2F%2Fyzkzoo.5d6d.com%2Fforum-16-1.html&cc=100&ga_vid=1025434795.1192631677&ga_sid=1192817968&ga_hid=1871659779&ga_fc=true&flash=8&u_h=768&u_w=1024&u_ah=738&u_aw=1024&u_cd=32&u_tz=480&u_his=2&u_java=true"> 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值