freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

圖形用戶界面編程ppt課件(編輯修改稿)

2025-05-31 22:04 本頁(yè)面
 

【文章內(nèi)容簡(jiǎn)介】 (text)。 } public FgButton(String text, Icon icon, String strToolTipText){ super(text, icon)。 setToolTipText(strToolTipText)。 } } Java程序設(shè)計(jì) Java Programming 27 、工具欄組件: JToolBar (3)添加 addToolBar()方法: private void addToolBar(){ //工具條 Container c=getContentPane()。 (, mtb)。 (new FlowLayout())。 FgButton[] btn={new FgButton(new ImageIcon(getClass().getResource()), 新建文件 ), new FgButton(new ImageIcon(getClass().getResource()), 打開文件 ), new FgButton(new ImageIcon(getClass().getResource()), 保存文件 )}。 for(int i=0。i。i++){ btn[i].setBorder(())。 (btn[i])。 } //設(shè)置不可浮動(dòng) (false)。 } (4)在構(gòu)造方法中添加如下代碼: addToolBar()。 Java程序設(shè)計(jì) Java Programming 28 小節(jié)安排 圖形用戶界面編程 、 菜單和工具條 、 組件常用方法 、 AWT與 Swing 、 容器: JFrame\JPanel\JScrollPane\JSplitPane 、 布局管理器 、 事件處理模型 、 基本組件: JLabel\JButton\JComboBox\JTree等 、 鼠標(biāo)事件處理 、 事件適配器類 、 鍵盤事件處理 Java程序設(shè)計(jì) Java Programming 29 、 JLabel import .*。 import .*。 public class TestJLabel extends JFrame{ public TestJLabel(){ super( JFrame with JLabel)。 //三個(gè)標(biāo)簽上的文字 String [] s = {第一個(gè)標(biāo)簽 , 文字在圖標(biāo)的左側(cè) , 文字在圖標(biāo)的下方 }。 ImageIcon[] ic = {null, new ImageIcon(), new ImageIcon( )}。 //三個(gè)標(biāo)簽在水平方向上的對(duì)齊方式 int [] ih = {0, , }。 //三個(gè)標(biāo)簽在垂直方向上的對(duì)齊方式 int [] iv = {0, , }。 Container c = getContentPane( )。//取得窗口的內(nèi)容面板 ( new FlowLayout() )。 //設(shè)置布局管理器 Java程序設(shè)計(jì) Java Programming 30 、 JLabel for (int i=0。 i3。 i++){ //創(chuàng)建三個(gè)標(biāo)簽 JLabel myLabel = new JLabel( s[i] , ic[i], )。 if (i0){ (ih[i])。 (iv[i])。 } //設(shè)置邊框 , setBorder來(lái)自 JLabel的父類 JComponent ( (, 2))。 (第 + (i+1) + 個(gè)標(biāo)簽 )。 //加入到窗口的內(nèi)容面板中 (myLabel)。 } setDefaultCloseOperation()。 setSize(400, 300)。 } public static void main(String args[ ]){ TestJLabel frm = new TestJLabel()。 (true)。 } } Java程序設(shè)計(jì) Java Programming 31 、單行文本框: JTextField和 JPasswordField import .*。 import .*。 public class TestJTextField{ public static void main(String args[ ]){ JFrame frm= new JFrame( JFrame with JTextField )。 ()。 (260, 100 )。 Container c = ( )。 (new FlowLayout( ) )。 JTextField[] t={new JTextField(2022103088, 15), new JPasswordField(1234567890, 15)}。 (new JLabel(用戶名: ))。 (t[0])。 (new JLabel(密 碼: ))。 (t[1])。 t[0].setEditable( false )。//用戶名設(shè)置為只讀 ( true )。 } } Java程序設(shè)計(jì) Java Programming 32 、按鈕: JButtom、 JCheckBox和 JRadioButton import .*。 import .*。 public class TestJButton extends JFrame{ TestJButton(String sTitle){ super(sTitle)。 Container c = getContentPane( )。 ( new FlowLayout( ))。 //兩個(gè)按鈕上的圖標(biāo) ImageIcon[] ic = {new ImageIcon(), new ImageIcon()}。 //三個(gè)按鈕 JButton[] btn = {new JButton(新建 , ic[0]), new JButton(中間 ), new JButton(打開 , ic[1])}。 int i。 for (i=0。 i。 i++) (btn[i])。 //btn[0]的文字在圖標(biāo)左側(cè) btn[0].setHorizontalTextPosition()。 //兩個(gè)復(fù)選框 JCheckBox[] ck = {new JCheckBox(左 ), new JCheckBox(右 )}。 for (i=0。 i。 i++){ (ck[i])。 ck[i].setSelected(true)。//將復(fù)選框設(shè)置為選中狀態(tài) } Java程序設(shè)計(jì) Java Programming 33 、按鈕: JButtom、 JCheckBox和 JRadioButton //兩個(gè)單選框 JRadioButton[] r={new JRadioButton(左 ), new JRadioButton(右 )}。 ButtonGroup rg = new ButtonGroup( )。 for (i=0。 i 。 i++){ ( r[i] )。 ( r[i] )。//組成 ButtonGroup,這樣二者只能同時(shí)選中一項(xiàng) } //設(shè)置單選框的選擇狀態(tài) r[0].setSelected(true)。 r[1].setSelected(false)。 setSize(300,150)。 setDefaultCloseOperation()。 } public static void main(String args[]){ TestJButton frm=new TestJButton(JFrame with JButton)。 (true)。 } } Java程序設(shè)計(jì) Java Programming 34 、下拉框: JComboBox import .*。 import .*。 public class TestJComboBox extends JFrame{ //字體與大小下拉框 JComboBox cbxFont=new JComboBox()。 JComboBox cbxFontSize=new JComboBox()。//字體大小 TestJComboBox(String sTitle){ super(sTitle)。 Container c = getContentPane( )。 (new FlowLayout())。 (new JLabel(字體名稱: ))。 (cbxFont)。 (new JLabel(字體大?。?))。 (cbxFontSize)。 //初始化字體與大小下拉框 InitFonts()。 setSize(300,120)。 setDefaultCloseOperation()。 } Java程序設(shè)計(jì) Java Programming 35 、下拉框: JComboBox //初始化字體框 private void InitFonts(){ //獲得系統(tǒng)的字體數(shù)組 GraphicsEnvironment ge= ()。 String[] fontList=()。 int i。 //添加字體名稱 for(i=0。i。i++) ((i)+ | +fontList[i])。 (231)。//選擇 index為 30的項(xiàng) //添加字體大小 for(i=9。i=72。i++) (new Integer(i).toString())。 (3)。//選擇 index為 3的項(xiàng) } public static void main(String args[]){ TestJComboBox frm=new TestJComboBox(JFrame with JComboBox)。 (true)。 } } Java程序設(shè)計(jì) Java Programming 36 、列表框: JList import .*。 import .*。 public class TestJList extends JFrame{ //聲明列表框?qū)ο? JList listNames=new JList()。 TestJList(String sTitle){ super(sTitle)。 Container c = getContentPane( )。 //以下語(yǔ)句保證列表框數(shù)據(jù)較多時(shí)會(huì)出現(xiàn)滾動(dòng)條 JScrollPane scrollPane = new JScrollPane(listNames)。 (scrollPane)。 //初始化列表框 InitFonts()。 setSize(250,150)。 setDefaultCloseOperation()。 } Java程序設(shè)計(jì) Java Programming 37 、列表框: JList //初始化列表框 private void InitFonts(){ String[] names={202226100101 曹帝胄 ,202226100111 洪峰 , 202226100128 徐華鵬 ,202226100131 姚臻平 , 202226100202 陳思行 ,202226100207 姜楠 , 202226100210 林一民 ,202226100211 林澤偉 }。 //用數(shù)組填充列表框 (names)。 //將 3的項(xiàng) (202226100111和 202226100131)設(shè)置為選擇狀態(tài) (new int[]{1, 3})。 } public static void main(String args[]){ TestJList frm=new TestJList(JFrame with JList)。 (true)。 } } Java程序設(shè)計(jì) Java Programming 38 、多行文本框: JTextArea JTextArea類的常用 public方法 方法定義 功能說(shuō)明 void setLineWrap(boolean wrap) 設(shè)置是否自動(dòng)換行,默認(rèn)值為
點(diǎn)擊復(fù)制文檔內(nèi)容
教學(xué)課件相關(guān)推薦
文庫(kù)吧 www.dybbs8.com
備案圖片鄂ICP備17016276號(hào)-1