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

正文內容

基于java的圖形用戶界面及其應用-預覽頁

2024-12-14 15:30 上一頁面

下一頁面
 

【正文】 裝成一個整體。它們都是在 AWT 組件名前面加一個英文字母 J( J組件)。這些從JComponent 抽象類繼承的組件類是一個實例,必須放置在象 JFrame, 等類的頂級容器中成為它們的子組件,而頂級容器 又是父容器。比如說,設計一個簡單的計算器,或一個文本編輯器等等。那么,在什么 時候應該使用布局管理器?應選擇哪種布局管理器?又該怎樣使用布局管理器呢? 如果寫的是 GUI 程序,在使用 AWT/Swing 組件時就不應硬性設置組件的大小和位置,而應該使用 Java 的布局管理器( LayoutManager)來設置和管理可視組件的大小和位置,否則就有可能造成布局混亂。也就是說,容器只管將其他組 件放入其中,而不管這些組件是如何放置的。然后 LayoutManager 類就可以通過這些信 息來實際布局其中的組件了。如圖 34 所示: North West Center East South 圖 34 邊界布局 例如: class MyPanel extends Jpanel {setLayout(new BorderLayout())。可以通過指定 BorderLayout 類中的 CENTER, NORTH, SOUTH, EAST, WEST 常量來添 加組件。在 Java中則是定義了一個普通的、可擴充的事件機制,這種機制能夠: (1)對事件類型和傳遞的模型的定義和擴充提供一個公共框架,并適合于廣泛的應用。 (5)事件機制本身不依賴于復雜的開發(fā)工具。實現了事件監(jiān)聽者接口中一些或全部方法的類就是事件監(jiān)聽者。有時,事件監(jiān)聽者不能直接實現事件監(jiān)聽者接口,或者還有其它的額外動作時,就要在一個源與其它一個或多個監(jiān)聽者之間插入一個事件適配器類的實例,來建立它們之間的聯系。授權型事件模式就是把對所引發(fā)事件的處理任務全部授權給這些獨立的來進行處理 四 一個基于 JAVA 的圖形用戶界面實例的設計與實現 (一)運行環(huán)境配置 本程序的運行環(huán)境是 ,安裝在 d 盤,其配置如下: ( 1) 如果你的操作系統是 Win 98,可以用記事本直接編輯 ,添加下面命令行: PATH=d:\\bin SET JAVA_HOME=d:\ SET CLASSPATH=.。右鍵單擊 我的電腦 ,在彈出菜單中選擇 屬性 → 系統特性 → 高級 → 環(huán)境變量 , 彈出環(huán)境變量對話框,就可以編輯系統的環(huán)境變量了。如圖 41 所示:( windows2020 中的開始菜單) 圖 41 Windows2020系統 開始菜單 而在本程序中采用的框架方式來實現,而不在是如上的菜單。如下: text: ActionListener textListener=new ActionListener() {public void actionPerformed(ActionEvent e) {…}} establish ActionListener estListener=new ActionListener() 9 {public void actionPerformed(ActionEvent e) {… }} search ActionListener seaListener=new ActionListener() {public void actionPerformed(ActionEvent e) {… }} help ActionListener helpListener=new ActionListener() {public void actionPerformed(ActionEvent e) {… }} carryout ActionListener carryListener=new ActionListener() {public void actionPerformed(ActionEvent e) {… }} 對于上述方法,是采用 JAVA 中的匿名內部類進行。內部類同 JAVA 中的訪問控制,以及安全性方面的交互也不明顯。其它的幾個匿名內部類都可以是和上面的方法一樣的。當用戶用鼠標點擊菜單項或子項時,也會象用鼠標點擊按鈕一樣產生動作事件,變化事件。對 start(啟動)也只給出空監(jiān)聽器,可以以后在實現起功能。為了實現此界面功能,就用到 JAVA中線程方面的接口,如 Runnable 接口,主要是對 run 方法的運用: public void run() { try{while(!interrupted()) {sleep(interval)。對于重畫工作,是通過調用 paint()方法實現,即用鐘面的顏色覆蓋掉原表針顏色。 else if((/))arg/=n。 12 五 結束語 通過本次設計,成功實現了基于 JAVA 的圖形用戶界面。 本文由于時間關系,圖形界面比較簡單,只是 說明了 JAVA 中圖形用戶界面的基本實現過程以及相關技術,各種功能并不完全。 import .*。 private JMenuItem search。 private JMenuItem start。 setTitle(windows2020)。 JMenuBar mbar=new JMenuBar()。 start=new JMenuItem(start)。 establish=new JMenuItem(establish)。 14 JMenuItem[] jm1={textfile,establish,search,help,carryout}。} }。 (timeListener)。 ActionListener staListener=new ActionListener() {public void actionPerformed(ActionEvent e) {。 (start)。} }。 ActionListener seaListener=new ActionListener() {public void actionPerformed(ActionEvent e) {。 。} 15 }。i++) { jm1[i].addActionListener(jm2[1])。} public void menuDeselected(MenuEvent e){int j=0。 } } import .*。 //import 。 ()。 setLocation(frameX,frameY)。 Container c=getContentPane()。 addWindowListener(new WindowAdapter() {public void windowClosing(WindowEvent e) {(0)。 class CalculatorJPanel extends JPanel implements ActionListener{ private JTextField display。 public CalculatorJPanel() {int rows=4,cols=4。 add(display,North)。 for(int i=0。 } private void addButton(Container c,String s) {JButton b=new JButton(s)。 if(39。(0)=39。 17 start=false。} else{ double x=(())。} } } public void calculate(double n) {if((+))arg+=n。 else if((=))arg=n。 setSize(width,height)。 (new CalculatorJPanel())。 import .*。 private String op==。 display=new JTextField(0)。 (new GridLayout(rows,cols))。i++) addButton(p,(i,i+1))。 (this)。=(0)amp。||(.)) {if(start)(s)。 start=false。 op=s。 else if((*))arg*=n。))arg=n。 setSize(width,height)。 (new CalculatorJPanel())。 import .*。 public Timeclock() {super()。 } public Timeclock(String str) {super()。 city=new String(str)。 xcenter=getWidth()/2。 h=()。 ym=(int)((m*)*40+ycenter)。 y=ycenterCLOCK_RADIUS。 (new Color(224,255,245))。ithickness。i+=5) if(i!=15amp。i!=45amp。 ()。 (12,xcenter5,ycenter37)。 if(xm!=lastxm||ym!=lastym){ (xcenter,ycenter1,lastxm,lastym)。} ()。 (xcenter+1,ycenter,xm,ym)。lastys=ys。lastyh=yh。 int xStr=6+((city))/2。 calendar=new GregorianCalendar((tz))。 Graphics g=getGraphics()。 private int interval。 } public void run() { try{while(!interrupted()) {sleep(interval)。s layout and layout ,a handle of Process. Not only install the method of JAVA system and give outing a specific way of realizesesing process, but also explain the JAVA high class characteristic, such as a handle of the multiline Process, the mechanism of unusually handle. moreover, this text still provided the method of handling of some animationsesed. Keywords: JAVA language, GUI, AWT, Swing, Jmodule
點擊復制文檔內容
環(huán)評公示相關推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1