版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、SWING的圖形介面元件,JLabel,JLabel label = new JLabel(關閉); JLabel label1 = new JLabel( new ImageIcon(tree.jpg); JLabel(String,int), JLabel(ImageIcon, int) JLabel.LEFT JLabel.RIGHT JLabel.CENTER JLabel.LEADING JLabel.TRAILING,JButton,JButton button1 = new JButton(切換(Alt_S); JButton button2 = new JButton( new
2、 ImageIcon(yellow.gif); button1.addActionListener(new ActionListener() public void actionPerformed(ActionEvent evt) / 切換標題的文字內容 if ( flag = 0 ) label.setText(開啟); else label.setText(關閉); flag = 1 - flag; );,JCheckBox,greenBox = new JCheckBox(綠色(G); greenBox.setMnemonic(KeyEvent.VK_G); greenBox.setSe
3、lected(true); greenBox.addItemListener(this); Ch11_1_2,JRadio,ButtonGroup() add() remove() JRadionButton() setMnemoic() setSelected(boolean) addItemListener(ItemListener) removeItemListener() CH11_1_3,JComboBox,String items = 程式語言, 計算機概論, 資料庫系統, 網頁設計; JComboBox list = new JComboBox(items); Ch11_1_4,
4、JList,String names = 陳會安, 江小魚, 小龍女, 張三丰; dlistModel = new DefaultListModel(); for (int i = 0; i names.length; i+) dlistModel.addElement(namesi); / 新增元素 nameList = new JList(dlistModel); Ch11_1_5,JScroll,JScrollBar() JScrollBar(int) JScrollBar(int,int,int,int,int) s1=new JScrollBar(JScrollBar.VERTICA
5、L,50,10,0,100);,JSlider,JSlider() JSlider(int) JSlider(int,int) JSlider(int,int,int) JSlider(int,int,int,int) Ch11_1_6,JTextComponent,JTextField and JPasswordField JTextField text = new JTextField(12); JPasswordField password = new JPasswordField(12); Ch_2_1,JTextArea,JTextArea() JTextArea(String) J
6、TextArea(int,int) JTextArea(String,int,int) area = new JTextArea(等待輸入資料.n, 15, 30); JScrollPane scroll = new JScrollPane(area); Ch11_2_2,JPopupMenu,popup = new JPopupMenu(); popup.add(blue = new JMenuItem(藍色); blue.addActionListener(this); popup.add(yellow = new JMenuItem(黃色); yellow.addActionListen
7、er(this); popup.add(green = new JMenuItem(綠色); green.addActionListener(this);,JPopupMenu,addMouseListener(new MouseAdapter() public void mousePressed(MouseEvent evt) if ( evt.isPopupTrigger() ) / 顯示選單 popup.show(evt.getComponent(), evt.getX(), evt.getY(); public void mouseReleased(MouseEvent evt) if
8、 ( evt.isPopupTrigger() ) / 顯示選單 popup.show(evt.getComponent(), evt.getX(), evt.getY(); ); Ch11_3_1,JMenuBar,JMenuBar jmb = new JMenuBar(); setJMenuBar(jmb); / 新增下拉式功能表,JMenu,JMenu file = new JMenu(檔案(F); file.setMnemonic(KeyEvent.VK_F); JMenuItem item; file.add(item = new JMenuItem(新增(N),KeyEvent.V
9、K_N); file.add(item = new JMenuItem(開啟(O),KeyEvent.VK_O); JMenu setting = new JMenu(“參數設定”); / 子選單 file.add(setting); / 新增子選單 file.addSeparator(); / 分隔線 file.add(item = new JMenuItem(關閉(X),KeyEvent.VK_X); jmb.add(file); / 新增file選單 Ch11_3_2,JToolBar,JToolBar toolBar = new JToolBar(); blue = new JButt
10、on(new ImageIcon(blue1.gif); blue.setToolTipText(藍色); blue.addActionListener(this); yellow = new JButton(new ImageIcon(yellow1.gif); yellow.setToolTipText(黃色); yellow.addActionListener(this); green = new JButton(new ImageIcon(green1.gif); green.setToolTipText(綠色); green.addActionListener(this); tool
11、Bar.add(blue); toolBar.add(yellow); toolBar.add(green); Ch11_3_3,JFileChooser,final JFileChooser jfc = new JFileChooser(); int n = jfc.showOpenDialog(Ch11_4_1.this); if ( n = JFileChooser.APPROVE_OPTION ) File file = jfc.getSelectedFile(); area.append(開啟檔案名稱: ); area.append(file.getName() + n); ,JColorChooser,final JColorChooser jcc = new JColorChooser(); JButton button = new JButton(選擇背景色彩); button.addActionListener(new ActionListener() pu
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026年海底管线交越与并行段施工保护方案
- 黑龙江省海伦市2026届初三期中考试化学试题(A卷)试题含解析
- 北京市教院附中2026年初三第一次联合考试生物试题理试卷含解析
- 2026年转基因产品成分定量检测标准制定优先方向
- 2026年边缘AI一体机从技术选型到部署实施全流程参考
- 2026年失能等级评估定点机构申请条件与流程
- 2025-2026学年下学期河北秦皇岛高二数学3月开学考试卷(含解析)
- 媒体广告投放合同谈判要点
- 电影行业制片人面试全解
- 综艺节目对青少年价值观的影响
- 2024年江苏农林职业技术学院高职单招(英语/数学/语文)笔试历年参考题库含答案解析
- DB52-T 1685-2022 电动汽车充电站(桩)防雷技术规范
- 建设工程项目经济分析与评价PPT完整全套教学课件
- 技术交底制度
- 废塑料高温裂解干馏可行性报告
- 地质勘探原始记录表格【实用文档】doc
- GB/T 30812-2014燃煤电厂用玻璃纤维增强塑料烟道
- 住院医师规范化培训临床技能结业考核体格检查评分表(神经外科)
- 小学二年级下册体育教案(全册)
- 中国外文出版发行事业局所属企事业单位公开招聘71人模拟试卷【共500题附答案解析】
- 《导游基础知识》61中国古典园林概说课件
评论
0/150
提交评论