成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

實用工具SwingUtilities

開發 后端
本文介紹實用工具SwingUtilities,它提供了許多的涉及計算、轉換、訪問控制、布局等方面的方法,這些方法已廣泛的應用在各種Swing組件當中。

Java的秘密:Swing的實用工具

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

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

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

(2)計算方法

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

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

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

以給定的鼠標事件來判定按下了哪個鼠標按鈕。

(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按鈕和標簽上的文本和圖標.
◆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)
在任一個圖形上繪制一個組件。

【編輯推薦】

  1. 淺析運行Swing應用程序
  2. 了解AWT和Swing組件
  3. Swing組件相關的操作
  4. 詳解MVC設計模式與Swing
  5. 淺談Swing和AWT構件
責任編輯:佚名 來源: 中國IT實驗室
相關推薦

2022-02-25 09:03:49

工具Swift項目

2011-01-14 13:40:24

UbuntuLinux Tips

2025-03-04 10:49:51

2011-07-20 14:03:33

jQuery Mobi實用工具

2017-04-28 14:47:23

人工智能

2013-11-29 10:35:34

命令行工具ncdu

2011-04-13 09:40:27

2023-08-02 10:41:26

2019-03-19 09:00:00

LinuxBackBox滲透測試

2011-07-20 10:08:05

NetXray

2022-04-26 09:01:39

實用工具類型TypeScript

2019-06-17 09:55:05

GPartedLinux根分區

2013-02-27 10:42:07

前端工具Web

2019-12-27 09:00:28

Azure工具Azure平臺

2020-10-26 10:00:28

Linux工具命令

2023-09-03 17:03:54

工具RegexGPTBloop

2011-01-24 15:52:07

2009-09-10 09:31:15

Linux無線網絡Linux實用工具

2019-07-12 08:00:00

Mac應用程序實用工具

2015-10-10 15:09:46

推薦工具Linux
點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 成人亚洲性情网站www在线观看 | 成人国产精品久久久 | 免费观看黄网站 | 91精品久久| 91久久久久久久久久久久久 | 毛片网站免费观看 | 综合伊人 | 99热这里只有精品8 激情毛片 | 精品一区二区三区在线观看 | aaaaa毛片| 成年人在线视频 | 久久精品国产久精国产 | 欧美激情国产日韩精品一区18 | 91综合在线观看 | av黄色在线观看 | 亚洲精选久久 | 亚洲精品一区二区三区在线 | 日韩欧美在线观看 | 色婷婷久久久久swag精品 | 国产视频福利一区 | 久久久久久久一区二区三区 | 99热在线免费| 久久久91 | 亚洲国产一区在线 | 黄色av网站在线观看 | av中文字幕网| av黄色片在线观看 | 亚洲精品乱码久久久久久久久 | 成人二区| 中文字幕一区二区三区四区 | 国产亚洲精品精品国产亚洲综合 | 亚洲日本中文 | www.99久久.com| 久久剧场| 亚洲一区二区三区在线 | 日韩欧美三级电影 | 免费观看av| 一级做a爰片性色毛片16 | 色婷婷久久久亚洲一区二区三区 | 国产男女猛烈无遮掩视频免费网站 | 久久久久久一区 |