ImageVerifierCode 换一换
格式:DOCX , 页数:8 ,大小:16.61KB ,
资源ID:7073536      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bingdoc.com/d-7073536.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(实验六图形界面Word文档格式.docx)为本站会员(b****3)主动上传,冰点文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰点文库(发送邮件至service@bingdoc.com或直接QQ联系客服),我们立即给予删除!

实验六图形界面Word文档格式.docx

1、代码如下:package TestChange;import java.awt.BorderLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JPanel;import javax.swing.JTextField;public class TestChange extends JFrame implements ActionListener pr

2、ivate static final long serialVersionUID = -3684503858019589006L; JPanel panel; JTextField tt1; JTextField tt2; JButton button; public TestChange() this.setTitle(TestChange); this.setSize(355, 85); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); panel = new JPanel(); tt1 = new JTextField(10); t

3、t2 = new JTextField(10); button = new JButton(Change button.addActionListener(this); panel.add(tt1); panel.add(tt2); panel.add(button); this.add(panel, BorderLayout.NORTH); this.setResizable(false); this.setVisible(true); public static void main(String str) new TestChange(); Override public void act

4、ionPerformed(ActionEvent e) if(e.getSource() = button) String temp = tt1.getText(); tt1.setText(tt2.getText(); tt2.setText(temp);2. 采用图形界面设计如下图2所示的界面。并能够实现当点击“+”按钮时,标签给出点击次数,如图3所示图2 开始界面图3 点击“+”按钮后的界面3教材P220页,第3题,创建一个会员注册窗体,要求使用上JCheckBox,JRadioButton,JTextFiled,JTextArea等组件,并将用户的注册信息显示到文本区中。package

5、 java实验六;import java.*;import javax.swing.*;import java.awt.event.*;import java.awt.*;public class VipDemo extends JFrame implements ActionListener private Color c; private int style; private Font f,fl; private JLabel jlExample,jlFontstyle,jlColor,jlname,jlid,jlphone,jlsex; private JButton jbOk,jbCa

6、ncel; private JRadioButton rbRed,rbBlue,rbBlack,rbm,rbf; private ButtonGroup g; private JCheckBox jcbBold,jcbItalic; private JPanel jpFontstyle,jpColor,jpLabel,jpsex; private JTextField jtname,jtid,jtphone; private JTextArea jta; public VipDemo() style=Font.PLAIN; jlExample=new JLabel(请看设置效果 jlFonts

7、tyle=new JLabel(字形 jlColor=new JLabel(颜色 jlsex=new JLabel(性别 jlname=new JLabel(名字 jlid=new JLabel(编号 jlphone=new JLabel(联系方式 jbOk=new JButton(确定 jbCancel=new JButton(取消 rbRed=new JRadioButton( rbBlue=new JRadioButton( rbBlack=new JRadioButton( rbm=new JRadioButton(男 rbf=new JRadioButton(女 g=new Butt

8、onGroup(); jcbBold=new JCheckBox(粗体 jcbItalic=new JCheckBox(斜体 jpFontstyle=new JPanel(); jpColor=new JPanel(); jpLabel=new JPanel(); jpsex=new JPanel(); jtname=new JTextField(); jtid=new JTextField(); jtphone=new JTextField(); jta=new JTextArea(4,15); public void launchButtonTest() jta.setEditable(f

9、alse); f=jlExample.getFont(); fl=f.deriveFont(Font.PLAIN); jlExample.setFont(fl); rbRed.setBackground(Color.red); rbBlue.setBackground(Color.blue); rbBlack.setBackground(Color.black); rbRed.addActionListener(this); rbBlue.addActionListener(this); rbBlack.addActionListener(this); jcbBold.addActionLis

10、tener(this); jcbItalic.addActionListener(this); rbm.addActionListener(this); rbf.addActionListener(this); jbOk.addActionListener(this); jbCancel.addActionListener(this); g.add(rbRed); g.add(rbBlue); g.add(rbBlack); g.add(rbm); g.add(rbf); jpFontstyle.add(jlFontstyle); jpFontstyle.add(jcbBold); jpFon

11、tstyle.add(jcbItalic); jpColor.add(jlColor); jpColor.add(rbRed); jpColor.add(rbBlue); jpColor.add(rbBlack); jpLabel.add(jlExample); jpsex.add(rbm); jpsex.add(rbf); Container cp=getContentPane(); cp.setLayout(new GridLayout(7,2,5,5); cp.add(jpFontstyle); cp.add(jpColor); cp.add(jpLabel); cp.add(jpsex

12、); cp.add(jlname); cp.add(jtname); cp.add(jlid); cp.add(jtid); cp.add(jlphone); cp.add(jtphone); cp.add(jbOk); cp.add(jbCancel); cp.add(jta); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); pack(); setVisible(true); public void actionPerformed(ActionEvent e) if(rbRed.isSelected() c=Color.red; if(rbB

13、lue.isSelected() c=Color.blue; if(rbBlack.isSelected() c=Color.black; jlExample.setForeground(c); Object source=e.getSource(); if(source=jcbBold) style=styleFont.BOLD; if(source=jcbItalic) style=styleFont.ITALIC; jlExample.setFont(fl.deriveFont(style); if(source=rbm) jta.append(男n if(source=rbf) if(

14、source=jbOk)姓名 +jtname.getText()+n+jtid.getText()+联系方式 +jtphone.getText()+ public static void main(String args) VipDemo bt=new VipDemo(); bt.setTitle(会员注册 bt.launchButtonTest();4 利用相应的组件编辑一个文本编辑器,参照Windows记事本,可以对字体大小、字形(粗体,斜体)、颜色进行设置,可以对内容进行添加、删除、修改,并保存文本。 说明:(1)可以选用单选框、复选框、列表、下拉框或菜单任意一种或多种组合实现字体的设置 (2)根据自己的编程能力实现功能,可以只实现字体的设置,或者字体和内容的编辑,或者全部功能都实现。 (3)本题的目的是常用组件的使用。III 在本次实验中的问题和解决方法 本次实验中一切的设计和实现还比较理想,没遇上什么难题。IV心得体会通过本次实验我了解了图形用户界面的设计方法,掌握了常用的构建用户界面的组件的用法,掌握事件操作的原理,能够对所设计的用户界面进行事件处理,能够应用运算符解决实际小问题,熟悉了Java的面向对象的编程思想

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2