您现在的位置是:Instagram刷粉絲, Ins買粉絲自助下單平台, Ins買贊網站可微信支付寶付款 > 

04 youtube to mp3 買粉絲nverter program in java第(0ffer是什么意思)

Instagram刷粉絲, Ins買粉絲自助下單平台, Ins買贊網站可微信支付寶付款2024-05-06 07:12:18【】9人已围观

简介現在我們手頭上已經有了這些API我們打算做些什么呢?對它們進行探索這種可能性當然是另人好奇的我們正打算看看幾個多樣混合的示例工具提示讓我們使應用工具提示變得透明怎么樣?對于輕量級工具提示實現這一目標是

現在我們手頭上已經有了這些 API 我們打算做些什么呢?對它們進行探索這種可能性當然是另人好奇的 我們正打算看看幾個多樣混合的示例

工具提示讓我們使應用工具提示變得透明怎么樣?對于輕量級工具提示 實現這一目標是相當容易的 因為它們被作為 Swing 頂級窗口的一部分加以繪畫 ( 要獲得關于輕量級彈出菜單的詳細信息 請參見 玻璃窗格和輕量級彈出菜單 條目 )但是 一旦工具提示成為重量級并 打破 窗口綁定 您必須繼續采用 Robot 或 JNI/JNA 現在讓我們看一看使用 AWTUtilities API 如何完成這項任務

javax swing PopupFactory 是創建彈出菜單的廠 工具提示只是彈出功能的一個例子 其他例子包括組合框下拉列表和菜單 PopupFactory setSharedInstance API 可以被用于設置自定義彈出廠 這就是我們想要做的 當前的彈出廠被用于創建所有應用彈出窗口 我們將在所有的工具提示上安裝自定義不透明廠

核心彈出廠的實現是相當復雜的 首先嘗試創建輕量級彈出窗口 當要求創建重量級窗口時 系統要管理高速緩存以便重用先前創建的彈出窗口 實現過程將創建一個新的重量級彈出窗口 在相對較新的膝上型電腦上運行不同的方案還未顯示任何突出的性能突破 讓我們從自定義彈出廠著手研究

public class TranslucentPopupFactory extends PopupFactory { @Override public Popup getPopup(Component owner Component 買粉絲ntents int x int y) throws IllegalArgumentException { // A more plete implementation would cache and reuse // popups return new TranslucentPopup(owner 買粉絲ntents x y) }}TranslucentPopup 的實現相當簡單 構造器創建新的 JWindow 將工具提示的不透明度設置為 從 Looks 項目安裝提供拖放陰影的自定義邊框

TranslucentPopup(Component owner Component 買粉絲ntents int ownerX int ownerY) { // create a new heavyweight window this popupWindow = new JWindow() // mark the popup with partial opacity sun awt AWTUtilities setWindowOpacity(popupWindow (買粉絲ntents instanceof JToolTip) ? f f) // determine the popup location popupWindow setLocation(ownerX ownerY) // add the 買粉絲ntents to the popup popupWindow getContentPane() add(買粉絲ntents BorderLayout CENTER) 買粉絲ntents invalidate() JComponent parent = (JComponent) 買粉絲ntents getParent() // set the shadow border parent setBorder(new ShadowPopupBorder()) }現在我們需要重寫 Popup 的 show() 方法來標記整個彈出窗口為透明樣式 這要求拖放陰影邊框的每個像素具有透明性

@Override public void show() { this popupWindow setVisible(true) this popupWindow pack() // mark the window as non opaque so that the // shadow border pixels take on the per pixel // translucency sun awt AWTUtilities setWindowOpaque(this popupWindow false) }hide() 方法只是隱藏并處置彈出窗口

@Override public void hide() { this popupWindow setVisible(false) this popupWindow removeAll() this popupWindow dispose() }要安裝該彈出窗口 僅簡單調用

PopupFactory setSharedInstance(new TranslucentPopupFactory()) 圖 顯示了一個具有透明工具提示的示例幀 注意 與工具提示保持視覺(透明性和拖放陰影邊框)上的一致性跨越 Swing 幀綁定并擴展到后臺 Eclipse 窗口

    圖 工具提示

現在我們做相同的動畫 當工具提示顯示時將顏色調淡些 當它被隱藏起來時把它的顏色漸隱如何?一旦您熟悉了 AWTUtilities API 上述操作不難實現 下面給出 show() 方法的代碼

@Override public void show() { if (this toFade) { // mark the popup with % opacity this currOpacity = sun awt AWTUtilities setWindowOpacity(popupWindow f) } this popupWindow setVisible(true) this popupWindow pack() // mark the window as non opaque so that the // shadow border pixels take on the per pixel // translucency sun awt AWTUtilities setWindowOpaque(this popupWindow false) if (this toFade) { // start fading in this fadeInTimer = new Timer( new ActionListener() { public void actionPerformed(ActionEvent e) { currOpacity += if (currOpacity <= ) { sun awt AWTUtilities setWindowOpacity(popupWindow currOpacity / f) // workaround bug should call // popupWindow repaint() but that will not repaint the // panel popupWindow getContentPane() repaint() } else { currOpacity = fadeInTimer stop() } } }) this fadeInTimer setRepeats(true) this fadeInTimer start() } }這時我們用0%的不透明度標記彈出窗口 然后我們啟動重復計時器進行五次迭代 每一次跌代我們增加窗口不透明度 % 并重新繪畫 最后我們停止計時器 最終的視覺結果是工具提示外觀的平滑退色序列 這一序列持續大約 毫秒

hide() 方法非常類似

@Override public void hide() { if (this toFade) { // cancel fade in if it s running if (this fadeInTimer isRunning()) this fadeInTimer stop() // start fading out this fadeOutTimer = new Timer( new ActionListener() { public void actionPerformed(ActionEvent e) { currOpacity = if (currOpacity >= ) { sun awt AWTUtilities setWindowOpacity(popupWindow currOpacity / f) // workaround bug should call // popupWindow repaint() but that will not repaint the // panel popupWindow getContentPane() repaint() } else { fadeOutTimer stop() popupWindow setVisible(false) popupWindow removeAll() popupWindow dispose() currOpacity = } } }) this fadeOutTimer setRepeats(true) this fadeOutTimer start() } else { popupWindow setVisible(false) popupWindow removeAll() popupWindow dispose() } }首先檢查退色序列是否仍在運行 根據需要將它刪除 然后 不立即隱藏窗口 而是將不透明度以 % 的增量從 % 改為 (因此漸隱序列是退色序列的兩倍)然后隱藏并處置彈出窗口 注意兩種方法參閱了 Boolean toFade 變量 —— 它在工具提示上被設置為 true 彈出窗口的其他類型(菜單 組合框下拉列表)沒有退色動畫

視頻反射現在讓我們做些更為激動人心的事情 在 Romain Guy 的博客條目 重畫管理器演示(第 章) 中 它顯示了提供反射功能的 Swing 組件 從他與 Chet Haase 合著的 《骯臟的富客戶機》 書中抽取一段測試應用程序 其中顯示該組件提供了 QuickTime 電影的實時反射 在窗口綁定 之外 進行反射如何?

首先要有實際應用中的反射幀的屏幕截圖 圖 顯示了正在播放 Get a Mac 廣告的形狀規則的 Swing 幀( 使用嵌入式 QuickTime 播放器 ) 伴隨著覆蓋桌面的透明的實時反射

圖 QuickTime 電影的反射

該實現重用了來自 Romain 的幾個構造塊并將它們擴展到 楨外 它還有一個重畫管理器 ( 要了解關于重畫管理器方面的詳細信息 請參見 使用重畫管理器的驗證覆蓋 條目 )以便將主楨內容與反射窗口保持同步 還需要在主楨上注冊組件偵聽器和窗口偵聽器以便確保反射窗口與主窗口的可見性 位置和大小保持同步 除此之外 還要有一個自定義窗格將其內容繪畫到脫屏緩沖區 脫屏緩沖區被用于繪畫主楨和在反射窗口內的反射

讓我們看一下代碼 主類是擴展 JFrame 的 JReflectionFrame 構造器創建了反射窗口并向其中添加非雙

很赞哦!(8)

Instagram刷粉絲, Ins買粉絲自助下單平台, Ins買贊網站可微信支付寶付款的名片

职业:程序员,设计师

现居:福建莆田仙游县

工作室:小组

Email:[email protected]