第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會有你想問的

接口的問題

接口的問題

慕姐4675099 2015-09-15 08:06:09
package com.lzw;import java.awt.*;import javax.swing.*;public class DrawIcon implements Icon { ? ? ?private int width; private int height; ? ? ?public int getIconHeight() { // 實(shí)現(xiàn)getIconHeight()方法 ? ? ? ? ? return this.height; } ? ?public int getIconWidth() { // 實(shí)現(xiàn)getIconWidth()方法 ? ? ? ? ? return this.width; } ? ? ?public DrawIcon(int width, int height) { // 定義構(gòu)造方法 ? ? ? ?this.width = width; ? ? ? ?this.height = height; } ? public void paintIcon(Component arg0, Graphics arg1, int x, int y) { ? ? ? ? ?arg1.fillOval(x, y, width, height); // 繪制一個(gè)圓形 } ? ? ?public static void main(String[] args) { ? ? ? ?DrawIcon icon = new DrawIcon(15, 15); ? ? ? ? ?JLabel j = new JLabel("測試", icon, SwingConstants.CENTER); ? ? ? ? ?JFrame jf = new JFrame(); ? ? ? ? ?Container c = jf.getContentPane(); ? ? ? ?c.add(j); ? ? ? ?jf.setSize(1000,1000); ? ? ? ?jf.setVisible(true); ? ? ? ?jf.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); }}程序中沒有運(yùn)行icon.paintIcon();方法的語句,但是后面”JLabel j = new JLabel("測試", icon, SwingConstants.CENTER);“中,直接調(diào)用了icon,而且程序結(jié)果也直接繪出了圓形圖標(biāo),那么這里是在實(shí)例化DrawIcon類對象icon之后,系統(tǒng)默認(rèn)自動調(diào)用并且運(yùn)行了類中重寫的接口中paintIcon();方法嗎?求大神解答啊
查看完整描述

目前暫無任何回答

  • 0 回答
  • 0 關(guān)注
  • 1518 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號