最近2018中文字幕在日韩欧美国产成人片_国产日韩精品一区二区在线_在线观看成年美女黄网色视频_国产精品一区三区五区_国产精彩刺激乱对白_看黄色黄大色黄片免费_人人超碰自拍cao_国产高清av在线_亚洲精品电影av_日韩美女尤物视频网站

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
?Swing中SwingUtilities有什么用

小編給大家分享一下Swing中SwingUtilities有什么用,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!

網(wǎng)站制作、成都網(wǎng)站建設(shè)的關(guān)注點不是能為您做些什么網(wǎng)站,而是怎么做網(wǎng)站,有沒有做好網(wǎng)站,給創(chuàng)新互聯(lián)一個展示的機會來證明自己,這并不會花費您太多時間,或許會給您帶來新的靈感和驚喜。面向用戶友好,注重用戶體驗,一切以用戶為中心。

Swing的實用工具

Swing提供了許多的在Swing組件內(nèi)部使用的實用工具,SwingUtilities類就是其中一個。它提供了許多的涉及計算、轉(zhuǎn)換、訪問控制、布局等方面的方法,這些方法已廣泛的應(yīng)用在各種Swing組件當(dāng)中。當(dāng)然,我們也可以把它拿來應(yīng)用到我們自己的程序當(dāng)中。

下面我們就來了解一個這些實用的功能.

(1)轉(zhuǎn)換方法
◆MouseEvent convertMouseEvent(Component source, MouseEvent ourceEvent, Component destination)
將一個鼠標(biāo)事件從一個組件轉(zhuǎn)換到另一個組件上。
◆Point convertPoint(Component source, int x, int y, Component estination)
◆Point convertPoint(Component source, Point aPoint, Component destination)
將一個組件上的點坐標(biāo)轉(zhuǎn)換成另一個組件上的坐標(biāo)點。
◆void convertPointFromScreen(Point p, Component c)
將一個屏暮坐標(biāo)點轉(zhuǎn)換成一個組件的坐標(biāo)點.
◆void convertPointToScreen(Point p, omponent c)
將一個組件上的坐標(biāo)點轉(zhuǎn)換成屏暮坐標(biāo)。
◆Rectangle convertRectangle(Component source, Rectangle aRectangle, Component destination)
將一個組件上的矩形坐標(biāo)轉(zhuǎn)換成另一個組件上的矩形坐標(biāo).

(2)計算方法

Rectangle[] computeDifference(Rectangle r1,Rectangle r2)  Rectangle computeIntersection(int x, int y, int width, int height, Rectangle dest)  Rectangle computeUnion(int x, int y, int width, int height, Rectangle dest)  int computeStringWidth(FontMetrics fm, String str)  boolean isRectangleContainingRectangle(Rectangle a, Rectangle b)

上面這些方法計算兩個矩形之間的差集、交集、并集,還可確定一個矩形是否包括了另一個矩形,以及計算一個字符串的像素寬度.

(3)鼠標(biāo)按鈕信息
◆boolean isLeftMouseButton(MouseEvent anEvent)
◆boolean isMiddleMouseButton(MouseEvent anEvent)
◆boolean isRightMouseButton(MouseEvent anEvent)

以給定的鼠標(biāo)事件來判定按下了哪個鼠標(biāo)按鈕。

(4)訪問控制方法
◆Component findFocusOwner(Component c)
取得給定組件的焦點組件.
◆Component getLocalBounds(Component aComponent)
取得給定組件的范圍(Bounds)信息.
◆Component getRoot(Component c)
◆JRootPane getRootPane(Component c)
取得給定組件的根窗格.
◆Window windowForComponent(Component aComponent)
返回一個組件的視窗Window.

(5)組件繪制

  1. String layoutCompoundLabel(FontMetrics fm, String text, Icon icon, 
    int verticalAlignment, int horizontalAlignment, int verticalTextPosition, 
    int horizontalTextPosition, Rectangle viewR, Rectangle iconR, Rectangle textR, 
    int textIconGap)  

  2. String layoutCompoundLabel(JComponent c, FontMetrics fm, String text, Icon icon, 
    int verticalAlignment, int horizontalAlignment, int verticalTextPosition, 
    int rizontalTextPosition, Rectangle viewR, Rectangle iconR, Rectangle textR, 
    int textIconGap)void paintComponent
    (Graphics g, Component c, Container p, int x, int y, int w, int h) 

這兩個方法用于重新布局swing按鈕和標(biāo)簽上的文本和圖標(biāo).
◆void paintComponent(Graphics g, Component c, Container p, int x, int y, int w, int h)
◆void paintComponent(Graphics g, Component c, Container p, Rectangle r)
在任一個圖形上繪制一個組件。

以上是“Swing中SwingUtilities有什么用”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對大家有所幫助,如果還想學(xué)習(xí)更多知識,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!


分享題目:?Swing中SwingUtilities有什么用
本文路徑:http://fisionsoft.com.cn/article/ggeepd.html