日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > java >内容正文

java

java invalidate_Java Component.invalidate方法代码示例

發布時間:2024/9/27 java 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java invalidate_Java Component.invalidate方法代码示例 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

import java.awt.Component; //導入方法依賴的package包/類

/** Installs the component we will embed to display the property */

private void installDisplayerComponent() {

//Fetch or instantiate the component we will embed to display the

//property. Depending on the prefs, it may be a RendererPropertyDisplayer,

//an EditablePropertyDisplayer or a CustomPropertyDisplayer.

PropertyDisplayer displayer = getPropertyDisplayer();

//Find who has focus now, so if we have focus, focus won't end up set

//to null

Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getPermanentFocusOwner();

boolean hadFocus = (focusOwner == this) || isAncestorOf(focusOwner);

if (hadFocus) {

//If we had focus, clear the global focus owner for now, so that

//when the existing component is removed, it does not cause

//focus to get briefly set to a random component

KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner();

}

//Fetch the new inner component (the custom editor or Inplace editor)

Component newInner = displayer.getComponent();

//Set the enabled state appropriately. For implementations of

//PropertyDisplayer_Editable, this will already be handled; for render-

//only cases, it should be handled explicitly

if (!(displayer instanceof PropertyDisplayer_Editable)) {

//only for renderers

newInner.setEnabled(isEnabled() && getProperty().canWrite());

}

newInner.setForeground(getForeground());

newInner.setBackground(getBackground());

//Make sure the inner component has really changed

if (newInner != inner) {

synchronized (getTreeLock()) {

//remove the odl component

if (inner != null) {

remove(inner);

}

//and add the new one (if any)

if (newInner != null) {

add(newInner);

//invalidate its layout so it will be re-laid out

newInner.invalidate();

inner = newInner;

}

}

}

//Force a re-layout immediately if visible

if (isShowing() && !(getParent() instanceof javax.swing.CellRendererPane)) {

validate();

}

//Restore focus if necessary

if (hadFocus && isEnabled() && ((preferences & PREF_READ_ONLY) == 0)) {

requestFocus();

}

//Simply adding a component to a container can sometimes cause it to be

//given focus even though it's not focusable. If this has happened,

//find the next component in the focus cycle root and force focus to that.

//Mainly a problem with JFileChooser, but we also have a few property

//editors that force focus on addNotify which should be fixed

if (!isEnabled() || ((preferences & PREF_READ_ONLY) != 0)) {

Component focus = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();

if ((focus == inner) || ((inner instanceof Container) && ((Container) inner).isAncestorOf(focus))) {

this.transferFocusUpCycle();

}

}

}

總結

以上是生活随笔為你收集整理的java invalidate_Java Component.invalidate方法代码示例的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。