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

正文內容

第四章圖形編程-預覽頁

2024-10-30 12:34 上一頁面

下一頁面
 

【正文】 內容窗格是用來添加組件的,獲得內容窗格的代碼如下: 在 AWT中可調用 add()把組件直接添加到 AWT Frame中 ,但在 Swing中組件只能添加到內容窗格里 六 .顯示信息 前面的例子中 ,信息都顯示在控制臺窗口 ,現在我們試著把信息顯示到 JFrame中 JFrame的結構有點復雜,它包括:根窗格、布局窗格、透明窗格和 內容窗格 用戶也可以創(chuàng)建一個畫板,然后在畫板上進行繪制,最后將畫板添加到內容窗格里,此時需要重寫 paintComponent() paintComponent(Graphics g)是定義在JComponent中,每當該方法被調用時,系統(tǒng)就自動產生一個 Graphics類型的參數,傳遞給paintComponent方法中的參數 g Container cp=getContentPane()。 setSize(WIDTH, HEIGHT)。 } class NotHelloWorldPanel extends JPanel { public void paintComponent(Graphics g) { (g)。 } 常用 API Container getContentPane() 返回 JFrame的內容窗格 void repain() 重新繪制組件 void repaint(int x, int y,intwidth,int height) 重新繪制組件的一部分 void paintComponent(Graphics g) 需要重寫該方法來說明你的組件應如何繪制 一 . 2D圖形 隨著 , J2SE包含了一個 Java 2D庫,該庫實現了一個非常強大的圖形操作集 如何獲得 Graphics 2D類對象 該類是 Graphics類的子類,通常可用Graphics對象轉換而來 .例: public void paintComponent(Graphics g) { graphics2D g2=(graphics 2D)g。/*Error*/ getWidth()返回 double值,應進行轉換: float f=(float)()。 double topY = 100。 (rect)。 // draw a diagonal line (new (leftX, topY, leftX + width, topY + height))。 Ellipse2D circle = new ()。例: ()。 Graphics2D g2 = (Graphics2D)g。 double height = 150。 // draw the enclosed ellipse Ellipse2D ellipse = new ()。 } } 例:將字符串顯示在畫板中央的例子 三 .文本和字體 SanaSerif Serif Monospaced Dialog DialogInput + Font serif=new Font(“Serif”,14)。 FontRenderContext context= g2. getFontRenderContext()。 double ascent= ()。 FontRenderContext context= g2. getFontRenderContext()。 double ascent= ()。 目前只能讀取 gif和 JPEG格式的文件 下面一段代碼用來在本地機上加載一個名為 : Image img=(). getImage(“”) 若從網絡上加載,必須提供 URL 例: URL u=new URL( “ Image img=(). getImage(u) 顯示代碼: ? public void paintComponent(Graphics g) ? {… . ? (img,x,y,null)。 (img,id)。 (image, 0)。 int imageHeight = (this)。 i++) for (int j = 0。 }
點擊復制文檔內容
教學課件相關推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1