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

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

我如何找到擴(kuò)展類(lèi)的方法在哪里

我如何找到擴(kuò)展類(lèi)的方法在哪里

心有法竹 2023-04-19 15:37:25
我仍在學(xué)習(xí)編碼,但我找不到 paintComponent 方法的來(lái)源,想了解如何找到它的位置以供將來(lái)參考。import java.awt.*;import javax.swing.*;public class Peach extends JPanel{    public void paintComponent (Graphics g){    }}
查看完整描述

2 回答

?
慕妹3146593

TA貢獻(xiàn)1820條經(jīng)驗(yàn) 獲得超9個(gè)贊

paintComponent方法實(shí)際上來(lái)自抽象類(lèi)JComponent,它由類(lèi)擴(kuò)展,而類(lèi)又是您要擴(kuò)展的JPanel類(lèi)。

的實(shí)際實(shí)現(xiàn)paintComponent是:

/**

?* Calls the UI delegate's paint method, if the UI delegate

?* is non-<code>null</code>.? We pass the delegate a copy of the

?* <code>Graphics</code> object to protect the rest of the

?* paint code from irrevocable changes

?* (for example, <code>Graphics.translate</code>).

?* <p>

?* If you override this in a subclass you should not make permanent

?* changes to the passed in <code>Graphics</code>. For example, you

?* should not alter the clip <code>Rectangle</code> or modify the

?* transform. If you need to do these operations you may find it

?* easier to create a new <code>Graphics</code> from the passed in

?* <code>Graphics</code> and manipulate it. Further, if you do not

?* invoker super's implementation you must honor the opaque property,

?* that is

?* if this component is opaque, you must completely fill in the background

?* in a non-opaque color. If you do not honor the opaque property you

?* will likely see visual artifacts.

?* <p>

?* The passed in <code>Graphics</code> object might

?* have a transform other than the identify transform

?* installed on it.? In this case, you might get

?* unexpected results if you cumulatively apply

?* another transform.

?*

?* @param g the <code>Graphics</code> object to protect

?* @see #paint

?* @see ComponentUI

?*/

protected void paintComponent(Graphics g) {

? ? if (ui != null) {

? ? ? ? Graphics scratchGraphics = (g == null) ? null : g.create();

? ? ? ? try {

? ? ? ? ? ? ui.update(scratchGraphics, this);

? ? ? ? }

? ? ? ? finally {

? ? ? ? ? ? scratchGraphics.dispose();

? ? ? ? }

? ? }

}


查看完整回答
反對(duì) 回復(fù) 2023-04-19
?
GCT1015

TA貢獻(xiàn)1827條經(jīng)驗(yàn) 獲得超4個(gè)贊

通常這樣的問(wèn)題可以通過(guò)查看文檔來(lái)回答。如果您在類(lèi)中看不到某個(gè)方法,它很可能是從父級(jí)繼承的。

您還可以從 IDE 內(nèi)部打開(kāi)類(lèi)聲明,您將能夠找到該方法。


查看完整回答
反對(duì) 回復(fù) 2023-04-19
  • 2 回答
  • 0 關(guān)注
  • 142 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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